/* Mobile-Friendly Form Improvements */

/* Base form improvements for touch */
.form-control,
.form-select {
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 44px; /* Touch-friendly minimum */
}

/* Mobile-specific checkbox sizing - inherits styles from forms.css */
.form-check-input {
    font-size: 16px; /* Prevents zoom on iOS */
}

/* Mobile form optimizations */
@media (max-width: 767px) {
    /* Form containers */
    .card-body form {
        padding: 1rem 0.5rem;
    }
    
    /* Form groups */
    .mb-3 {
        margin-bottom: 1.5rem !important;
    }
    
    /* Labels */
    .form-label {
        font-weight: 600;
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
        display: block;
    }
    
    /* Form controls */
    .form-control,
    .form-select {
        padding: 12px 16px;
        border-radius: 8px;
        border: 1.5px solid var(--border-color);
        font-size: 16px;
        min-height: 44px;
        width: 100%;
        transition: all 0.3s ease;
    }
    
    .form-control:focus,
    .form-select:focus {
        border-color: var(--navy-primary);
        box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
        outline: none;
    }
    
    /* Textarea specific */
    .form-control[rows] {
        min-height: 100px;
        resize: vertical;
    }
    
    /* Checkboxes and radios */
    .form-check {
        padding-left: 2rem;
        margin-bottom: 1rem;
    }
    
    .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
        margin-left: -2rem;
        margin-top: 0.125rem;
        /* Keep the checkbox styles from above, just adjust size for mobile */
    }
    
    .form-check-label {
        font-size: 0.9rem;
        margin-left: 0.5rem;
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 0.5rem 0;
    }
    
    /* Form rows - stack on mobile */
    .row .col-md-6,
    .row .col-lg-4,
    .row .col-lg-6 {
        margin-bottom: 1rem;
    }
    
    /* Button groups in forms */
    .d-flex.gap-2,
    .d-flex.mt-4,
    .btn-toolbar {
        flex-direction: column;
        gap: 0.5rem !important;
    }
    
    .d-flex.gap-2 .btn,
    .d-flex.mt-4 .btn,
    .btn-toolbar .btn {
        width: 100%;
        margin-bottom: 0.5rem;
        justify-content: center;
        min-height: 48px;
    }
    
    /* Primary button should be first on mobile */
    .btn-primary {
        order: -1;
    }
    
    /* Form text/help text */
    .form-text {
        font-size: 0.8rem;
        margin-top: 0.25rem;
        color: var(--text-secondary);
        line-height: 1.3;
    }
    
    /* Input groups */
    .input-group {
        flex-wrap: nowrap;
    }
    
    .input-group .btn {
        min-width: 44px;
        white-space: nowrap;
    }
    
    /* File inputs */
    .form-control[type="file"] {
        padding: 8px;
    }
    
    /* Select2 mobile improvements (if using Select2) */
    .select2-container {
        width: 100% !important;
    }
    
    .select2-selection {
        min-height: 44px !important;
        border-radius: 8px !important;
        border: 1.5px solid var(--border-color) !important;
    }
    
    /* Number inputs with increment/decrement */
    input[type="number"] {
        -webkit-appearance: none;
        -moz-appearance: textfield;
    }
    
    input[type="number"]::-webkit-outer-spin-button,
    input[type="number"]::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }
    
    /* Date/time inputs */
    input[type="date"],
    input[type="time"],
    input[type="datetime-local"] {
        min-height: 44px;
        padding: 8px 12px;
    }
    
    /* Form validation styles */
    .is-invalid {
        border-color: var(--danger);
        box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.2);
    }
    
    .is-valid {
        border-color: var(--success);
        box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
    }
    
    .invalid-feedback,
    .valid-feedback {
        font-size: 0.8rem;
        margin-top: 0.25rem;
    }
    
    /* Required field indicators */
    .required::after {
        content: " *";
        color: var(--danger);
        font-weight: bold;
    }
    
    /* Form sections on mobile */
    .card .card-header {
        padding: 1rem 1rem 0.75rem;
    }
    
    .card .card-header h5,
    .card .card-header h6 {
        font-size: 1rem;
        margin-bottom: 0;
    }
    
    /* Collapsible form sections */
    .collapse-toggle {
        width: 100%;
        text-align: left;
        background: none;
        border: none;
        padding: 0.75rem 1rem;
        font-weight: 600;
        color: var(--text-primary);
    }
    
    .collapse-toggle::after {
        content: "\f078";
        font-family: "Font Awesome 6 Free";
        font-weight: 900;
        float: right;
        transition: transform 0.3s ease;
    }
    
    .collapse-toggle[aria-expanded="true"]::after {
        transform: rotate(180deg);
    }
}

/* Extra small mobile adjustments */
@media (max-width: 575px) {
    .card-body form {
        padding: 0.75rem 0.25rem;
    }
    
    .form-control,
    .form-select {
        padding: 10px 12px;
        font-size: 15px;
    }
    
    .btn {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
    
    .form-label {
        font-size: 0.85rem;
    }
    
    .form-text {
        font-size: 0.75rem;
    }
}

/* Landscape phone adjustments */
@media (max-width: 767px) and (orientation: landscape) {
    .form-control,
    .form-select {
        min-height: 38px;
    }
    
    .form-check-input {
        width: 1rem;
        height: 1rem;
        /* Keep the checkbox styles from above, just adjust size for landscape */
    }
    
    .form-check-label {
        min-height: 38px;
        font-size: 0.85rem;
    }
    
    .mb-3 {
        margin-bottom: 1rem !important;
    }
}

/* High DPI improvements */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .form-control,
    .form-select,
    .btn {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}