/* Search Page Specific Styles */

/* ===========================================
   TIER 1: Search Term Highlighting
   =========================================== */
.search-highlight,
mark {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeb3b 100%);
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: inherit;
    color: inherit;
    box-shadow: 0 1px 3px rgba(255, 235, 59, 0.3);
}

/* Highlight in headword */
.headword-link mark {
    background: linear-gradient(135deg, #bbdefb 0%, #64b5f6 100%);
    border-radius: 4px;
}

/* Highlight in translations */
.def-text mark {
    background: linear-gradient(135deg, #c8e6c9 0%, #81c784 100%);
}

/* ===========================================
   TIER 1: Keyboard Navigation
   =========================================== */
.entry-row.keyboard-focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.15);
}

.entry-row.keyboard-selected {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%) !important;
    border-left-color: #1976d2 !important;
}

/* Skip link for accessibility */
.skip-to-results {
    position: absolute;
    left: -9999px;
    z-index: 999;
    padding: 0.5rem 1rem;
    background: #007bff;
    color: white;
    text-decoration: none;
    border-radius: 4px;
}

.skip-to-results:focus {
    left: 1rem;
    top: 1rem;
}

/* ===========================================
   TIER 1: Grouped Results Separators
   =========================================== */
.results-group {
    margin-bottom: 1.5rem;
}

.results-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e0e0e0;
}

.results-group-header .group-icon {
    font-size: 1.1rem;
}

.results-group-header .group-label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.results-group-header .group-count {
    background: #e9ecef;
    color: #6c757d;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Exact matches styling */
.results-group.exact-matches .entry-row {
    border-left: 4px solid #28a745 !important;
}

/* Inflected matches styling */
.results-group.inflected-matches .entry-row {
    border-left: 4px solid #17a2b8 !important;
}

/* Partial matches styling */
.results-group.partial-matches .entry-row {
    border-left: 4px solid #ffc107 !important;
}

/* ===========================================
   TIER 1: Search History Sidebar
   =========================================== */
.search-history-panel {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1050;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.search-history-panel.show {
    right: 0;
}

.search-history-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.search-history-panel .panel-header h5 {
    margin: 0;
    font-weight: 600;
    font-size: 1rem;
}

.search-history-panel .panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.search-history-panel .history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.search-history-panel .history-item:hover {
    background: #f8f9fa;
}

.search-history-panel .history-item .query-text {
    font-weight: 500;
    color: #007bff;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-history-panel .history-item .query-time {
    font-size: 0.75rem;
    color: #6c757d;
}

.search-history-panel .history-item .remove-btn {
    opacity: 0;
    padding: 2px 6px;
    font-size: 0.8rem;
    border: none;
    background: none;
    color: #dc3545;
    cursor: pointer;
    transition: opacity 0.2s;
}

.search-history-panel .history-item:hover .remove-btn {
    opacity: 1;
}

.search-history-panel .panel-footer {
    padding: 0.75rem;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
}

/* History toggle button */
.history-toggle-btn {
    position: fixed;
    right: 1rem;
    bottom: 5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
    cursor: pointer;
    z-index: 1040;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.history-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 123, 255, 0.5);
}

.history-toggle-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 0.65rem;
    min-width: 18px;
    height: 18px;
}

/* Backdrop overlay */
.search-history-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1045;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.search-history-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* ===========================================
   TIER 1: Attestation Bar Visualization
   =========================================== */
.attestation-visual {
    margin-top: 6px;
    display: flex;
    align-items: center;
}

.attestation-bar {
    width: 60px;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
}

.attestation-bar .attestation-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
    background: linear-gradient(90deg, #28a745 0%, #20c997 100%); /* Default green */
}

/* ===========================================
   TIER 1: Multi-select Filter Pills
   =========================================== */
.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    background: #e7f1ff;
    color: #0d6efd;
    border: 1px solid #b6d4fe;
    border-radius: 16px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-pill:hover {
    background: #cfe2ff;
}

.filter-pill.active {
    background: #0d6efd;
    color: white;
    border-color: #0d6efd;
}

.filter-pill .remove-pill {
    font-size: 1rem;
    line-height: 1;
    margin-left: 0.25rem;
    opacity: 0.7;
}

.filter-pill .remove-pill:hover {
    opacity: 1;
}

/* ===========================================
   Keyboard Shortcut Hint
   =========================================== */
.keyboard-hints {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.75rem;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
}

.keyboard-hints.show {
    opacity: 1;
}

.keyboard-hints kbd {
    background: #495057;
    padding: 2px 6px;
    border-radius: 3px;
    margin-right: 4px;
}

.corpus-sentences-container {
    scrollbar-width: thin;
    scrollbar-color: var(--color-success-500, #28a745) #f0f0f0;
}

.corpus-sentences-container::-webkit-scrollbar {
    width: 6px;
}

.corpus-sentences-container::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}

.corpus-sentences-container::-webkit-scrollbar-thumb {
    background: var(--color-success-500, #28a745);
    border-radius: 3px;
}

.corpus-sentences-container::-webkit-scrollbar-thumb:hover {
    background: var(--color-success-700, #218838);
}

/* Keep active favorites visible */
.btn-favorite.active {
    opacity: 1 !important;
    visibility: visible !important;
    color: #ffc107 !important; /* Bootstrap warning color */
}
.btn-favorite.active i {
    font-weight: 900 !important; /* Ensure solid star */
}

@media (max-width: 991.98px) {
    .corpus-sentences-container {
        max-height: none !important;
        overflow-y: visible !important;
    }
}

/* Split View Layout - CSS Grid */
@media (min-width: 992px) {
    .search-results-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
        align-items: start;
        width: 100%;
    }

    #dictionary-entries-column,
    #corpus-sentences-column {
        min-width: 0; /* Critical for preventing grid blowout with flex children */
        width: 100%;
    }
}

