/* ==========================================================================
   app/static/css/search.css
   Global Calculator Search Modal & Navbar Trigger Styles
   GammaCalculator Phase 3C
   ========================================================================== */

/* --- NAVBAR SEARCH TRIGGER --- */
/* Option B: Compact Search Pill (Desktop, Laptop, Tablet: ~76px x 32px) */
.nav-search-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 16px;
    padding: 0 10px;
    width: 76px;
    height: 32px;
    min-height: 32px;
    color: var(--text-header);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    line-height: 1;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    box-sizing: border-box;
    white-space: nowrap;
}

.nav-search-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.4);
}

.nav-search-btn:focus-visible {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

.nav-search-icon {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
    flex-shrink: 0;
}

.nav-search-text {
    opacity: 0.9;
    white-space: nowrap;
}

.nav-search-shortcut {
    display: none !important;
}

/* Option C: Icon-only Search Button (Mobile: min 44px x 44px touch target) */
@media (max-width: 600px) {
    .nav-search-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        padding: 0;
        border-radius: 50%;
        justify-content: center;
        gap: 0;
    }

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

    .nav-search-text,
    .nav-search-shortcut {
        display: none !important;
    }
}

/* Narrow mobile adjustment: keep items inline */
@media (max-width: 440px) {
    header .nav-container {
        padding: 0 8px;
    }

    header h1, header .nav-brand {
        font-size: 1.25rem;
    }

    header nav li {
        margin-left: 8px;
    }
}

@media (max-width: 350px) {
    header h1, header .nav-brand {
        font-size: 1.15rem;
    }

    header nav li {
        margin-left: 6px;
    }
}

/* --- SEARCH MODAL BACKDROP --- */
.search-modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--modal-overlay);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 64px 16px 20px;
    box-sizing: border-box;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

/* --- SEARCH DIALOG CONTAINER --- */
.search-modal-dialog {
    width: 100%;
    max-width: 620px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.32);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: calc(100vh - 100px);
    max-height: calc(100dvh - 100px);
    box-sizing: border-box;
    transition: border-color 0.15s ease;
}

.search-modal-dialog:focus-within {
    border-color: var(--link-color);
}

/* --- SEARCH HEADER / INPUT BAR --- */
.search-modal-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
    background: var(--bg-card);
    flex-shrink: 0;
}

.search-input-icon {
    width: 20px;
    height: 20px;
    stroke: var(--text-muted);
    fill: none;
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-main);
    font-size: 1.05rem;
    font-family: inherit;
    outline: none;
    min-width: 0;
}

.search-input::placeholder {
    color: var(--text-muted);
    opacity: 0.75;
}

.search-clear-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    transition: background-color 0.15s, color 0.15s;
}

.search-clear-btn:hover {
    background: var(--bg-body);
    color: var(--text-main);
}

.search-clear-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
}

.search-clear-btn:focus-visible,
.search-close-btn:focus-visible {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
    border-radius: 4px;
}

.search-close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-esc-badge {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    font-family: inherit;
    line-height: 1.4;
}

/* --- SEARCH BODY --- */
.search-modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 8px;
    min-height: 80px;
}

/* --- RESULTS LIST --- */
.search-results-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.search-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-main);
    cursor: pointer;
    margin-bottom: 2px;
    transition: background-color 0.12s ease, color 0.12s ease;
    border: 1px solid transparent;
}

.search-result-item:hover,
.search-result-item.is-selected {
    background: rgba(13, 110, 253, 0.1);
    border-color: rgba(13, 110, 253, 0.25);
    color: var(--link-color);
}

html.dark .search-result-item:hover,
html.dark .search-result-item.is-selected {
    background: rgba(96, 165, 250, 0.14);
    border-color: rgba(96, 165, 250, 0.3);
    color: var(--link-color);
}

.search-result-item-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
}

.search-result-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-match-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-badge {
    font-size: 0.72rem;
    font-weight: 500;
    background: var(--bg-body);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 12px;
}

/* --- STATE VIEWS: EMPTY & NO RESULTS --- */
.search-state-view {
    padding: 20px 14px;
    text-align: center;
}

.search-state-title {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-align: left;
    padding-left: 4px;
}

.search-suggestions-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.search-suggestion-pill {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.85rem;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.search-suggestion-pill:hover,
.search-suggestion-pill:focus-visible {
    background: rgba(13, 110, 253, 0.08);
    border-color: var(--link-color);
    color: var(--link-color);
    outline: none;
}

.search-no-results-icon {
    margin: 8px auto 12px;
    width: 40px;
    height: 40px;
    color: var(--text-muted);
}

.search-no-results-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
}

.search-no-results-text {
    font-size: 1rem;
    color: var(--text-main);
    margin-bottom: 6px;
}

.search-no-results-subtext {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.search-no-results-subtext a {
    color: var(--link-color);
    text-decoration: none;
}

.search-no-results-subtext a:hover {
    text-decoration: underline;
}

/* --- SEARCH MODAL FOOTER --- */
.search-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    padding: 10px 16px;
    background: var(--bg-body);
    border-top: 1px solid var(--border-color);
    font-size: 0.78rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-footer-hint {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.search-footer-hint kbd {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 0.72rem;
    font-family: inherit;
    font-weight: 600;
    color: var(--text-main);
}

/* --- ACCESSIBILITY --- */
.visually-hidden {
    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;
}

/* --- MOBILE MODAL ADJUSTMENTS --- */
@media (max-width: 600px) {
    .search-modal-backdrop {
        padding: 12px 8px;
        align-items: flex-start;
    }

    .search-modal-dialog {
        max-height: calc(100vh - 24px);
        max-height: calc(100dvh - 24px);
        border-radius: 10px;
    }

    .search-modal-footer {
        display: none;
    }

    .search-result-item {
        min-height: 48px;
        padding: 10px 12px;
    }

    .search-clear-btn {
        width: 44px;
        height: 44px;
    }

    .search-close-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .search-esc-badge {
        display: none;
    }

    .search-close-btn::after {
        content: '✕';
        font-size: 1.1rem;
        color: var(--text-muted);
        padding: 6px;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }
}

