/* 西北工业大学 RAG 智能问答系统 - 高级 chat 风格 */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #f4f6fb;
    --bg-soft: #e7ebf5;
    --panel: #ffffff;
    --panel-strong: #ffffff;
    --glass: rgba(255, 255, 255, 0.9);
    --primary: #1f4b99; /* 海军蓝 */
    --primary-strong: #163a7c;
    --accent: #7aa2ff; /* 辅助蓝 */
    --muted: #5b6475;
    --text: #0b1628;
    --shadow: 0 25px 80px rgba(15, 23, 42, 0.12);
    --shadow-soft: 0 16px 40px rgba(31, 75, 153, 0.2);
    --radius-lg: 18px;
    --radius-xl: 26px;
    --radius-full: 999px;
}

body.theme-dark {
    --bg: #0a1018;
    --bg-soft: #0f1722;
    --panel: rgba(255, 255, 255, 0.06);
    --panel-strong: rgba(255, 255, 255, 0.08);
    --glass: rgba(255, 255, 255, 0.08);
    --primary: #1f4b99;
    --primary-strong: #2a66cc;
    --accent: #7aa2ff;
    --muted: #a9b4c2;
    --text: #eef2f7;
    --shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
    --shadow-soft: 0 16px 40px rgba(31, 75, 153, 0.25);
}

body {
    font-family: 'Manrope', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: radial-gradient(circle at 20% 20%, rgba(31, 75, 153, 0.12), transparent 28%),
                radial-gradient(circle at 80% 0%, rgba(122, 162, 255, 0.14), transparent 25%),
                var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.7;
    overflow-x: hidden;
}

.background-decoration {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 10% 80%, rgba(31, 75, 153, 0.18), transparent 38%),
                radial-gradient(circle at 90% 40%, rgba(122, 162, 255, 0.16), transparent 34%);
    filter: blur(28px);
    z-index: 0;
    pointer-events: none;
}

.grid-overlay { display: none; }

.grain { display: none; }