/* Responsive adjustments */
@media (max-width: 991.98px) {
    .search-results-container {
        display: flex;
    }
}

/* ===========================================
   TIER 5: Dark Mode Refinements
   Gemini search bar: global (home + search).
   Strong Bootstrap overrides: only under .page-search so entry/corpus pages keep token-based styling.
   =========================================== */
[data-theme="dark"] .gemini-input-group,
[data-theme="dark"] .search-history-panel,
[data-theme="dark"] .search-history-panel .panel-footer {
    background: #1e1e1e;
    border-color: #333;
    color: #e0e0e0;
}

[data-theme="dark"] .page-search .filter-panel {
    background: #1e1e1e;
    border-color: #333;
    color: #e0e0e0;
}

[data-theme="dark"] .gemini-input-group input {
    background: transparent;
    color: #fff;
}

[data-theme="dark"] .gemini-input-group i {
    color: #bbb;
}

[data-theme="dark"] .page-search .filter-panel h6,
[data-theme="dark"] .search-history-panel .panel-header {
    background: #252525;
    color: #ddd;
    border-bottom-color: #333;
}

[data-theme="dark"] .page-search .results-group-header .group-label {
    color: #adb5bd;
}

[data-theme="dark"] .page-search .results-group-header {
    border-bottom-color: #333;
}

[data-theme="dark"] .page-search .results-group-header .group-count {
    background: #333;
    color: #ccc;
}

[data-theme="dark"] .search-history-panel .history-item:hover {
    background: #2a2a2a;
}

[data-theme="dark"] .search-history-panel .history-item .query-text {
    color: #6ea8fe;
}

[data-theme="dark"] .search-history-panel .query-time {
    color: #888;
}

[data-theme="dark"] .page-search .filter-pill {
    background: #0c1a2b;
    color: #6ea8fe;
    border-color: #084298;
}

[data-theme="dark"] .page-search .filter-pill:hover {
    background: #102136;
}

[data-theme="dark"] .page-search .filter-pill.active {
    background: #0d6efd;
    color: #fff;
}

/* Search result highlights (dictionary search only) */
[data-theme="dark"] .page-search .search-highlight,
[data-theme="dark"] .page-search mark {
    background: linear-gradient(135deg, #664d03 0%, #856404 100%);
    color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .page-search .headword-link mark {
    background: linear-gradient(135deg, #052c65 0%, #084298 100%);
}

[data-theme="dark"] .page-search .def-text mark {
    background: linear-gradient(135deg, #0f5132 0%, #198754 100%);
}

[data-theme="dark"] .page-search .sort-controls {
    background: #252525 !important;
    border-color: #333 !important;
}

[data-theme="dark"] .page-search .sort-controls select {
    color: #e0e0e0;
}

[data-theme="dark"] .page-search .btn-outline-secondary {
    color: #adb5bd;
    border-color: #495057;
}

[data-theme="dark"] .page-search .btn-outline-secondary:hover {
    background-color: #495057;
    color: #fff;
}

[data-theme="dark"] .page-search .text-muted {
    color: #adb5bd !important;
}

[data-theme="dark"] .page-search .card {
    background-color: #1e1e1e;
    border-color: #333;
}

[data-theme="dark"] .page-search .bg-light {
    background-color: #2b2b2b !important;
}

[data-theme="dark"] .page-search .table {
    color: #e0e0e0;
    border-color: #333;
}

[data-theme="dark"] .page-search .table-striped > tbody > tr:nth-of-type(odd) > * {
    color: #e0e0e0;
    box-shadow: inset 0 0 0 9999px rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .page-search .dropdown-menu {
    background-color: #252525;
    border-color: #333;
}

[data-theme="dark"] .page-search .dropdown-item {
    color: #e0e0e0;
}

[data-theme="dark"] .page-search .dropdown-item:hover,
[data-theme="dark"] .page-search .dropdown-item:focus {
    background-color: #333;
    color: #fff;
}

/* ===========================================
   Search Page – Hero / Filters / Toolbar
   (extracted from inline <style> in search.html, 2026-05-11)
   =========================================== */

.page-search .gemini-hero {
    padding: 2rem 0;
    background: transparent;
}

.page-search .gemini-title {
    display: none;
}

.page-search .filter-panel {
    margin-top: 1rem;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    animation: searchFilterSlideDown 0.3s ease-out;
}

@keyframes searchFilterSlideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.page-search .search-toolbar-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-search .sort-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-search .search-input-wrapper {
    position: relative;
    flex-grow: 1;
    max-width: 800px;
    margin: 0 auto;
}

.page-search .form-select-sm,
.page-search .btn-sm {
    font-size: 0.85rem;
}

/* Zero-results guidance box */
.page-search .no-results-guidance {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin-top: 1rem;
}

.page-search .no-results-guidance h6 {
    margin-bottom: 0.75rem;
}

.page-search .no-results-guidance ul {
    margin-bottom: 0;
    padding-left: 1.25rem;
}

.page-search .no-results-guidance li + li {
    margin-top: 0.25rem;
}

[data-theme="dark"] .page-search .filter-panel,
[data-theme="dark"] .page-search .no-results-guidance {
    background-color: #1e1e1e;
    border-color: #333;
    color: #e0e0e0;
}

/* Active filter summary + mode hint (UX 2026-05) */
.page-search .search-mode-hint {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.45;
}

.page-search .search-active-filters .search-filter-chip {
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.35em 0.65em;
    white-space: normal;
    text-align: left;
}

[data-theme="dark"] .page-search .search-active-filters.card {
    background-color: #1e1e1e;
    border: 1px solid #333 !important;
}