/* ============================================
   SEARCH MODAL STYLES
   Goodwill Central Texas - Cmd+K Search
   ============================================ */

/* CSS Custom Properties */
:root {
    --gwctx-primary: #0351a3;
    --gwctx-primary-dark: #021058;
    --gwctx-primary-light: #EEF6FE;
    --gwctx-gold: #ffbf00;
    --gwctx-border: #E5E7EB;
    --gwctx-border-light: #F3F4F6;
    --gwctx-text: #231F20;
    --gwctx-text-muted: #6B7280;
    --gwctx-text-light: #9CA3AF;
    --gwctx-bg: #FFFFFF;
    --gwctx-bg-hover: #F9FAFB;
    --gwctx-font: 'Gantari', sans-serif;
    --gwctx-radius-sm: 6px;
    --gwctx-radius-md: 10px;
    --gwctx-radius-lg: 16px;
    --gwctx-radius-pill: 50px;
    --gwctx-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --gwctx-transition: 0.2s ease;
}

/* ---- Backdrop ---- */
.gwctx-search-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.gwctx-search-modal[hidden] {
    display: none;
}

.gwctx-search-modal.is-open {
    opacity: 1;
    visibility: visible;
}

.gwctx-search-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 16, 88, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    cursor: pointer;
}

/* ---- Container ---- */
.gwctx-search-modal__container {
    position: relative;
    width: 100%;
    max-width: 640px;
    max-height: 70vh;
    background: var(--gwctx-bg);
    border-radius: var(--gwctx-radius-lg);
    box-shadow: var(--gwctx-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(-10px) scale(0.98);
    transition: transform 0.2s ease;
    z-index: 1;
}

.gwctx-search-modal.is-open .gwctx-search-modal__container {
    transform: translateY(0) scale(1);
}

/* ---- Header / Input ---- */
.gwctx-search-modal__header {
    padding: 0;
    border-bottom: 1px solid var(--gwctx-border);
}

.gwctx-search-modal__input-wrap {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    gap: 12px;
}

.gwctx-search-modal__search-icon {
    font-size: 18px;
    color: var(--gwctx-primary);
    flex-shrink: 0;
}

.gwctx-search-modal__input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 20px;
    font-family: var(--gwctx-font);
    font-weight: 400;
    color: var(--gwctx-text);
    background: transparent;
    padding: 0;
    line-height: 1.5;
}

.gwctx-search-modal__input::placeholder {
    color: var(--gwctx-text-light);
}

.gwctx-search-modal__input::-webkit-search-cancel-button {
    display: none;
}

.gwctx-search-modal__kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border: 1px solid var(--gwctx-border);
    border-radius: 4px;
    background: var(--gwctx-bg-hover);
    color: var(--gwctx-text-muted);
    font-size: 11px;
    font-family: var(--gwctx-font);
    font-weight: 500;
    line-height: 1;
    flex-shrink: 0;
}

/* ---- Filter Pills ---- */
.gwctx-search-modal__filters {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--gwctx-border-light);
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.gwctx-search-modal__filters::-webkit-scrollbar {
    display: none;
}

.gwctx-search-modal__filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border: 1px solid var(--gwctx-border);
    border-radius: var(--gwctx-radius-pill);
    background: var(--gwctx-bg);
    color: var(--gwctx-text-muted);
    font-size: 14px;
    font-family: var(--gwctx-font);
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--gwctx-transition);
    line-height: 1.4;
}

.gwctx-search-modal__filter-pill:hover {
    border-color: var(--gwctx-primary);
    color: var(--gwctx-primary);
    background: var(--gwctx-primary-light);
}

.gwctx-search-modal__filter-pill.is-active {
    background: var(--gwctx-primary);
    border-color: var(--gwctx-primary);
    color: #FFFFFF;
}

.gwctx-search-modal__filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.2);
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

.gwctx-search-modal__filter-pill:not(.is-active) .gwctx-search-modal__filter-count {
    background: var(--gwctx-border-light);
    color: var(--gwctx-text-muted);
}

/* ---- Body ---- */
.gwctx-search-modal__body {
    flex: 1;
    overflow-y: auto;
    min-height: 100px;
    max-height: calc(70vh - 180px);
    scrollbar-width: thin;
    scrollbar-color: var(--gwctx-border) transparent;
}

.gwctx-search-modal__body::-webkit-scrollbar {
    width: 6px;
}

