/* RAG Search — Clean, Google-like styling with sidebar */

:root {
    --sgi-purple: #5f249f;
    --sgi-purple-light: #7b3fbf;
    --sgi-purple-dark: #3d1566;
    --sgi-gold: #c4a000;
    --bg: #1a1a2e;
    --bg-card: #16213e;
    --bg-input: #0f3460;
    --bg-sidebar: #111827;
    --text: #e0e0e0;
    --text-muted: #8899aa;
    --text-link: #7eb8ff;
    --border: #2a3a5e;
    --score-high: #4caf50;
    --score-mid: #ff9800;
    --score-low: #f44336;
    --sidebar-width: 200px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Sidebar ─────────────────────────────────────────────────────────── */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0;
    z-index: 100;
    transition: transform 0.25s ease;
}

.sidebar-logo {
    padding: 0 1.25rem 1.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
}

.sidebar-logo a {
    font-size: 1.3rem;
    font-weight: 300;
    text-decoration: none;
}

.sidebar-nav {
    list-style: none;
    flex: 1;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-nav li a svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-nav li a:hover {
    background: rgba(255,255,255,0.04);
    color: var(--text);
    text-decoration: none;
}

.sidebar-nav li.active a {
    color: var(--text);
    border-left-color: var(--sgi-purple-light);
    background: rgba(95, 36, 159, 0.1);
}

.sidebar-stats {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
}

.sidebar-stat {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    padding: 0.2rem 0;
}

.sidebar-stat .label { color: var(--text-muted); }
.sidebar-stat .value { color: var(--sgi-gold); font-weight: 600; }

.sidebar-toggle {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 101;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.sidebar-toggle svg { width: 20px; height: 20px; display: block; }

/* Pages with sidebar get left margin */
.has-sidebar {
    margin-left: var(--sidebar-width);
}

/* ── Home Page (centered search) ──────────────────────────────────────── */

.home-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.logo {
    margin-bottom: 2rem;
    text-align: center;
}

.logo h1 {
    font-size: 3.5rem;
    font-weight: 300;
    letter-spacing: -0.02em;
}

.logo .subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    margin-top: 0.25rem;
}

/* ── Search Form ──────────────────────────────────────────────────────── */

.search-form {
    width: 100%;
    max-width: 680px;
    margin-bottom: 2rem;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: 28px;
    padding: 0.5rem 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box:focus-within {
    border-color: var(--sgi-purple-light);
    box-shadow: 0 0 0 3px rgba(95, 36, 159, 0.2);
}

.search-box .icon {
    color: var(--text-muted);
    font-size: 1.2rem;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.search-box input[type="text"] {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 1.1rem;
    outline: none;
    padding: 0.5rem 0;
}

.search-box input[type="text"]::placeholder {
    color: var(--text-muted);
}

.search-options {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.collection-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.btn {
    background: var(--sgi-purple);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn:hover { background: var(--sgi-purple-light); }

/* ── Home Panels ──────────────────────────────────────────────────────── */

.home-panels {
    display: flex;
    gap: 2rem;
    width: 100%;
    max-width: 680px;
    flex-wrap: wrap;
}

.panel {
    flex: 1;
    min-width: 250px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
}

.panel h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.panel ul { list-style: none; }

.panel li {
    padding: 0.3rem 0;
    font-size: 0.9rem;
}

.panel li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-count {
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
}

.collection-stats {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.stat-badge {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
}

.stat-badge .label { color: var(--text-muted); }
.stat-badge .value { color: var(--sgi-gold); font-weight: 600; }

/* ── Results Page ─────────────────────────────────────────────────────── */

.results-container {
    max-width: 820px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
}

.results-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.results-header .logo-sm {
    font-size: 1.5rem;
    font-weight: 300;
    white-space: nowrap;
}

.results-header .search-form {
    flex: 1;
    margin-bottom: 0;
    min-width: 300px;
}

.results-meta {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.result-item { margin-bottom: 1.75rem; }

.result-source {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
    word-break: break-all;
}

.result-title { font-size: 1.1rem; margin-bottom: 0.3rem; }
.result-title a { color: var(--text-link); }
.result-title a:hover { text-decoration: underline; }

.result-snippet {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.result-score {
    display: inline-block;
    font-size: 0.75rem;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.score-high { background: rgba(76, 175, 80, 0.2); color: var(--score-high); }
.score-mid { background: rgba(255, 152, 0, 0.2); color: var(--score-mid); }
.score-low { background: rgba(244, 67, 54, 0.2); color: var(--score-low); }

.result-expand { margin-top: 0.5rem; }

.result-expand details summary {
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--sgi-purple-light);
}

.result-expand pre {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-break: break-word;
    margin-top: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
}

/* ── History Page ─────────────────────────────────────────────────────── */

.history-container {
    max-width: 820px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th {
    text-align: left;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.history-table td {
    padding: 0.5rem;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(42, 58, 94, 0.4);
}

/* ── Nav (legacy, still used as footer) ──────────────────────────────── */

.nav-links {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-top: 1rem;
    font-size: 0.85rem;
}

.nav-links a { color: var(--text-muted); }
.nav-links a:hover { color: var(--text-link); }

/* ── Footer ───────────────────────────────────────────────────────────── */

.footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 2rem;
}

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.5); }
    .sidebar-toggle { display: block; }
    .has-sidebar { margin-left: 0; }
    .logo h1 { font-size: 2.2rem; }
    .results-header { flex-direction: column; }
    .home-panels { flex-direction: column; }
    .results-container, .history-container { padding: 1rem; }
}
