/* Mobile forms and touch controls: branded inputs, touch-target buttons,
   action/quick-action groups, status badges, and the detail-page action bar.
   Loaded after Bootstrap so these override its form/button defaults. */

/* Mobile-optimized forms */
.mobile-optimized-form {
    padding: 0;
}

/* iOS auto-zooms inputs whose font-size resolves below 16px. .form-control-mobile
   handles its own branded inputs; this catch-all covers plain inputs/selects/textareas
   on small viewports so the same protection applies site-wide. */
@media (max-width: 768px) {
    input:not([type=submit]):not([type=button]):not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=file]),
    select,
    textarea {
        font-size: max(16px, 1rem);
    }
}

.form-control-mobile {
    min-height: 44px; /* Touch target compliance */
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 12px 16px;
    border-radius: 8px;
    border: 2px solid var(--border-light);
    transition: border-color 0.2s ease;
}

.form-control-mobile:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(var(--primary-rgb), 0.25);
    outline: none;
}

.form-label {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.form-section {
    margin-bottom: 24px;
    padding: 20px 0;
}

.form-section-title {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-light);
}

.btn-mobile {
    min-height: 44px; /* Touch target compliance */
    font-size: 1rem;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
}

.form-actions {
    display: flex;
    gap: 12px;
    padding: 20px 0;
}

.form-actions .btn-mobile {
    flex: 1;
}

/* Touch-optimized buttons */
.btn-touch {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-touch:active {
    transform: scale(0.98);
}

/* Action button groups with proper spacing */
.action-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.action-group .btn {
    flex: 1;
    min-width: 120px;
}

/* Status badges with better touch targets */
.status-badge-touch {
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 20px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
}

/* Quick action buttons */
.quick-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 16px 0;
}

.quick-action-btn {
    flex: 1;
    min-width: 120px;
    min-height: 44px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 576px) {
    /* New Client / New Quote sit side by side on mobile.
       Base rule gives flex:1; clearing min-width lets them
       share the row evenly instead of stacking full-width.
       Trim the inherited .btn-mobile padding/size so the
       (nowrap) label stays centred inside the narrow button. */
    .quick-action-btn {
        min-width: 0;
        padding: 12px 8px;
        font-size: 0.9rem;
    }

    .quick-action-btn .bi {
        margin-right: 0.35rem !important;
    }
}

/* =========================================================================
   Detail Page Action Bar - Mobile Layout
   Handles button layout, spacing, and border radius for mobile action bars
   ========================================================================= */

@media (max-width: 767px) {
    /* Container full width on mobile */
    .card-body .btn-group[role="group"] {
        display: flex !important;
        width: 100% !important;
    }

    /* Mobile action buttons fill available space equally */
    .mobile-action-btn {
        flex: 1;
    }

    /* Status dropdown and form wrappers also fill space */
    .mobile-action-group {
        flex: 1;
    }

    /* Buttons inside flex containers fill parent */
    .mobile-action-group .btn {
        width: 100%;
    }

    /* Reset ALL buttons to square - override Bootstrap defaults */
    .card-body .btn-group[role="group"] .btn {
        border-radius: 0 !important;
    }

    /* Override for buttons with rounded-start: keep left rounded, force right square */
    .card-body .btn-group[role="group"] .btn.rounded-start {
        border-top-left-radius: 0.375rem !important;
        border-bottom-left-radius: 0.375rem !important;
        border-top-right-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
    }

    /* Override for buttons with rounded-end: keep right rounded, force left square */
    .card-body .btn-group[role="group"] .btn.rounded-end,
    .card-body .btn-group[role="group"] .dropdown-toggle.rounded-end {
        border-top-left-radius: 0 !important;
        border-bottom-left-radius: 0 !important;
        border-top-right-radius: 0.375rem !important;
        border-bottom-right-radius: 0.375rem !important;
    }
}

/* Desktop: reset container width to auto */
@media (min-width: 768px) {
    .card-body .btn-group[role="group"] {
        width: auto !important;
    }
}