.gwctx-search-modal__body::-webkit-scrollbar-thumb {
    background: var(--gwctx-border);
    border-radius: 3px;
}

/* ---- Initial State ---- */
.gwctx-search-modal__section-title {
    font-size: 11px;
    font-family: var(--gwctx-font);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gwctx-text-light);
    padding: 12px 20px 6px;
    margin: 0;
}

.gwctx-search-modal__recent-list,
.gwctx-search-modal__quick-list {
    list-style: none;
    margin: 0;
    padding: 0 8px 8px;
}

.gwctx-search-modal__recent-list li,
.gwctx-search-modal__quick-list li {
    margin: 0;
}

.gwctx-search-modal__recent-list a,
.gwctx-search-modal__quick-list a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--gwctx-radius-sm);
    color: var(--gwctx-text);
    text-decoration: none;
    font-size: 16px;
    font-family: var(--gwctx-font);
    transition: background var(--gwctx-transition);
}

.gwctx-search-modal__recent-list a:hover,
.gwctx-search-modal__quick-list a:hover {
    background: var(--gwctx-primary-light);
    color: var(--gwctx-primary);
}

.gwctx-search-modal__recent-list i,
.gwctx-search-modal__quick-list i {
    width: 20px;
    text-align: center;
    color: var(--gwctx-text-muted);
    font-size: 14px;
    flex-shrink: 0;
}

.gwctx-search-modal__recent-list a:hover i,
.gwctx-search-modal__quick-list a:hover i {
    color: var(--gwctx-primary);
}

.gwctx-search-modal__recent-item-remove {
    margin-left: auto;
    padding: 4px 8px;
    border: none;
    background: none;
    color: var(--gwctx-text-light);
    cursor: pointer;
    font-size: 12px;
    border-radius: 4px;
    transition: all var(--gwctx-transition);
    opacity: 0;
}

.gwctx-search-modal__recent-list li:hover .gwctx-search-modal__recent-item-remove {
    opacity: 1;
}

.gwctx-search-modal__recent-item-remove:hover {
    color: #EF4444;
    background: #FEF2F2;
}

/* ---- Loading State ---- */
.gwctx-search-modal__loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 12px;
    color: var(--gwctx-text-muted);
    font-size: 14px;
    font-family: var(--gwctx-font);
}

.gwctx-search-modal__loading p {
    margin: 0;
}

.gwctx-search-modal__spinner-ring {
    width: 28px;
    height: 28px;
    border: 3px solid var(--gwctx-border);
    border-top-color: var(--gwctx-primary);
    border-radius: 50%;
    animation: gwctx-spin 0.7s linear infinite;
}

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

/* ---- Results ---- */
.gwctx-search-modal__result-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 12px 20px;
    cursor: pointer;
    transition: background var(--gwctx-transition);
    border-bottom: 1px solid var(--gwctx-border-light);
    text-decoration: none;
    color: inherit;
    outline: none;
}

.gwctx-search-modal__result-item:last-child {
    border-bottom: none;
}

.gwctx-search-modal__result-item:hover,
.gwctx-search-modal__result-item.is-active {
    background: var(--gwctx-primary-light);
}

.gwctx-search-modal__result-item:focus-visible {
    background: var(--gwctx-primary-light);
    outline: 2px solid var(--gwctx-primary);
    outline-offset: -2px;
}

.gwctx-search-modal__result-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--gwctx-radius-sm);
    background: var(--gwctx-primary-light);
    color: var(--gwctx-primary);
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 2px;
}

.gwctx-search-modal__result-item.is-active .gwctx-search-modal__result-icon,
.gwctx-search-modal__result-item:hover .gwctx-search-modal__result-icon {
    background: var(--gwctx-primary);
    color: #FFFFFF;
}

.gwctx-search-modal__result-content {
    flex: 1;
    min-width: 0;
}

.gwctx-search-modal__result-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.gwctx-search-modal__result-type {
    font-size: 12px;
    font-weight: 600;
    font-family: var(--gwctx-font);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--gwctx-primary);
    line-height: 1;
}

.gwctx-search-modal__result-date {
    font-size: 13px;
    color: var(--gwctx-text-light);
    font-family: var(--gwctx-font);
    line-height: 1;
}

