/**
 * Gravity Forms Auto-Suggest Styles
 * WCAG 2.2 Compliant Styling
 */

/* Focus styles for accessibility - using main website green color */
.gform_wrapper input:not([type=submit]):focus, .gform_wrapper select:focus, .gform_wrapper textarea:focus,
.gf-auto-suggest-input:focus {
    outline-style: dotted !important;
    outline-width: 2px !important;
    outline-color: #227a00 !important;
    outline-offset: 2px !important;
}


/* Screen reader only content */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Auto-suggest container */
.gf-auto-suggest-container {
    position: relative;
    display: inline-block;
    width: 100%;
}

/* Enhanced input field */
.gf-auto-suggest-input {
    position: relative;
    z-index: 1;
    background-color: #ffffff;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 16px;
    line-height: 1.5;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.2s ease-in-out;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.gf-auto-suggest-input:focus {
    outline-style: dotted !important;
    outline-width: 2px !important;
    outline-color: #227a00 !important;
    outline-offset: 2px !important;
    border-color: #227a00;
    box-shadow: 0 0 0 3px rgba(34, 122, 0, 0.15);
    background-color: #fefefe;
}

.gf-auto-suggest-input:hover:not(:focus) {
    border-color: #d1d5db;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .gf-auto-suggest-input {
        border-width: 3px;
        border-color: #000000;
    }
    
    .gf-auto-suggest-input:focus {
        border-color: #227a00;
        outline-color: #227a00 !important;
        outline-width: 3px !important;
        box-shadow: 0 0 0 4px rgba(34, 122, 0, 0.3);
    }
    
    .gf-auto-suggest-dropdown {
        border-color: #000000;
        border-width: 4px;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.8);
    }
    
    .gf-auto-suggest-option {
        border-bottom-color: #000000;
    }
    
    .gf-auto-suggest-option:hover,
    .gf-auto-suggest-option.selected {
        background: #227a00;
        color: #ffffff;
    }
    
    .gf-auto-suggest-option:focus {
        outline-color: #227a00 !important;
        outline-width: 3px !important;
    }
}

/* Enhanced dropdown container */
.gf-auto-suggest-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #f8fafc;
    border: 3px solid #d1d5db;
    border-top: 2px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.15), 
                0 10px 15px -5px rgba(0, 0, 0, 0.1),
                0 0 0 1px rgba(0, 0, 0, 0.05);
    max-height: 280px;
    overflow-y: auto;
    display: none;
    margin-top: 4px;
    opacity: 0;
    transform: translateY(-8px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    padding: 8px 0;
}

.gf-auto-suggest-dropdown[style*="block"] {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Custom scrollbar for modern browsers */
.gf-auto-suggest-dropdown::-webkit-scrollbar {
    width: 6px;
}

.gf-auto-suggest-dropdown::-webkit-scrollbar-track {
    background: #f8fafc;
}

.gf-auto-suggest-dropdown::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.gf-auto-suggest-dropdown::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Enhanced dropdown options */
.gf-auto-suggest-option {
    padding: 18px 20px;
    cursor: pointer;
    border-bottom: 1px solid #e5e7eb;
    color: #374151;
    font-size: 15px;
    line-height: 1.6;
    transition: all 0.15s ease-in-out;
    display: block;
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    animation: slideInUp 0.15s ease-out backwards;
    margin: 2px 4px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    background: #ffffff;
    border: 1px solid #f1f5f9;
}

.gf-auto-suggest-option:nth-child(1) { animation-delay: 0.02s; }
.gf-auto-suggest-option:nth-child(2) { animation-delay: 0.04s; }
.gf-auto-suggest-option:nth-child(3) { animation-delay: 0.06s; }
.gf-auto-suggest-option:nth-child(4) { animation-delay: 0.08s; }
.gf-auto-suggest-option:nth-child(5) { animation-delay: 0.10s; }

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gf-auto-suggest-option:last-child {
    border-bottom: none;
    border-radius: 0 0 6px 6px;
    margin-bottom: 4px;
}

.gf-auto-suggest-option:first-child {
    border-radius: 0;
    margin-top: 4px;
}

.gf-auto-suggest-option:hover,
.gf-auto-suggest-option.selected {
    background: linear-gradient(135deg, #227a00 0%, #2d9600 100%);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 122, 0, 0.25);
    border-color: #227a00;
}

.gf-auto-suggest-option:focus {
    outline-style: dotted !important;
    outline-width: 2px !important;
    outline-color: #227a00 !important;
    outline-offset: 2px !important;
    z-index: 1;
}

/* Additional focus styles for dropdown options when navigated via keyboard */
.gf-auto-suggest-option.selected {
    background: linear-gradient(135deg, #227a00 0%, #2d9600 100%);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 122, 0, 0.25);
    border-color: #227a00;
}

/* Remove school icon */
/* .gf-auto-suggest-option::before removed - no more icons */

/* Enhanced highlighted text within options */
.gf-auto-suggest-option mark {
    background-color: #cbfec7;
    padding: 3px 0px;
    font-weight: 600;
    border-radius: 4px;
    box-decoration-break: clone;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    margin: 0 1px;
    display: inline-block;
}
/* Enhanced highlighted text within options */
.gf-auto-suggest-option:hover {
    cursor: pointer;
}

.gf-auto-suggest-option.selected mark,
.gf-auto-suggest-option:hover mark {
    background-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Enhanced no results message */
.gf-auto-suggest-no-results {
    padding: 24px 20px;
    color: #6b7280;
    font-style: italic;
    border-bottom: none;
    cursor: default;
    text-align: center;
    background: #f9fafb;
    border-radius: 6px;
    margin: 8px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    line-height: 1.6;
}

.gf-auto-suggest-no-results::before {
    content: '🔍';
    display: block;
    font-size: 28px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Status message for screen readers */
.gf-auto-suggest-status {
    /* This is intentionally hidden but accessible to screen readers */
    position: absolute;
    left: -9999px;
}

/* Enhanced responsive design */
@media (max-width: 768px) {
    .gf-auto-suggest-input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 14px 16px;
    }
    
    .gf-auto-suggest-dropdown {
        max-height: 240px;
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    }
    
    .gf-auto-suggest-option {
        padding: 20px;
        font-size: 16px;
        min-height: 56px; /* Touch target size */
        display: block;
        margin: 3px 6px;
        line-height: 1.5;
    }
    
    /* Remove icon spacing on mobile since we removed icons */
    
    /* Larger touch targets */
    .gf-auto-suggest-option:hover,
    .gf-auto-suggest-option.selected {
        transform: translateY(-1px); /* Keep subtle transform on mobile */
    }
}

/* Focus management for keyboard users */
.gf-auto-suggest-container:focus-within .gf-auto-suggest-dropdown {
    /* Ensure dropdown is visible when container has focus */
    z-index: 10000;
}

/* Loading state (if needed in future) */
.gf-auto-suggest-loading {
    position: relative;
}

.gf-auto-suggest-loading::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}



/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .gf-auto-suggest-input,
    .gf-auto-suggest-option {
        transition: none;
    }
    
    .gf-auto-suggest-loading::after {
        animation: none;
    }
}

/* Print styles */
@media print {
    .gf-auto-suggest-dropdown {
        display: none !important;
    }
}
