/* Search CSS for Data-Driven Time-Series Prediction LaTeX Book */

/* 1. Sidebar Search Trigger */
.search-sidebar-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #ffffff;
    border: 1px solid #dcdad5;
    border-radius: 6px;
    padding: 0.5em 0.8em;
    margin: 1ex 0.8em 2ex 0.8em;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8em;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-sidebar-container:hover {
    border-color: #b0aea9;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.search-sidebar-icon {
    font-size: 1.1em;
    color: #8c8a85;
}

.search-sidebar-placeholder {
    flex-grow: 1;
    margin-left: 0.6em;
    color: #8c8a85;
    text-align: left;
}

.search-sidebar-kbd {
    background: #f4f3ef;
    border: 1px solid #d2cfc9;
    border-radius: 3px;
    box-shadow: 0 1px 0 rgba(0,0,0,0.1);
    color: #7a7873;
    display: inline-block;
    font-family: monospace;
    font-size: 0.85em;
    font-weight: bold;
    padding: 1px 4px;
    line-height: 1;
}

/* 2. Homepage Index Search Trigger */
.search-index-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 8px;
    padding: 0.8em 1.2em;
    margin: 2em auto;
    max-width: 450px;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-index-container:hover {
    border-color: #999999;
    box-shadow: 0 3px 6px rgba(0,0,0,0.08);
}

.search-index-icon {
    font-size: 1.2em;
    color: #777777;
}

.search-index-placeholder {
    flex-grow: 1;
    margin-left: 1em;
    color: #777777;
    font-size: 1em;
    text-align: left;
}

.search-index-kbd {
    background: #f5f5f5;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 1px 0 rgba(0,0,0,0.1);
    color: #666;
    display: inline-block;
    font-family: monospace;
    font-size: 0.9em;
    font-weight: bold;
    padding: 2px 6px;
}

/* 3. Top Navigation Bar Search Trigger (Mobile View) */
.search-nav-trigger {
    display: inline-block;
    margin-left: 1.5em;
    padding: 2px 8px;
    background-color: #f0ede9;
    border: 1px solid #d4cfc9;
    border-radius: 4px;
    font-size: 0.8em;
    color: #504f4b;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}

.search-nav-trigger:hover {
    background-color: #e5e0da;
}

/* 4. Search Modal Backdrop */
.search-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 12vh;
    box-sizing: border-box;
}

/* 5. Search Modal Content Box */
.search-modal-content {
    background-color: #ffffff;
    width: 90%;
    max-width: 680px;
    max-height: 75vh;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: search-fade-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes search-fade-in {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Header */
.search-modal-header {
    display: flex;
    align-items: center;
    padding: 1.1em 1.3em;
    border-bottom: 1px solid #edf2f7;
    gap: 0.8em;
}

.search-modal-icon {
    font-size: 1.3em;
    color: #718096;
}

#modal-search-input {
    flex-grow: 1;
    border: none;
    outline: none;
    font-size: 1.1em;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1a202c;
    background: transparent;
}

#modal-search-close {
    border: none;
    background: none;
    font-size: 1.8em;
    color: #a0aec0;
    cursor: pointer;
    padding: 0;
    line-height: 0.8;
}

#modal-search-close:hover {
    color: #4a5568;
}

/* Results Area */
.search-modal-results {
    overflow-y: auto;
    flex-grow: 1;
    padding: 1em 1.2em;
    background-color: #fcfcfb;
    box-sizing: border-box;
}

/* Single Result Item */
.search-result-item {
    display: block;
    text-decoration: none !important;
    padding: 0.9em 1.1em;
    margin-bottom: 0.6em;
    border-radius: 8px;
    border: 1px solid #eaeaea;
    background-color: #ffffff;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
    box-sizing: border-box;
}

.search-result-item:hover, .search-result-item.selected {
    background-color: #f4f7f6;
    border-color: #d1dcd6;
}

.search-result-item.selected {
    outline: 2px solid #577f6b;
    outline-offset: -1px;
}

/* Metadata Badges */
.search-result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
    margin-bottom: 0.4em;
    font-family: system-ui, -apple-system, sans-serif;
}

.search-badge {
    font-size: 0.7em;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.search-badge-part {
    background-color: #ebf8ff;
    color: #2b6cb0;
}

.search-badge-chapter {
    background-color: #fefcbf;
    color: #975a16;
}

.search-badge-section {
    background-color: #f0fff4;
    color: #276749;
}

/* Result Titles & Snippets */
.search-result-title {
    font-family: inherit;
    font-size: 1.05em;
    font-weight: bold;
    color: #1a202c;
    margin-bottom: 0.3em;
}

.search-result-snippet {
    font-size: 0.85em;
    color: #4a5568;
    line-height: 1.45;
    word-break: break-word;
}

/* Text Highlighting */
.search-result-snippet mark {
    background-color: #fef08a;
    color: #854d0e;
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 600;
}

/* State Placeholders */
.search-no-query, .search-no-results {
    text-align: center;
    padding: 3em 1em;
    color: #718096;
    font-size: 0.95em;
    font-family: system-ui, -apple-system, sans-serif;
}

/* Footer Instructions */
.search-modal-footer {
    padding: 0.7em 1.3em;
    background-color: #f7fafc;
    border-top: 1px solid #edf2f7;
    display: flex;
    justify-content: flex-end;
}

.search-modal-hint {
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 0.72em;
    color: #718096;
}

.search-modal-hint kbd {
    background: #edf2f7;
    border: 1px solid #cbd5e0;
    border-radius: 3px;
    padding: 1px 4px;
    margin: 0 2px;
    font-family: monospace;
    font-size: 0.9em;
    color: #4a5568;
}

/* Mobile Responsiveness styling overrides */
@media (max-width: 600px) {
    .search-modal {
        padding-top: 5vh;
    }
    .search-modal-content {
        max-height: 90vh;
    }
    .search-sidebar-container {
        display: none !important; /* Sidebar is hidden anyway, hide trigger as well */
    }
}