.gwctx-search-modal__result-title {
    font-size: 18px;
    font-weight: 600;
    font-family: var(--gwctx-font);
    color: var(--gwctx-text);
    margin: 0 0 4px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gwctx-search-modal__result-excerpt {
    font-size: 15px;
    font-family: var(--gwctx-font);
    color: var(--gwctx-text-muted);
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gwctx-search-modal__result-thumbnail {
    width: 48px;
    height: 48px;
    border-radius: var(--gwctx-radius-sm);
    object-fit: cover;
    flex-shrink: 0;
    margin-top: 2px;
}

/* ---- Empty State ---- */
.gwctx-search-modal__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 10px;
    color: var(--gwctx-text-muted);
    font-family: var(--gwctx-font);
    text-align: center;
}

.gwctx-search-modal__empty i {
    font-size: 28px;
    color: var(--gwctx-text-light);
}

.gwctx-search-modal__empty p {
    margin: 0;
    font-size: 14px;
}

/* ---- Footer ---- */
.gwctx-search-modal__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    border-top: 1px solid var(--gwctx-border-light);
    background: var(--gwctx-bg-hover);
    border-radius: 0 0 var(--gwctx-radius-lg) var(--gwctx-radius-lg);
}

.gwctx-search-modal__footer-hints {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 12px;
    font-family: var(--gwctx-font);
    color: var(--gwctx-text-muted);
}

.gwctx-search-modal__footer-hints kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border: 1px solid var(--gwctx-border);
    border-radius: 4px;
    background: var(--gwctx-bg);
    font-size: 11px;
    font-family: var(--gwctx-font);
    font-weight: 500;
    color: var(--gwctx-text-muted);
    margin-right: 2px;
    box-shadow: 0 1px 0 var(--gwctx-border);
}

.gwctx-search-modal__view-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-family: var(--gwctx-font);
    font-weight: 600;
    color: var(--gwctx-primary);
    text-decoration: none;
    transition: color var(--gwctx-transition);
}

.gwctx-search-modal__view-all:hover {
    color: var(--gwctx-primary-dark);
}

/* ---- Header Search Trigger Button ---- */
.gwctx-search-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--gwctx-border);
    border-radius: 50%;
    background: transparent;
    color: #231F20;
    font-size: 15px;
    cursor: pointer;
    transition: all var(--gwctx-transition);
    margin-left: 12px;
}

.gwctx-search-trigger:hover {
    background: var(--gwctx-primary);
    border-color: var(--gwctx-primary);
    color: #FFFFFF;
}

/* Mobile search trigger in hamburger menu */
.gwctx-search-trigger--mobile {
    display: none;
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--gwctx-border);
    border-radius: var(--gwctx-radius-md);
    background: var(--gwctx-bg-hover);
    color: var(--gwctx-text);
    font-size: 15px;
    font-family: var(--gwctx-font);
    cursor: pointer;
    gap: 10px;
    align-items: center;
    margin: 10px 0;
    transition: all var(--gwctx-transition);
}

.gwctx-search-trigger--mobile:hover {
    border-color: var(--gwctx-primary);
    color: var(--gwctx-primary);
}

.gwctx-search-trigger--mobile i {
    color: var(--gwctx-text-muted);
}

.gwctx-search-trigger--mobile span {
    flex: 1;
    text-align: left;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .gwctx-search-modal {
        padding-top: 0;
        align-items: flex-start;
    }

    .gwctx-search-modal__container {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        height: 100%;
    }

    .gwctx-search-modal__body {
        max-height: calc(100vh - 180px);
    }

    .gwctx-search-modal__footer {
        border-radius: 0;
    }

    .gwctx-search-modal__footer-hints {
        display: none;
    }

    .gwctx-search-trigger__shortcut {
        display: none !important;
    }

    .gwctx-search-trigger--mobile {
        display: flex;
    }
}

@media (max-width: 480px) {
    .gwctx-search-modal__input {
        font-size: 16px; /* Prevent iOS zoom */
    }

    .gwctx-search-modal__filters {
        padding: 8px 16px;
    }

    .gwctx-search-modal__result-item {
        padding: 10px 16px;
    }
}

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
    .gwctx-search-modal,
    .gwctx-search-modal__container,
    .gwctx-search-modal__filter-pill,
    .gwctx-search-modal__result-item {
        transition: none;
    }

    .gwctx-search-modal__spinner-ring {
        animation-duration: 1.5s;
    }
}

/* ---- Body scroll lock when modal is open ---- */
body.gwctx-search-open {
    overflow: hidden;
}
