/**
 * NEF Unified Search - Complete Styling
 * Handles search bar, expanded results box, browse mode, and calendar integration
 * 
 * Color Palette:
 * Primary (Sage Green): #77827C
 * Secondary (Beige): #EAE3D6
 * Accent (Gold): #D5B22A
 * Text: #4F4F4F
 * White: #FFFFFF
 * Light Gray: #F7F6F5
 * Mid Gray: #9D9D95
 * Dark Gray: #272727
 */

/* ==========================================================================
   SEARCH BAR (Collapsed State)
   ========================================================================== */

.nef-unified-search-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    z-index: 1000;
}

.nef-unified-search-bar {
    position: relative;
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.nef-unified-search-bar:hover {
    border-color: #77827C;
    box-shadow: 0 4px 12px rgba(119, 130, 124, 0.1);
}

.nef-unified-search-bar.is-focused {
    border-color: #77827C;
    box-shadow: 0 0 0 3px rgba(119, 130, 124, 0.1);
}

form.nef-unified-search-form {
    display: flex;
    gap: 0;
    align-items: stretch;
}

input.nef-unified-search-input {
    font-size: 16px;
    font-style: normal;
    font-weight: 400;
    line-height: 24px;
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px 0px 0px 8px;
    box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.05);
    color: var(--ast-form-input-text, #475569);
    border-width: 1px;
    border-style: solid;
    border-color: var(--ast-border-color);
    background: #ffffff;
    outline: none;
    height: 48px;
}

.nef-unified-search-input::placeholder {
    color: #9ca3af;
}

.nef-unified-search-button {
    padding: 12px 32px;
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #ffffff;
    background: #4a90e2;
    border: none;
    border-radius: 0px 8px 8px 0px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.nef-search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
}

.nef-search-icon svg {
    width: 20px;
    height: 20px;
}

.nef-search-clear {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: #f3f4f6;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6b7280;
}

.nef-search-clear:hover {
    background: #e5e7eb;
    color: #374151;
}

/* ==========================================================================
   EXPANDED RESULTS BOX
   ========================================================================== */

.nef-unified-search-results {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    transition: all 0.3s ease;
    z-index: 999;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    min-width: 100%;
    max-width: 1200px;
    max-height: 0;
    opacity: 0;
}

.nef-unified-search-results.is-open {
    max-height: 80vh;
    opacity: 1;
    overflow-y: auto;
}

.nef-unified-search-results-inner {
    padding: 24px;
}

/* Custom Scrollbar */
.nef-unified-search-results::-webkit-scrollbar {
    width: 8px;
}

.nef-unified-search-results::-webkit-scrollbar-track {
    background: #f9fafb;
    border-radius: 10px;
}

.nef-unified-search-results::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

.nef-unified-search-results::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Mobile Close Button */
.nef-mobile-close {
    display: none;
    position: sticky;
    top: 0;
    right: 0;
    margin-left: auto;
    margin-bottom: 16px;
    background: #f3f4f6;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
}

.nef-close-icon {
    font-size: 24px;
    line-height: 1;
    color: #6b7280;
}

/* ==========================================================================
   BROWSE MODE (4 Columns)
   ========================================================================== */

.nef-browse-mode {
    display: block;
}

.nef-browse-columns {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}

.nef-browse-column {
    background: #f9fafb;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s ease;
}

.nef-browse-column:hover {
    background: #f3f4f6;
    transform: translateY(-2px);
}

.nef-browse-column-title {
    margin: 0 0 16px;
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #1f2937;
    padding-bottom: 12px;
    border-bottom: 2px solid #e5e7eb;
}

/* By Modality List */
.nef-browse-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nef-browse-list li {
    margin-bottom: 0px;
}

.nef-browse-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: #4b5563;
    font-size: 14px;
    transition: all 0.2s ease;
}

.nef-browse-link:hover {
    background: #ffffff;
    color: #D5B22A;
    transform: translateX(4px);
}

.nef-browse-count {
    font-size: 12px;
    color: #9ca3af;
    font-weight: 500;
}

/* By Date Column */
.nef-browse-date-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 22px 20px;
    background: linear-gradient(135deg, #77827C 0%, #6a746e 100%);
    border: none;
    border-radius: 10px;
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(119, 130, 124, 0.2);
}

.nef-browse-date-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(119, 130, 124, 0.3);
}

.nef-date-icon {
    display: flex;
    align-items: center;
    font-size: 18px;
}

.nef-date-icon .emoji {
    width: 18px;
    height: 18px;
}

/* Find Facilitator Column */
.nef-browse-facilitator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: normal;
    text-align: center;
}

.nef-browse-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    background: linear-gradient(135deg, #D5B22A 0%, #c2a024 100%);
    color: #ffffff !important;
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(213, 178, 42, 0.2);
}

.nef-browse-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(213, 178, 42, 0.3);
    background: linear-gradient(135deg, #c2a024 0%, #b09020 100%);
}

/* ==========================================================================
   FLATPICKR CALENDAR POSITIONING
   ========================================================================== */

.flatpickr-calendar {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    margin-top: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
    border-radius: 12px !important;
    border: 1px solid #e5e7eb !important;
}

.flatpickr-calendar.open {
    display: block;
    z-index: 1;
}