.page {
    max-width: 1260px;
    margin: 0 auto;
    padding: 2.6rem 1.6rem;
    position: relative;
    z-index: 1;
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.2rem;
    border-radius: var(--radius-lg);
    background: var(--glass);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
    margin-bottom: 1.8rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.logo-mark {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: linear-gradient(135deg, #1f4b99 0%, #4b6fb3 100%);
    color: #eef2f7;
    display: grid;
    place-items: center;
    font-weight: 800;
    letter-spacing: 0.06em;
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.35);
}

.logo-text { display: flex; flex-direction: column; gap: 0.15rem; }
.logo-title { font-weight: 900; letter-spacing: -0.02em; }
.logo-desc { color: var(--muted); font-size: 0.95rem; }

.nav-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-full);
    font-weight: 800;
    font-size: 0.9rem;
    letter-spacing: -0.01em;
    border: 1px solid rgba(15, 23, 42, 0.1);
    color: var(--text);
    background: rgba(255, 255, 255, 0.5);
}
.status-pill.success { color: #1f4b99; border-color: rgba(31, 75, 153, 0.25); background: rgba(31, 75, 153, 0.12); }
.status-pill.accent { color: #4b6fb3; border-color: rgba(75, 111, 179, 0.25); background: rgba(75, 111, 179, 0.12); }
.status-pill.soft { color: var(--muted); }
.status-pill.ghost { background: rgba(255, 255, 255, 0.04); color: var(--muted); }

.toggle-btn {
    cursor: pointer;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
}
.toggle-btn:hover {
    box-shadow: var(--shadow-soft);
    transform: translateY(-1px);
}

.layout { display: grid; grid-template-columns: 360px 1fr; gap: 1.2rem; }
.glass {
    background: var(--glass);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.sidebar {
    padding: 1.3rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.hero-card {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 1rem 1rem;
    border-radius: var(--radius-lg);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04));
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.hero-icon { font-size: 2.6rem; filter: drop-shadow(0 10px 16px rgba(90, 183, 255, 0.6)); }
.hero-card h1 { font-size: 1.55rem; letter-spacing: -0.02em; margin-bottom: 0.15rem; }
.header-subtitle { color: var(--muted); font-size: 0.95rem; }
.eyebrow { font-size: 0.85rem; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }

.chip-block {
    padding: 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.06);
}
.chip-title { font-weight: 800; margin-bottom: 0.6rem; }
.prompt-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.prompt-chip {
    border: 1px solid rgba(31, 75, 153, 0.35);
    background: rgba(31, 75, 153, 0.12);
    color: var(--text);
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s ease;
}
.prompt-chip:hover { transform: translateY(-1px); box-shadow: var(--shadow-soft); background: rgba(75, 111, 179, 0.16); }

.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.7rem; }
.meta-card {
    padding: 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: var(--shadow-soft);
}
.meta-label { color: var(--muted); font-size: 0.9rem; letter-spacing: 0.05em; margin-bottom: 0.2rem; text-transform: uppercase; }
.meta-value { font-size: 1.2rem; font-weight: 900; letter-spacing: -0.02em; margin-bottom: 0.2rem; }
.meta-card p { color: var(--muted); font-size: 0.93rem; }

.tip-card {
    padding: 1.05rem;
    border-radius: var(--radius-lg);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
}
.tip-title { font-weight: 800; margin-bottom: 0.5rem; }
.tip-list { list-style: none; display: grid; gap: 0.4rem; color: var(--muted); font-size: 0.95rem; }

.chat-panel {
    padding: 1.3rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}
.panel-head { display: flex; justify-content: space-between; gap: 1rem; }
.panel-head h3 { font-size: 1.28rem; font-weight: 900; letter-spacing: -0.02em; margin-bottom: 0.25rem; }
.panel-desc { color: var(--muted); max-width: 720px; }
.panel-status { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }

.search-wrapper { display: flex; flex-direction: column; gap: 1rem; }
.search-form { display: flex; flex-direction: column; gap: 0.9rem; }
.input-wrapper { position: relative; }
.input-icon { position: absolute; left: 1.1rem; top: 50%; transform: translateY(-50%); color: var(--primary); font-size: 1.2rem; }
.search-input {
    width: 100%;
    padding: 1.1rem 1.1rem 1.1rem 3.1rem;
    border-radius: var(--radius-xl);
    border: 1.4px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-size: 1.03rem;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
    transition: all 0.2s ease;
}
.search-input:focus {
    outline: none;
    border-color: rgba(130, 210, 255, 0.8);
    box-shadow: 0 18px 40px rgba(130, 210, 255, 0.18);
}
.button-group { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.btn {
    padding: 0.95rem 1.4rem;
    font-weight: 800;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.98rem;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-soft);
    color: var(--text);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(120deg, #5ab7ff 0%, #82d2ff 100%); color: #0b1220; }
.btn-primary { background: linear-gradient(120deg, #1f4b99 0%, #4b6fb3 100%); color: #f5f7fb; }
.btn-primary:hover { box-shadow: 0 16px 32px rgba(31, 75, 153, 0.35); }
.btn-chat { background: linear-gradient(120deg, #0f172a 0%, #111827 100%); color: #e9eef7; }
.btn-chat:hover { box-shadow: 0 16px 32px rgba(0, 0, 0, 0.45); }
.btn-clear { background: rgba(255, 255, 255, 0.08); color: #fca5a5; border: 1px solid rgba(252, 165, 165, 0.35); }
.btn-clear:hover { background: rgba(252, 165, 165, 0.16); }

.search-options { display: flex; justify-content: flex-end; }
.option-item { display: flex; align-items: center; gap: 0.7rem; }
.option-label { color: var(--muted); font-weight: 700; }
.label-icon { opacity: 0.6; }
.option-input {
    width: 90px;
    padding: 0.5rem 0.6rem;
    border-radius: 12px;
    border: 1.5px solid rgba(255, 255, 255, 0.16);
    text-align: center;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}
.option-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(16, 163, 127, 0.2); }

.helper-strip { display: none; }

.error-message {
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.35);
    color: #fecdd3;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    display: none;
}
.error-message.active { display: block; }

.loading {
    display: none;
    text-align: center;
    padding: 1.2rem;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.loading.active { display: block; animation: fadeIn 0.25s ease; }
.loading-content { display: flex; flex-direction: column; gap: 0.6rem; align-items: center; }
.spinner-wrapper { position: relative; width: 52px; height: 52px; }
.spinner {
    width: 52px; height: 52px; border: 4px solid rgba(130, 210, 255, 0.2);
    border-top: 4px solid var(--primary); border-radius: 50%; animation: spin 0.9s linear infinite;
}
.spinner-ring {
    position: absolute; inset: 6px; border: 2px dashed rgba(157, 123, 255, 0.28);
    border-radius: 50%; animation: spin 1.6s linear infinite reverse;
}
.loading-dots span {
    width: 8px; height: 8px; display: inline-block; margin: 0 3px;
    background: var(--primary); border-radius: 50%; animation: pulse 1.3s infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.loading-dots span:nth-child(3) { animation-delay: 0.3s; }

.results-container { display: flex; flex-direction: column; gap: 1rem; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; color: var(--text); }
.section-title small { color: var(--muted); }

.chat-history-section,
.sources-section {
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 1.2rem;
    box-shadow: var(--shadow-soft);
}

.chat-history-list { display: flex; flex-direction: column; gap: 1rem; margin-top: 0.5rem; }
.chat-message {
    padding: 1rem 1.1rem;
    border-radius: 18px;
    max-width: 90%;
    position: relative;
    line-height: 1.6;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
    animation: floatIn 0.2s ease;
}
.chat-message.user {
    align-self: flex-end;
    background: linear-gradient(120deg, #0b1220 0%, #0f172a 100%);
    color: #e9eef7;
    border: 1px solid rgba(255, 255, 255, 0.14);
}
.chat-message.assistant {
    align-self: flex-start;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
}
.chat-message-header { font-size: 0.82rem; opacity: 0.7; margin-bottom: 0.4rem; font-weight: 800; letter-spacing: 0.05em; }
.answer-section { display: none; }

.source-list { display: grid; gap: 0.8rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.source-item {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem 1.1rem 1rem 1.3rem;
    position: relative;
    transition: all 0.2s ease;
    cursor: pointer;
    animation: floatIn 0.28s ease;
}
.source-item::before {
    content: '';
    position: absolute;
    left: 0.9rem;
    top: 1.1rem;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--primary) 0%, var(--accent) 100%);
    box-shadow: 0 0 0 6px rgba(157, 123, 255, 0.25);
}
.source-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); }
.source-title { font-weight: 800; display: flex; align-items: center; gap: 0.4rem; color: var(--text); margin-left: 1.1rem; }
.source-meta { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.5rem 0 0.4rem 1.1rem; }
.source-tag {
    padding: 0.25rem 0.7rem;
    border-radius: var(--radius-full);
    background: rgba(130, 210, 255, 0.16);
    font-weight: 700;
    color: var(--text);
}
.source-category { background: rgba(157, 123, 255, 0.18); }
.source-similarity { background: rgba(134, 239, 172, 0.18); }
.source-content {
    margin-top: 0.55rem;
    margin-left: 1.1rem;
    color: var(--muted);
    font-size: 0.95rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.source-content.expanded {
    -webkit-line-clamp: unset;
    display: block;
}

.empty-state {
    text-align: center;
    padding: 1.4rem;
    color: var(--muted);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg);
}

@media (max-width: 1100px) {
    .layout { grid-template-columns: 1fr; }
    .nav { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
}

@media (max-width: 720px) {
    .page { padding: 1.5rem 1rem; }
    .panel-head { flex-direction: column; }
    .button-group { flex-direction: column; }
    .btn { width: 100%; justify-content: center; }
    .chat-message { max-width: 100%; }
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }
@keyframes floatIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
