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

:root {
    --bg-deep:    #0d1117;
    --bg-mid:     #161b22;
    --bg-surface: #21262d;
    --border:     #30363d;
    --text-main:  #e6edf3;
    --text-muted: #8b949e;
    --text-faint: #484f58;
    --accent:     #1f6feb;
    --accent-hover: #388bfd;
    --green:      #238636;
    --red:        #da3633;
    --orange:     #d29922;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg-deep);
    color: var(--text-main);
    font-size: 14px;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--bg-mid);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid var(--border);
}

.logo { font-size: 22px; }

.logo-text {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.3px;
}

.sidebar-section {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.sidebar-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 4px;
    padding: 0 4px;
}

.quick-btn {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 7px 10px;
    text-align: left;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quick-btn:hover {
    background: var(--bg-surface);
    border-color: var(--border);
    color: var(--text-main);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.clear-btn {
    width: 100%;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 7px 10px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.clear-btn:hover {
    background: var(--bg-surface);
    border-color: var(--red);
    color: var(--red);
}

/* ─── Chat Panel ─────────────────────────────────────────────────────────── */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-deep);
}

/* ─── Messages ───────────────────────────────────────────────────────────── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.message {
    display: flex;
    gap: 12px;
    max-width: 860px;
    width: 100%;
}

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

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    background: var(--bg-surface);
}

.bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.65;
}

.message.user .bubble {
    background: var(--accent);
    color: #fff;
    border-radius: 12px 2px 12px 12px;
    border: 1px solid transparent;
}

.message.assistant .bubble {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 2px 12px 12px 12px;
    color: var(--text-main);
}

/* ─── Bubble Content Styles ──────────────────────────────────────────────── */
.bubble p            { margin: 0 0 8px 0; }
.bubble p:last-child { margin-bottom: 0; }

.bubble ul, .bubble ol { margin: 6px 0 8px 16px; }
.bubble li            { margin: 3px 0; }

.bubble h4 {
    font-size: 14px;
    font-weight: 600;
    margin: 10px 0 6px;
    color: #79c0ff;
}

.bubble h5 {
    font-size: 13px;
    font-weight: 600;
    margin: 8px 0 4px;
}

.bubble strong        { color: #f0f6fc; }
.bubble em            { color: var(--text-muted); }

.bubble code {
    background: var(--bg-deep);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Cascadia Code', Consolas, monospace;
    font-size: 12px;
    color: #79c0ff;
}

/* Tables */
.bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
}

.bubble th {
    background: var(--bg-deep);
    padding: 6px 10px;
    text-align: left;
    border: 1px solid var(--border);
    font-weight: 600;
    white-space: nowrap;
}

.bubble td {
    padding: 6px 10px;
    border: 1px solid var(--border);
    vertical-align: top;
}

.bubble tr:nth-child(even) td { background: rgba(255,255,255,0.025); }

/* User bubble overrides */
.message.user .bubble strong { color: #deeeff; }
.message.user .bubble a      { color: #9ecfff; }

/* ─── Thinking Indicator ─────────────────────────────────────────────────── */
.thinking {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 2px 12px 12px 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.dots {
    display: flex;
    gap: 4px;
}

.dots span {
    width: 6px;
    height: 6px;
    background: var(--text-faint);
    border-radius: 50%;
    animation: bounce 1.3s ease-in-out infinite;
}

.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
    40%            { transform: translateY(-5px); opacity: 1; }
}

/* ─── Error ──────────────────────────────────────────────────────────────── */
.error-bubble {
    padding: 10px 14px;
    background: #2d1112;
    border: 1px solid #6e2c2c;
    border-radius: 8px;
    color: #ffa198;
    font-size: 13px;
}

/* ─── Input Area ─────────────────────────────────────────────────────────── */
.chat-input-area {
    padding: 16px 32px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-mid);
}

.input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

textarea {
    flex: 1;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-main);
    font-family: inherit;
    line-height: 1.55;
    resize: none;
    max-height: 160px;
    overflow-y: auto;
    transition: border-color 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
}

textarea::placeholder { color: var(--text-faint); }

#sendBtn {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    background: var(--accent);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: background 0.2s, transform 0.1s;
}

#sendBtn:hover   { background: var(--accent-hover); }
#sendBtn:active  { transform: scale(0.94); }
#sendBtn:disabled {
    background: var(--bg-surface);
    color: var(--text-faint);
    cursor: not-allowed;
}

.input-hint {
    margin-top: 7px;
    text-align: center;
    font-size: 11px;
    color: var(--text-faint);
}
