/* ── AMNC Brand Colors ── */
:root {
    --blue-primary: #1773b2;
    --blue-accent: #009bd9;
    --blue-dark: #0a274f;
    --blue-highlight: #1862ec;
    --gray-light: #e6ebf1;
    --gray-bg: #f5f7fa;
    --footer-dark: #0a121b;
    --white: #ffffff;
    --text-dark: #1a1a2e;
    --text-gray: #666;
    --text-light: #999;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-sm: 8px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: var(--gray-bg);
    color: var(--text-dark);
    min-height: 100vh;
    line-height: 1.6;
}

.wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Header ── */
.header {
    background: linear-gradient(135deg, var(--blue-primary), var(--blue-dark));
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo {
    height: 36px;
    width: 36px;
    border-radius: 6px;
    object-fit: contain;
    background: rgba(255,255,255,0.15);
    padding: 2px;
}

.brand {
    color: var(--white);
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.nav-link {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.3);
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--white);
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.5);
}

/* ── Hero ── */
.hero {
    background: linear-gradient(135deg, var(--blue-dark), var(--blue-primary));
    padding: 40px 24px;
    text-align: center;
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
}

.hero-title {
    color: var(--white);
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.hero-subtitle {
    color: rgba(255,255,255,0.7);
    font-size: 16px;
}

/* ── Main Layout ── */
.main {
    max-width: 1200px;
    width: 100%;
    margin: -20px auto 0;
    padding: 0 24px 40px;
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

/* ── Chat Container ── */
.chat-container {
    flex: 1;
    min-width: 0;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 280px);
    min-height: 500px;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb {
    background: #ddd; border-radius: 3px;
}
.chat-messages::-webkit-scrollbar-thumb:hover { background: #ccc; }

/* ── Welcome ── */
.welcome-msg {
    text-align: center;
    padding: 40px 20px;
    margin: auto;
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.welcome-msg h2 {
    font-size: 22px;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.welcome-msg p {
    color: var(--text-gray);
    font-size: 14px;
    margin-bottom: 24px;
}

.quick-asks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.quick-btn {
    display: inline-block;
    padding: 8px 16px;
    background: var(--gray-light);
    color: var(--blue-primary);
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.quick-btn:hover {
    background: var(--blue-accent);
    color: var(--white);
}

/* ── Messages ── */
.message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

.msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    background: var(--gray-light);
}

.msg-user .msg-avatar { background: var(--blue-accent); }

.msg-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.msg-text {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.7;
    word-break: break-word;
}

.msg-bot .msg-text {
    background: var(--gray-light);
    color: var(--text-dark);
    border-top-left-radius: 2px;
}

.msg-user .msg-text {
    background: var(--blue-accent);
    color: var(--white);
    border-top-right-radius: 2px;
}

.msg-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.src-tag {
    font-size: 11px;
    color: var(--text-light);
    margin-right: 4px;
}

.src-item {
    font-size: 11px;
    padding: 2px 8px;
    background: var(--gray-light);
    color: var(--text-gray);
    border-radius: 10px;
    cursor: default;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Input ── */
.chat-input-area {
    border-top: 1px solid #eee;
    padding: 16px 20px;
}

.chat-input-box {
    display: flex;
    gap: 8px;
    align-items: center;
    background: var(--gray-bg);
    border-radius: 24px;
    padding: 4px 4px 4px 18px;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.chat-input-box:focus-within {
    border-color: var(--blue-accent);
    background: var(--white);
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    padding: 10px 0;
    outline: none;
    color: var(--text-dark);
}

.chat-input::placeholder { color: var(--text-light); }

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--blue-accent);
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-btn:hover { background: var(--blue-primary); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.hint {
    text-align: center;
    font-size: 12px;
    color: var(--text-light);
    margin-top: 8px;
}

/* ── Spinner ── */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Stats Panel ── */
.stats-panel {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 16px;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--blue-dark);
}

/* ── Footer ── */
.footer {
    background: var(--footer-dark);
    padding: 16px 24px;
    text-align: center;
    margin-top: auto;
}

.footer-inner {
    font-size: 13px;
    color: rgba(255,255,255,0.5);
}

.footer-inner a {
    color: rgba(255,255,255,0.5);
    text-decoration: none;
}

.footer-inner a:hover { color: rgba(255,255,255,0.8); }

.sep { margin: 0 8px; color: rgba(255,255,255,0.2); }

/* ── Responsive ── */
@media (max-width: 860px) {
    .main {
        flex-direction: column;
    }
    .stats-panel {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }
    .stat-card {
        flex: 1;
        min-width: 140px;
    }
    .chat-container {
        height: calc(100vh - 380px);
    }
    .hero-title { font-size: 22px; }
}
