/*
 * Simple Application Manager Form Styles
 * Version: 3.8.1
 */
.sam-application-form {
    max-width: 800px;
    margin: 2rem auto;
    background: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.07);
}

/* Form Sections (Fieldsets) */
.form-section {
    border: none;
    padding: 0;
    margin: 0 0 2.5rem 0;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 2.5rem;
}
.form-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 1.5rem;
}
.form-section legend {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2E8B57;
    margin-bottom: 1.5rem;
    padding: 0;
}

/* Grid for layout */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* Individual field groups */
.form-field-group {
    margin-bottom: 1.5rem; 
}
.form-field-group:last-child {
    margin-bottom: 0;
}
.form-grid > .form-field-group {
    margin-bottom: 0;
}

.form-field-group label {
    display: block;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 0.5rem;
}
.form-field-group input[type="text"],
.form-field-group input[type="email"],
.form-field-group input[type="tel"],
.form-field-group input[type="file"],
.form-field-group input[type="date"],
.form-field-group textarea,
.form-field-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    background-color: #f7fafc;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.form-field-group input:focus,
.form-field-group textarea:focus,
.form-field-group select:focus {
    outline: none;
    border-color: #2E8B57;
    box-shadow: 0 0 0 2px rgba(46, 139, 87, 0.2);
}
.form-field-group textarea {
    min-height: 150px;
    resize: vertical;
}

/* Checkbox and Radio Groups */
.checkbox-group, .radio-group {
    display: grid;
    gap: 0.75rem;
}
.radio-group {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}
.checkbox-group.cols-2 { grid-template-columns: repeat(2, 1fr); }
.checkbox-group.cols-3 { grid-template-columns: repeat(3, 1fr); }

.checkbox-group label, .radio-group label {
    display: flex;
    align-items: center;
    font-weight: 500;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.3s, background-color 0.3s;
}
.checkbox-group label:hover, .radio-group label:hover {
    border-color: #2E8B57;
}
.checkbox-group input, .radio-group input {
    margin-right: 0.75rem;
    accent-color: #2E8B57;
}

/* Spacing & Separator utility */
.sam-mt-lg {
    margin-top: 2.5rem;
}
.sam-separator {
    border: 0;
    border-top: 1px solid #e2e8f0;
    margin: 0 0 1.5rem 0;
}

/* Conditional fields */
.sam-conditional-field {
    display: none; /* Hidden by default */
}
#residency-status-group.sam-conditional-field,
#residency-other-group.sam-conditional-field,
#visa-expiry-group.sam-conditional-field {
    margin-top: 1.5rem;
}

