/* ── Reset & base ── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: #fafafa;
    color: #1a1a1a;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.app-container {
    max-width: var(--page-width);
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
}

/* ── Header ── */
header {
    display: flex;
    align-items: baseline; /* title and nav links share a text baseline */
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
    background: #fff;
}

a.header-left {
    display: flex;
    align-items: baseline; /* exports the h1 baseline to the header */
    gap: 12px;
    text-decoration: none !important;
    color: inherit;
}

a.header-left:hover,
a.header-left:visited,
a.header-left h1 {
    text-decoration: none !important;
    color: inherit;
}

.logo-icon {
    align-self: center; /* icons have no baseline; keep them centered */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #2563eb;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    flex-shrink: 0;
}

header h1 {
    font-size: 1.35em;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: -0.02em;
}

header nav {
    display: flex;
    align-items: baseline;
    gap: 4px;
    flex: 1;
    margin-left: 40px;
}

header nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: var(--fs-sm);
    padding: 6px 12px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

header nav a:hover {
    background: #f5f5f5;
    color: #1a1a1a;
}

header nav a.active {
    background: var(--line-soft);
    color: #1a1a1a;
    font-weight: 500;
}

.chat-header {
    display: flex;
    justify-content: flex-end;
    padding: 6px 16px 0;
    flex-shrink: 0;
}

.chat-export-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: none;
    color: #bbb;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.chat-export-btn:hover {
    background: #f5f5f5;
    color: #1a1a1a;
}

/* ── Main / chat area ── */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
}

/* chat reads as a centered column inside the full-width page */
.chat-messages, footer form, .chart-area {
    max-width: 920px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

/* ── Messages ── */
.message {
    margin-bottom: 18px;
    padding: 10px 14px;
    border-radius: 10px;
    max-width: 88%;
    line-height: 1.55;
    font-size: var(--fs-md);
    word-wrap: break-word;
}

.message.user {
    background: #f5f5f5;
    margin-left: auto;
    color: #1a1a1a;
}

.message.assistant {
    background: transparent;
    padding-left: 0;
    padding-right: 0;
    color: #333;
}

.message.assistant.error {
    background: #fef2f2;
    border-left: 2px solid var(--bad);
    padding: 10px 14px;
}

/* ── SQL blocks ── */
.message .sql-block {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 12px 14px;
    border-radius: 8px;
    font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
    font-size: var(--fs-sm);
    overflow-x: auto;
    margin: 10px 0;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.5;
}

/* ── Tables ── */
.message table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
    margin: 10px 0;
}

.message th,
.message td {
    padding: 8px 12px;
    text-align: left;
}

.message th {
    background: #fafafa;
    font-weight: 600;
    font-size: var(--fs-sm);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    border-bottom: 2px solid var(--line);
}

.message td {
    border-bottom: 1px solid var(--line-soft);
    color: #333;
}

.message tbody tr:hover td {
    background: #fafafa;
}

.message .table-wrap {
    max-height: 400px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.message .table-wrap table {
    margin: 0;
    border: none;
}

.message .row-count {
    font-size: var(--fs-sm);
    color: #999;
    margin-top: 6px;
}

/* ── Chart button ── */
.chart-btn {
    display: inline-block;
    margin-top: 10px;
    padding: 6px 14px;
    background: #fff;
    color: #2563eb;
    border: 1px solid #2563eb;
    border-radius: 6px;
    cursor: pointer;
    font-size: var(--fs-sm);
    font-weight: 500;
    transition: background 0.15s;
}

.chart-btn:hover {
    background: #eff6ff;
}

/* ── Chart area ── */
.chart-area {
    position: relative;
    padding: 16px 20px;
    border-top: 1px solid var(--line);
    max-height: 420px;
    flex-shrink: 0;
    background: #fafafa;
}

.chart-close {
    position: absolute;
    top: 10px;
    right: 14px;
    width: 28px;
    height: 28px;
    border: none;
    background: #fff;
    color: #999;
    font-size: 1.2em;
    line-height: 1;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: color 0.15s;
}

.chart-close:hover {
    color: #333;
}

.chart-controls {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    justify-content: center;
}

.chart-controls button {
    padding: 4px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    color: var(--muted);
    cursor: pointer;
    font-size: var(--fs-sm);
    transition: background 0.15s, color 0.15s;
}

.chart-controls button:hover {
    background: #f5f5f5;
    color: #1a1a1a;
}

/* ── Footer / input ── */
footer {
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    flex-shrink: 0;
    background: #fff;
}

footer form {
    display: flex;
    gap: 8px;
    align-items: center;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 4px 4px 4px 16px;
    transition: border-color 0.2s;
}

footer form:focus-within {
    border-color: #ccc;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.03);
}

footer input {
    flex: 1;
    padding: 10px 0;
    border: none;
    background: transparent;
    font-size: var(--fs-md);
    color: #1a1a1a;
    outline: none;
}

footer input::placeholder {
    color: #aaa;
}

footer button[type="submit"] {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}

footer button[type="submit"]:hover {
    background: #1d4ed8;
}

footer button[type="submit"]:disabled {
    background: #ddd;
    cursor: not-allowed;
}

/* ── Loading animation ── */
.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%  { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* ── Beta disclaimer ── */
.app-disclaimer {
    text-align: center;
    padding: 10px 16px;
    font-size: var(--fs-xs);
    color: #b8860b;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .message { max-width: 95%; }
    header { padding: 10px 14px; }
    footer { padding: 10px 14px; }
}

.password-hint {
    display: block;
    margin-top: 4px;
    color: #888;
    font-size: var(--fs-xs);
}

/* QA actions on the reviews list; item state cell */
.qa-actions { margin-top: 10px; display: flex; gap: 6px; align-items: center; }
.state-cell { color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }
/* Rework banner on the review workbench */
.rework-banner { background: #fef3c7; border: 1px solid #f59e0b; color: #92400e; padding: 10px 14px; margin: 8px 16px; border-radius: 6px; }