.flatpickr-months {
    border-radius: 12px 12px 0 0;
    background: linear-gradient(135deg, #77827C 0%, #6a746e 100%);
}

.flatpickr-months .flatpickr-month {
    background: transparent;
    color: rgba(0, 0, 0, 0.9);
    fill: rgba(0, 0, 0, 0.9);
    height: 48px;
    line-height: 1;
    text-align: center;
    position: relative;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    overflow: hidden;
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    -ms-flex: 1;
    flex: 1;
}

.flatpickr-current-month {
    color: #ffffff !important;
}

.flatpickr-monthDropdown-months,
.numInput.cur-year {
    color: #ffffff !important;
    font-weight: 600;
}

.flatpickr-prev-month svg,
.flatpickr-next-month svg {
    fill: #ffffff !important;
}

.flatpickr-day.today {
    border-color: #77827C !important;
    background: rgba(119, 130, 124, 0.1) !important;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: #77827C !important;
    border-color: #77827C !important;
}

.flatpickr-day:hover {
    background: #f3f4f6;
    border-color: #77827C;
}

/* ==========================================================================
   SEARCH MODE (2 Columns - Events & Facilitators)
   ========================================================================== */

.nef-search-mode {
    display: none;
}

.nef-search-mode.is-active {
    display: block;
}

.nef-unified-search-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.nef-search-category {
    min-height: 200px;
}

.nef-search-category-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e5e7eb;
}

.nef-search-category-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.nef-search-results-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nef-search-results-list li {
    margin-bottom: 12px;
}

.nef-search-result-link {
    display: block;
    padding: 14px 16px;
    background: #f9fafb;
    border-radius: 10px;
    text-decoration: none;
    color: #1f2937;
    transition: all 0.2s ease;
}

.nef-search-result-link:hover {
    background: #f3f4f6;
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.nef-search-result-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: #1f2937;
}

.nef-search-result-meta {
    font-size: 13px;
    color: #6b7280;
}

.nef-search-view-all {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
    text-align: center;
}

.nef-search-view-all-link {
    display: inline-block;
    padding: 10px 20px;
    background: #D5B22A;
    color: #ffffff;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
}

.nef-search-view-all-link:hover {
    background: #c2a024;
    transform: translateY(-2px);
}

/* No Results State */
.nef-search-no-results {
    text-align: center;
    padding: 60px 20px;
}

.nef-search-no-results-title {
    margin: 0 0 12px;
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
}

.nef-search-no-results-message {
    margin: 0;
    font-size: 15px;
    color: #6b7280;
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

/* Tablet (≤1024px) */
@media (max-width: 1024px) {
    .nef-browse-columns {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .nef-unified-search-columns {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}

/* Mobile (≤768px) */
@media (max-width: 768px) {
    .nef-unified-search-results.is-open {
        position: fixed;
        top: 0;
        left: 50%;
        right: 0%;
        bottom: 0;
        max-height: 90vh;
        border-radius: 0;
        background-color: rgba(0, 0, 0, 0.77);
        padding: 30px;
        /*position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        max-height: 100vh;
        border-radius: 0;*/
    }
    
    .nef-unified-search-results-inner {
        padding: 16px;
    }
    
    .nef-mobile-close {
        display: flex;
    }
    
    .nef-browse-columns {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .nef-browse-column {
        padding: 16px;
    }
    
    .nef-unified-search-input {
        padding: 14px 50px 14px 45px;
        font-size: 16px;
    }
    
    .nef-browse-date-trigger,
    .nef-browse-cta {
        font-size: 14px;
        padding: 12px 18px;
    }
    
    /* Stack calendar properly on mobile */
    .flatpickr-calendar {
        width: 100% !important;
        max-width: 320px;
        margin-left: auto;
        margin-right: auto;
    }
}

/* Small Mobile (≤480px) */
@media (max-width: 480px) {
    .nef-unified-search-input {
        padding: 12px 45px 12px 40px;
        font-size: 15px;
    }
    
    .nef-search-icon {
        left: 14px;
    }
    
    .nef-search-icon svg {
        width: 18px;
        height: 18px;
    }
    
    .nef-search-clear {
        right: 12px;
        width: 26px;
        height: 26px;
    }
    
    .nef-browse-link {
        font-size: 13px;
        padding: 6px 10px;
    }
    
    .nef-browse-count {
        font-size: 11px;
    }
}

/* ==========================================================================
   LOADING STATES
   ========================================================================== */

.nef-search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.nef-search-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: #77827C;
    border-radius: 50%;
    animation: nef-spin 0.8s linear infinite;
}

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

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */

.nef-unified-search-input:focus {
    outline: none;
}

.nef-browse-link:focus,
.nef-search-result-link:focus,
.nef-browse-date-trigger:focus,
.nef-browse-cta:focus {
    outline: 2px solid #77827C;
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .nef-unified-search-bar {
        border-width: 3px;
    }
    
    .nef-browse-column {
        border: 1px solid #9ca3af;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .nef-unified-search-results,
    .nef-browse-link,
    .nef-search-result-link,
    .nef-browse-date-trigger,
    .nef-browse-cta {
        transition: none;
    }
    
    .nef-search-loading-spinner {
        animation: none;
    }
}

/* ==========================================================================
   DARK MODE SUPPORT (Optional)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .nef-unified-search-bar {
        background: #1f2937;
        border-color: #374151;
    }
    
    .nef-unified-search-input {
        color: #f9fafb;
    }
    
    .nef-unified-search-input::placeholder {
        color: #6b7280;
    }
    
    .nef-unified-search-results {
        background: #111827;
    }
    
    .nef-browse-column {
        background: #1f2937;
    }
    
    .nef-browse-column:hover {
        background: #374151;
    }
    
    .nef-browse-column-title {
        color: #f9fafb;
        border-bottom-color: #374151;
    }
    
    .nef-browse-link {
        color: #d1d5db;
    }
    
    .nef-browse-link:hover {
        background: #374151;
        color: #D5B22A;
    }
    
    .nef-search-result-link {
        background: #1f2937;
        color: #f9fafb;
    }
    
    .nef-search-result-link:hover {
        background: #374151;
    }
}
