/**
 * AYIO Jobs - Enhanced Form UX Styles
 * Adds visual polish to form validation, progress tracking, and smart features
 */

/* ==================== PROGRESS BAR ==================== */
.form-progress-container {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

.form-progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.form-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold) 0%, var(--gold-light) 100%);
    border-radius: 10px;
    transition: width 0.5s ease, background-color 0.3s ease;
    min-width: 0%;
}

.form-progress-fill.complete {
    background: linear-gradient(90deg, var(--success, #10b981) 0%, #34d399 100%);
}

.form-progress-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: var(--gray-600);
}

.form-progress-text .fields-complete {
    font-weight: 600;
    color: var(--navy);
}

/* ==================== VALIDATION STATUS ==================== */
.validation-status {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.125rem;
    font-weight: bold;
    pointer-events: none;
    z-index: 1;
}

/* Add padding to inputs to make room for status icon */
.form-group input:has(+ .validation-status),
.form-group input:not(:has(~ .validation-status)) {
    padding-right: 40px;
}

.validation-help {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    transition: color 0.2s ease;
}

/* ==================== ALERT STYLES ==================== */
.alert-info {
    background: var(--info-bg, #dbeafe);
    color: var(--info-text, #1e40af);
    border: 1px solid var(--info-border, #93c5fd);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9375rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.alert-info i {
    margin-top: 2px;
}

/* ==================== LICENCE SUGGESTION ==================== */
.licence-suggestion {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== TRAILER WARNING ==================== */
.trailer-licence-warning {
    animation: pulse 0.5s ease;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

/* ==================== SECTION HIGHLIGHT ==================== */
.conditional-section {
    transition: opacity 0.3s ease, transform 0.3s ease, border-color 0.3s ease;
}

.conditional-section.section-revealed {
    animation: sectionReveal 0.4s ease;
}

@keyframes sectionReveal {
    0% {
        opacity: 0;
        transform: translateY(-15px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.conditional-section.section-highlight {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(247, 195, 46, 0.2);
}

/* ==================== AUTOSAVE INDICATOR ==================== */
.autosave-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--navy);
    color: var(--white);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.autosave-indicator.saved {
    background: var(--success);
    opacity: 1;
    transform: translateY(0);
}

.autosave-indicator.loaded {
    background: var(--gold);
    color: var(--navy);
    opacity: 1;
    transform: translateY(0);
}

/* ==================== COLLAPSIBLE SECTIONS ==================== */
.collapsible-section {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

.collapsible-header {
    background: var(--gray-50);
    padding: 1rem 1.25rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background 0.2s ease;
}

.collapsible-header:hover {
    background: var(--gray-100);
}

.collapsible-header h3 {
    margin: 0;
    font-size: 1.125rem;
    color: var(--navy);
}

.collapsible-toggle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--white);
    border: 1px solid var(--gray-300);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    font-weight: bold;
    color: var(--gray-600);
    transition: all 0.2s ease;
}

.collapsible-section.open .collapsible-toggle {
    transform: rotate(180deg);
    background: var(--gold);
    border-color: var(--gold);
    color: var(--navy);
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.collapsible-section.open .collapsible-content {
    max-height: 2000px;
    padding: 1.25rem;
}

/* ==================== AUTOSAVE CONTROLS ==================== */
.autosave-controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: var(--radius);
}

/* ==================== SMART DEFAULT HIGHLIGHT ==================== */
.highlight-field {
    animation: fieldHighlight 3s ease;
}

@keyframes fieldHighlight {
    0% {
        background-color: var(--warning-bg, #fef3c7);
    }
    70% {
        background-color: var(--warning-bg, #fef3c7);
    }
    100% {
        background-color: transparent;
    }
}

/* ==================== VEHICLE/TRAILER DROPDOWN STYLING ==================== */
select option.highlight {
    background-color: var(--success-bg, #d1fae5);
    font-weight: 600;
}

select option.requires-licence {
    color: var(--warning, #f59e0b);
}

select option.compatible {
    background-color: var(--success-bg, #d1fae5);
}

/* ==================== MOBILE OPTIMIZATIONS ==================== */
@media (max-width: 768px) {
    .form-progress-container {
        padding: 0.875rem 1rem;
        margin-bottom: 1rem;
    }

    .form-progress-text {
        font-size: 0.8125rem;
    }

    .autosave-indicator {
        bottom: 10px;
        right: 10px;
        left: 10px;
        text-align: center;
    }

    .collapsible-header {
        padding: 0.875rem 1rem;
    }

    .collapsible-header h3 {
        font-size: 1rem;
    }

    /* Make checkboxes larger on mobile */
    input[type="checkbox"],
    input[type="radio"] {
        min-width: 22px;
        min-height: 22px;
    }

    /* Increase touch targets */
    .checkbox-item,
    .checkbox-group label {
        padding: 0.5rem 0;
        min-height: 44px;
    }
}

/* ==================== SECTION CHECKLIST ==================== */
.section-checklist {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.section-checklist h4 {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.section-checklist-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.section-checklist-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    padding: 0.375rem 0.625rem;
    background: var(--white);
    border-radius: 4px;
    border: 1px solid var(--gray-200);
}

.section-checklist-item.done {
    border-color: var(--success);
    background: var(--success-bg, #d1fae5);
}

.section-checklist-item.done::before {
    content: '✓';
    color: var(--success);
    font-weight: bold;
}

.section-checklist-item.next {
    border-color: var(--gold);
    background: var(--warning-bg, #fef3c7);
    animation: nextSectionPulse 2s ease infinite;
}

@keyframes nextSectionPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(247, 195, 46, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(247, 195, 46, 0);
    }
}

/* ==================== LOADING STATES ==================== */
.form-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.form-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== TOOLTIP HELPERS ==================== */
.tooltip-trigger {
    position: relative;
    cursor: help;
    border-bottom: 1px dotted var(--gray-400);
}

.tooltip-trigger::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--navy-dark);
    color: var(--white);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8125rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    margin-bottom: 8px;
}

.tooltip-trigger:hover::after {
    opacity: 1;
}

/* ==================== ENHANCED INPUT STATES ==================== */
.form-group {
    position: relative;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
}

.form-group input.valid,
.form-group select.valid,
.form-group textarea.valid {
    border-color: var(--success);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2310b981'%3E%3Cpath fill-rule='evenodd' d='M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
    padding-right: 40px;
}

.form-group input.invalid,
.form-group select.invalid,
.form-group textarea.invalid {
    border-color: var(--error);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23ef4444'%3E%3Cpath fill-rule='evenodd' d='M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
    padding-right: 40px;
}

/* ==================== SMOOTH SCROLL TO NEXT SECTION ==================== */
.scroll-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: linear-gradient(180deg, transparent 0%, var(--gold) 100%);
    color: var(--navy);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.scroll-hint:hover {
    background: var(--gold);
}

.scroll-hint i {
    animation: bounce 1.5s ease infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(5px);
    }
}

/* ==================== POSTCODE/SUBURB SUGGESTIONS ==================== */
.postcode-suggestions {
    position: absolute;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 250px;
    overflow-y: auto;
    z-index: 9999;
}

.postcode-suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--gray-100);
    transition: background-color 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.postcode-suggestion-item:last-child {
    border-bottom: none;
}

.postcode-suggestion-item:hover {
    background-color: var(--gray-50);
}

.postcode-suggestion-item strong {
    color: var(--navy);
}

.postcode-suggestion-details {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.postcode-suggestion-item:hover .postcode-suggestion-details {
    color: var(--gray-600);
}

/* Loading state for postcode lookup */
.postcode-loading {
    padding: 0.75rem 1rem;
    color: var(--gray-500);
    text-align: center;
    font-size: 0.875rem;
}

/* No results state */
.postcode-no-results {
    padding: 0.75rem 1rem;
    color: var(--gray-500);
    text-align: center;
    font-size: 0.875rem;
}

/* ==================== ROLE CASCADE FORM STYLES ==================== */

/* Section description text */
.section-description {
    font-size: 0.9375rem;
    color: var(--gray-600);
    margin-bottom: 1rem;
    line-height: 1.5;
}

/* Help text styling */
.help-text {
    font-size: 0.8125rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
    display: block;
}

/* Form row for side-by-side fields */
.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 200px;
}

.form-row .form-group.half {
    flex: 0 0 calc(50% - 0.5rem);
    min-width: 150px;
}

/* Input with button container (ABN verify) */
.input-with-button {
    display: flex;
    gap: 0.5rem;
}

.input-with-button input {
    flex: 1;
}

.input-with-button button {
    flex-shrink: 0;
}

/* Conditional section animations */
.conditional-section {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.conditional-section[style*="display: block"] {
    animation: fadeSlideIn 0.3s ease;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Checkbox grid styling */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem 1rem;
}

.checkbox-grid-2 {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

/* Checkbox label styling */
.checkbox-label,
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.375rem 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.checkbox-label:hover,
.checkbox-item:hover {
    background-color: var(--gray-50);
}

.checkbox-label input[type="checkbox"],
.checkbox-item input[type="checkbox"] {
    margin: 0;
    flex-shrink: 0;
}

/* Disabled state for selects */
select:disabled {
    background-color: var(--gray-100);
    color: var(--gray-500);
    cursor: not-allowed;
    opacity: 0.7;
}

/* Section number styling */
.section-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--navy);
    color: var(--white);
    border-radius: 50%;
    font-size: 0.875rem;
    font-weight: 600;
    margin-right: 0.75rem;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-row .form-group.half {
        flex: 1;
        min-width: 100%;
    }

    .checkbox-grid,
    .checkbox-grid-2 {
        grid-template-columns: 1fr;
    }

    .input-with-button {
        flex-direction: column;
    }

    .input-with-button button {
        width: 100%;
    }
}

/* ==================== ERROR FIELD HIGHLIGHTING ==================== */
/* Used by registration-wizard.js when validation fails on step navigation */
input.field-error,
select.field-error,
textarea.field-error,
.form-group .field-error {
    border-color: var(--error, #ef4444);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* Used by candidate.php and employer.php inline JS for server-side error highlighting */
input.error-field,
select.error-field,
textarea.error-field,
.form-group .error-field {
    border-color: var(--error, #ef4444);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* Enhanced error highlight with shake animation - used for scroll-to-error */
input.error-highlight,
select.error-highlight,
textarea.error-highlight,
.form-group .error-highlight {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.25);
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Error highlight for consent items and non-input elements */
.form-group .error-highlight-section,
.checkbox-group.error-highlight-section,
div.error-highlight-section {
    border: 2px solid #dc3545;
    border-radius: 8px;
    padding: 8px;
    background: rgba(220, 53, 69, 0.05);
    animation: shake 0.5s ease-in-out;
}

/* AYIO-CHECKBOX-FIX 2026-05-05: override .form-group input{width:100%} for checkboxes+radios */
.form-group input[type="checkbox"],.form-group input[type="radio"]{width:auto!important;flex-shrink:0;margin:0}
.form-group label input[type="checkbox"],.form-group label input[type="radio"]{width:auto!important;flex-shrink:0}