/* Choices.js Overrides */
.choices { margin-bottom: 0; }
.choices__inner { background-color: #f7fafc; border: 1px solid #cbd5e0; border-radius: 6px; padding: 0.5rem 0.75rem; min-height: auto; font-size: 1rem; }
.choices.is-focused .choices__inner { border-color: #2E8B57; box-shadow: 0 0 0 2px rgba(46, 139, 87, 0.2); }
.choices__list--dropdown { border-radius: 6px; border-color: #e2e8f0; }
.choices__list--dropdown .choices__item--selectable.is-highlighted { background-color: #2E8B57; }
.choices[data-type*="select-one"]::after { border-color: #4a5568 transparent transparent; right: 12.5px; margin-top: -3px; }
.choices[data-type*="select-one"].is-open::after { border-color: transparent transparent #4a5568; margin-top: -3px; }

/* Availability Table Styles */
.availability-table-wrapper { overflow-x: auto; }
.availability-table { width: 100%; border-collapse: collapse; margin-top: 1rem; min-width: 600px; }
.availability-table th, .availability-table td { border: 1px solid #e2e8f0; padding: 0.5rem; text-align: center; vertical-align: middle; }
.availability-table th { background-color: #f7fafc; font-weight: 600; font-size: 0.9em; }
.availability-table td:first-child { text-align: left; font-weight: 600; background-color: #f7fafc; }
.availability-table td .mobile-cell-content { display: flex; justify-content: center; align-items: center; }
.availability-table td label { margin: 0; padding: 0.5rem; display: inline-flex; justify-content: center; align-items: center; cursor: pointer; width: auto; height: auto; font-weight: normal; border: none; }
.availability-table td label input { display: none; }
.availability-table td label span { display: inline-block; width: 20px; height: 20px; border: 2px solid #cbd5e0; border-radius: 4px; transition: all 0.2s; }
.availability-table td label input:checked + span { background-color: #2E8B57; border-color: #2E8B57; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-6'/%3e%3c/svg%3e"); }
.availability-table .slot-details { display: none; margin-left: 0.5rem; }
.availability-table .slot-details input { width: 100%; max-width: 120px; padding: 0.5rem; font-size: 0.9em; margin: 0 auto; background-color: #fff; }

/* File upload styles */
#sam-files-container .sam-file-input-wrapper { margin-bottom: 0.75rem; }
.sam-add-file-button { background: none; border: 1px dashed #2E8B57; color: #2E8B57; padding: 0.5rem 1rem; border-radius: 4px; cursor: pointer; margin-top: 0.5rem; transition: all 0.3s; }
.sam-add-file-button:hover { background: rgba(46, 139, 87, 0.1); border-style: solid; }

/* intl-tel-input overrides */
.iti { width: 100%; }
.iti__country-list { z-index: 100; }

/* Messages and Submit Button */
.sam-form-message { padding: 1rem; margin-bottom: 1.5rem; border-radius: 4px; border: 1px solid transparent; }
.sam-form-success { color: #155724; background-color: #d4edda; border-color: #c3e6cb; }
.sam-form-errors { color: #721c24; background-color: #f8d7da; border-color: #f5c6cb; }
.sam-form-errors ul { margin: 0; padding-left: 20px; }
.form-submit-group { text-align: center; margin-top: 2rem; }
.sam-submit-button { display: inline-block; background-color: #2E8B57; color: white; font-weight: bold; font-size: 1.1rem; padding: 0.8rem 2.5rem; border: none; border-radius: 6px; cursor: pointer; transition: all 0.3s; }
.sam-submit-button:hover { background-color: #256d44; transform: translateY(-2px); box-shadow: 0 4px 15px rgba(0,0,0,0.1); }

/* Responsive Adjustments */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    .sam-application-form {
        padding: 1.5rem;
    }
    .form-section legend {
        font-size: 1.25rem;
    }
    .checkbox-group.cols-3,
    .checkbox-group.cols-2 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* --- CORRECTED Responsive Availability Table --- */
    .availability-table { border: none; min-width: 0; }
    .availability-table thead { display: none; }
    .availability-table tr { display: block; border: 1px solid #e2e8f0; border-radius: 6px; margin-bottom: 1rem; padding: 0.75rem; }
    
    /* Default for all cells in mobile view */
    .availability-table td {
        display: block;
        text-align: left;
        border: none;
        padding: 0.5rem 0;
    }
    .availability-table tr td:not(:last-child) {
        border-bottom: 1px solid #f1f1f1;
    }

    /* Style for the Day header cell */
    .availability-table td[data-label="Day"] { 
        font-size: 1.1rem; 
        font-weight: bold; 
        padding-bottom: 0.75rem; 
        margin-bottom: 0.5rem;
    }

    /* Style for the time slot cells (Morning, Afternoon, Evening) */
    .availability-table td:not([data-label="Day"]) {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
    }

    /* The ::before pseudo-element for labels */
    .availability-table td:not([data-label="Day"])::before { 
        content: attr(data-label); 
        font-weight: 600; 
        color: #4a5568; 
    }
    .availability-table td[data-label="Day"]::before {
        content: none;
    }
    
    .availability-table td .mobile-cell-content { 
        justify-content: flex-end; /* Pushes checkbox to the right */
    }
}

@media (max-width: 480px) {
    .checkbox-group.cols-3,
    .checkbox-group.cols-2 {
        grid-template-columns: 1fr;
    }
}