/* ============================================================
   VBPL-AI — Search Page Styles
   ============================================================ */

/* Light mode overrides for search page */
html.light .sidebar-search { background: #f8fafc; }
html.light .filter-select,
html.light .filter-input { background: #ffffff; color: #0f172a; }
html.light .filter-select option { background: #f8fafc; color: #0f172a; }
html.light .result-item { background: #ffffff; }
html.light .result-item:hover { background: #f8fafc; }
html.light .result-snippet mark { background: rgba(245,158,11,0.15); color: #b45309; }
html.light .quick-search-btn { background: #f1f5f9; }
html.light .page-btn { background: #f1f5f9; }
html.light .search-bar { background: #ffffff; }
html.light .exact-search-hint { background: rgba(59,130,246,0.06); border-color: rgba(59,130,246,0.2); }

/* Exact search indicator */
.exact-search-badge {
    display: none;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    background: rgba(139,92,246,0.1);
    border: 1px solid rgba(139,92,246,0.3);
    border-radius: 100px;
    font-size: 0.75rem;
    color: var(--accent-light);
    font-weight: 600;
    margin-left: 8px;
}
.exact-search-badge.visible { display: inline-flex; }
html.light .exact-search-badge { background: rgba(139,92,246,0.08); color: var(--accent); }

/* Exact search hint box */
.exact-search-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    padding: 6px 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.exact-search-hint code {
    background: rgba(59,130,246,0.1);
    color: var(--primary-light);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: monospace;
}
html.light .exact-search-hint code { color: var(--primary-dark); }

/* Sidebar ───────────────────────────────────────────────── */
.sidebar-search {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    padding: 28px 20px;
    overflow-y: auto;
    height: calc(100vh - var(--topbar-h));
    position: sticky;
    top: var(--topbar-h);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.sidebar-header h3 {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}

.btn-clear-filters {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    font-family: inherit;
}
.btn-clear-filters:hover { color: var(--danger); background: rgba(239,68,68,0.1); }

.filter-group {
    margin-bottom: 20px;
}
.filter-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.filter-select,
.filter-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
    appearance: none;
}
.filter-select { cursor: pointer; }
.filter-select:focus,
.filter-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.filter-select option { background: var(--bg-surface); }
.filter-input::placeholder { color: var(--text-muted); }

.btn-apply-filters {
    width: 100%;
    padding: 12px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition);
    font-family: inherit;
    margin-top: 8px;
}
.btn-apply-filters:hover { opacity: 0.88; }

/* Search Page ─────────────────────────────────────────── */
.search-page {
    padding: 32px 40px;
    max-width: 900px;
    width: 100%;
}

.search-header { margin-bottom: 28px; }
.search-header h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: 6px; }
.search-header p { color: var(--text-secondary); font-size: 0.9rem; }

.search-bar-wrapper { margin-bottom: 28px; }
.search-bar {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.search-bar:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59,130,246,0.1);
}

.search-icon {
    width: 20px; height: 20px;
    margin-left: 18px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-bar input {
    flex: 1;
    padding: 16px 16px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
}
.search-bar input::placeholder { color: var(--text-muted); }

.search-bar button {
    padding: 14px 24px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition);
    font-family: inherit;
    flex-shrink: 0;
}
.search-bar button:hover { opacity: 0.88; }

/* Results Meta ──────────────────────────────────────────── */
.results-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
#results-count { font-size: 0.88rem; color: var(--text-secondary); }
#results-count strong { color: var(--text-primary); }

.sort-options { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--text-muted); }
.sort-btn {
    padding: 5px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.sort-btn.active, .sort-btn:hover {
    background: rgba(59,130,246,0.1);
    border-color: var(--primary);
    color: var(--primary-light);
}

/* Result Items ──────────────────────────────────────────── */
.result-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 12px;
    transition: all var(--transition);
    animation: fadeInUp 0.3s ease;
}
.result-item:hover {
    border-color: rgba(59,130,246,0.3);
    background: var(--bg-card-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.result-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 8px;
}
.result-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.result-date { font-size: 0.78rem; color: var(--text-muted); }

.result-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 10px;
}
.result-title a { color: var(--text-primary); transition: color var(--transition); }
.result-title a:hover { color: var(--primary-light); }

.result-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.meta-item svg { width: 13px; height: 13px; }

.sector-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.sector-tag {
    padding: 2px 9px;
    background: rgba(16,185,129,0.08);
    border: 1px solid rgba(16,185,129,0.2);
    border-radius: 100px;
    font-size: 0.72rem;
    color: #6ee7b7;
}

.result-snippet {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 14px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.result-snippet mark {
    background: rgba(245,158,11,0.2);
    color: var(--gold);
    border-radius: 2px;
    padding: 0 2px;
}

.result-actions { display: flex; gap: 10px; }
.btn-view {
    padding: 7px 16px;
    background: var(--gradient-primary);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    transition: opacity var(--transition);
}
.btn-view:hover { opacity: 0.85; }
.btn-source {
    padding: 7px 14px;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    transition: all var(--transition);
}
.btn-source:hover { color: var(--primary-light); border-color: var(--primary); }

/* Empty state ───────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: var(--text-muted);
}
.empty-state svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 1.1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 0.88rem; margin-bottom: 24px; }

.quick-searches { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.quick-searches span { font-size: 0.82rem; color: var(--text-muted); }
.quick-search-btn {
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 100px;
    color: var(--text-secondary);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.quick-search-btn:hover { color: var(--primary-light); border-color: var(--primary); }

/* No results ────────────────────────────────────────────── */
.no-results { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.no-results h3 { color: var(--text-secondary); margin-bottom: 8px; }

/* Pagination ────────────────────────────────────────────── */
.pagination-wrapper { display: flex; justify-content: center; padding: 24px 0; gap: 6px; flex-wrap: wrap; }
.page-btn {
    min-width: 38px; height: 38px;
    padding: 0 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
    display: flex; align-items: center; justify-content: center;
    font-family: inherit;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary-light); }
.page-btn.active { background: var(--gradient-primary); color: white; border-color: transparent; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Autocomplete ──────────────────────────────────────────── */
.search-bar-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: calc(100% - 8px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
    z-index: 200;
    overflow: hidden;
    animation: dropdownIn 0.15s ease;
}

@keyframes dropdownIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.autocomplete-dropdown:empty { display: none; }

.autocomplete-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 18px;
    cursor: pointer;
    transition: background var(--transition);
    border-bottom: 1px solid var(--border);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.focused {
    background: rgba(59,130,246,0.08);
}

.autocomplete-icon {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
    opacity: 0.6;
}

.autocomplete-text {
    flex: 1;
    min-width: 0;
}
.autocomplete-title {
    font-size: 0.88rem;
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.autocomplete-title mark {
    background: transparent;
    color: var(--primary-light);
    font-weight: 700;
}
.autocomplete-meta {
    font-size: 0.73rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.autocomplete-badge {
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.68rem;
    font-weight: 600;
    background: rgba(59,130,246,0.1);
    color: var(--primary-light);
    border: 1px solid rgba(59,130,246,0.2);
    white-space: nowrap;
    flex-shrink: 0;
}

html.light .autocomplete-dropdown {
    background: #ffffff;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
html.light .autocomplete-item:hover,
html.light .autocomplete-item.focused {
    background: #f0f7ff;
}
html.light .autocomplete-title mark { color: var(--primary-dark); }
html.light .search-bar:focus-within {
    border-radius: var(--radius) var(--radius) 0 0;
}

/* ── Nút Hỏi AI trong kết quả tìm kiếm ─────────────────── */
.btn-ask-ai {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition);
    background: rgba(139, 92, 246, 0.12);
    color: var(--accent-light);
    border: 1px solid rgba(139, 92, 246, 0.25);
}
.btn-ask-ai:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: translateY(-1px);
}
html.light .btn-ask-ai {
    background: rgba(139, 92, 246, 0.08);
    color: var(--accent);
}
html.light .btn-ask-ai:hover {
    background: var(--accent);
    color: #fff;
}

