/* ── 51学通信 · 3GPP规范智能问答 - Stylesheet ── */

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-chat: #0f172a;
    --bg-user-msg: #1d4ed8;
    --bg-ai-msg: #1e293b;
    --bg-input: #1e293b;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --border: #334155;
    --source-bg: #172554;
    --success: #22c55e;
    --warning: #eab308;
    --error: #ef4444;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 900px;
    margin: 0 auto;
}

/* ── Header ── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-sub {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 8px;
}

.badge {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--accent);
    color: white;
    margin-right: 12px;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}
.btn-icon:hover { background: rgba(255,255,255,0.1); }

/* ── Chat Area ── */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

.chat-area::-webkit-scrollbar { width: 6px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Welcome ── */
.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    padding: 40px 20px;
}

.welcome h2 {
    font-size: 24px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome p {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 14px;
}

.example-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
    max-width: 800px;
    width: 100%;
}

.example-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.example-card:hover {
    border-color: var(--accent);
    background: rgba(59,130,246,0.1);
    transform: translateY(-1px);
}

.example-icon { font-size: 24px; flex-shrink: 0; }

.example-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ── Messages ── */
.message {
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-user {
    display: flex;
    justify-content: flex-end;
}

.message-user .bubble {
    background: var(--bg-user-msg);
    color: white;
    padding: 10px 16px;
    border-radius: 16px 16px 4px 16px;
    max-width: 75%;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.message-ai {
    display: flex;
    justify-content: flex-start;
}

.message-ai .bubble {
    background: var(--bg-ai-msg);
    padding: 16px 20px;
    border-radius: 16px 16px 16px 4px;
    max-width: 95%;
    font-size: 14px;
    line-height: 1.7;
    word-break: break-word;
}

/* Markdown content in AI messages */
.message-ai .bubble h1, .message-ai .bubble h2, .message-ai .bubble h3 {
    color: var(--text-primary);
    margin: 16px 0 8px;
}

.message-ai .bubble h3 { font-size: 16px; }

.message-ai .bubble p { margin: 8px 0; }

.message-ai .bubble blockquote {
    border-left: 3px solid var(--accent);
    padding: 8px 16px;
    margin: 8px 0;
    background: rgba(59,130,246,0.1);
    border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.message-ai .bubble strong {
    color: #93c5fd;
}

.message-ai .bubble code {
    background: rgba(0,0,0,0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'Fira Code', monospace;
}

.message-ai .bubble pre {
    background: rgba(0,0,0,0.3);
    padding: 12px 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-ai .bubble ul, .message-ai .bubble ol {
    padding-left: 20px;
    margin: 8px 0;
}

.message-ai .bubble li { margin: 4px 0; }

.message-ai .bubble hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 12px 0;
}

/* Source tags */
.source-tag {
    display: inline-block;
    padding: 2px 8px;
    margin: 2px 4px;
    background: var(--source-bg);
    border: 1px solid #2563eb;
    border-radius: 4px;
    font-size: 12px;
    color: #93c5fd;
    cursor: default;
}

/* ── Source Panel ── */
.source-panel {
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    max-height: 200px;
    overflow: hidden;
    transition: max-height 0.3s;
}

.source-panel.hidden { max-height: 0; border: none; }

.source-header {
    padding: 8px 20px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}

.source-content {
    padding: 0 20px 12px;
    font-size: 12px;
    overflow-y: auto;
    max-height: 160px;
}

.source-item {
    padding: 4px 0;
    color: var(--text-muted);
}

.source-item span {
    color: #93c5fd;
    font-weight: 500;
}

/* ── Input Area ── */
.input-area {
    padding: 12px 20px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 8px 8px 8px 16px;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--accent);
}

#userInput {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    max-height: 120px;
    outline: none;
    font-family: inherit;
}

#userInput::placeholder { color: var(--text-muted); }

.send-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: var(--accent);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.input-hint {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
}

.hint-main {
    margin-bottom: 2px;
}

.hint-brand {
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0.8;
    margin-top: 2px;
}

.hint-promo {
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0.6;
    margin-top: 1px;
}

/* ── Loading indicator ── */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: blink 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
    0%, 60%, 100% { opacity: 0.3; }
    30% { opacity: 1; }
}

/* ── Search Status (Planning phase) ── */
.search-status {
    padding: 12px 16px;
    background: rgba(59,130,246,0.08);
    border: 1px solid rgba(59,130,246,0.2);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.8;
}

.search-status .status-icon {
    margin-right: 6px;
}

.search-status .step-badge {
    display: inline-block;
    padding: 1px 8px;
    background: var(--source-bg);
    border: 1px solid #2563eb;
    border-radius: 4px;
    font-size: 12px;
    color: #93c5fd;
    font-weight: 500;
    margin: 2px 4px 2px 0;
}

.search-status strong {
    color: #93c5fd;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .header { padding: 10px 12px; }
    .logo { font-size: 15px; }
    .logo-sub { display: none; }
    .badge { display: none; }
    .chat-area { padding: 12px; }
    .example-grid { grid-template-columns: 1fr; }
    .input-area { padding: 8px 12px 12px; }
    .message-user .bubble, .message-ai .bubble { max-width: 95%; }
}
