/* VBM Visualizer - Clean, Natural Aesthetic */

:root {
    /* Warm, natural palette */
    --bg-canvas: #faf9f7;
    --bg-primary: #ffffff;
    --bg-secondary: #f5f4f2;
    --bg-tertiary: #efeee9;

    /* Text colors - warm grays */
    --text-primary: #1a1918;
    --text-secondary: #5c5a57;
    --text-muted: #8a8885;
    --text-subtle: #918f8b;

    /* Accent - warm terracotta/coral */
    --accent: #c4654a;
    --accent-hover: #b55a40;
    --accent-subtle: #f0e6e3;

    /* Borders */
    --border-light: #e8e6e1;
    --border-medium: #d4d1cb;

    /* Shadows - very subtle */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.05);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.06);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition: 200ms ease;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-canvas);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 880px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

/* Header */
.paper-header {
    text-align: center;
    margin-bottom: 2.5rem;
    padding: 2.5rem 2rem;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.paper-header h1 {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.paper-header .subtitle {
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

.paper-header .intro {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 560px;
    margin: 0 auto 1rem;
    line-height: 1.6;
}

.paper-header .data-note {
    font-size: 0.85rem;
    color: var(--text-subtle);
    letter-spacing: 0.01em;
}

.paper-header .data-note a {
    color: var(--accent);
    text-decoration: none;
    transition: var(--transition-fast);
}

.paper-header .data-note a:hover {
    color: var(--accent-hover);
}

/* Main Layout */
.main-content {
    display: block;
}

/* Results Section */
.results-section {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.results-section h2 {
    font-size: 0.8rem;
    font-weight: 500;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* Tables */
.table-container {
    padding: 1.5rem;
    overflow-x: auto;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.results-table th,
.results-table td {
    padding: 0.75rem 1rem;
    text-align: center;
}

.results-table thead tr:first-child th {
    border-bottom: none;
    padding-bottom: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.results-table thead tr:last-child th {
    border-bottom: 1px solid var(--border-medium);
    padding-top: 0.25rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.results-table tbody tr {
    transition: var(--transition-fast);
}

.results-table tbody tr:hover {
    background: var(--bg-secondary);
}

.results-table tbody tr:not(:last-child) td {
    border-bottom: 1px solid var(--border-light);
}

.results-table tbody tr:last-child td {
    border-top: 1px solid var(--border-medium);
    font-weight: 500;
    background: var(--bg-tertiary);
}

.results-table td:first-child {
    text-align: left;
    font-weight: 500;
    color: var(--text-secondary);
}

.results-table .coefficient {
    font-weight: 600;
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.results-table .coefficient.significant {
    color: var(--accent);
}

.results-table .std-error {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
}

.table-notes {
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-light);
}

/* Chat Interface */
.chat-container {
    border-top: 1px solid var(--border-light);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
}

.chat-icon {
    font-size: 1rem;
    opacity: 0.7;
}

.query-counter {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-subtle);
    background: var(--bg-primary);
    padding: 0.25rem 0.625rem;
    border-radius: 100px;
    border: 1px solid var(--border-light);
}

/* Example Buttons */
.chat-examples {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.5rem;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
}

.example-label {
    font-size: 0.75rem;
    color: var(--text-subtle);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-width: 52px;
}

.example-btn {
    font-size: 0.8rem;
    padding: 0.3rem 0.625rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 100px;
    cursor: pointer;
    color: var(--text-secondary);
    font-family: inherit;
    transition: var(--transition-fast);
    white-space: nowrap;
}

.example-btn:hover {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
    background: var(--bg-primary);
    min-height: 80px;
    max-height: 280px;
}

.chat-message {
    margin-bottom: 1rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    line-height: 1.55;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-message.user {
    background: var(--accent);
    color: white;
    margin-left: 25%;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    margin-right: 15%;
    border-bottom-left-radius: 4px;
    color: var(--text-secondary);
}

.chat-message .result-preview {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-left: 2px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
}

/* Loading spinner */
.chat-loading {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.chat-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Chat Input */
.chat-input-container {
    display: flex;
    padding: 1rem 1.5rem;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-light);
    gap: 0.625rem;
}

.chat-input {
    flex: 1;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: var(--transition-fast);
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.chat-input::placeholder {
    color: var(--text-subtle);
}

.chat-input:focus {
    border-color: var(--accent);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.chat-submit {
    padding: 0.625rem 1.25rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    transition: var(--transition-fast);
}

.chat-submit:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.chat-submit:active {
    transform: translateY(0);
}

.chat-submit:disabled {
    background: var(--border-medium);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(250, 249, 247, 0.95);
    z-index: 999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-bottom: 1rem;
}

.loading-overlay p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-subtle);
    font-size: 0.75rem;
}

footer em {
    font-style: normal;
}

/* Highlights */
.highlight-change {
    color: var(--accent);
    font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
    html { font-size: 12px; }
    .container { padding: 1.5rem 1rem; }
    .chat-examples { padding: 0.5rem 1rem; }
    .example-label { display: none; }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-subtle);
}

/* Selection */
::selection {
    background: var(--accent-subtle);
    color: var(--accent);
}

/* Coefficient Plot */
.coef-plot-section {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-light);
}

.coef-plot-section h3 {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.coef-plot {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.coef-plot-row {
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
    font-size: 0.85rem;
}

.coef-plot-row:not(:last-child) {
    border-bottom: 1px solid var(--border-light);
}

.coef-plot-label {
    width: 180px;
    flex-shrink: 0;
    color: var(--text-secondary);
    font-weight: 500;
}

.coef-plot-bar {
    flex: 1;
    position: relative;
    height: 24px;
}

.coef-plot-value {
    width: 100px;
    text-align: right;
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    padding-left: 1rem;
}

.coef-plot-value.significant {
    color: var(--accent);
    font-weight: 600;
}

/* SVG plot styling */
.coef-plot svg {
    width: 100%;
    height: auto;
    display: block;
}

.coef-point {
    fill: var(--accent);
}

.coef-point.not-significant {
    fill: var(--text-muted);
}

.coef-ci {
    stroke: var(--text-secondary);
    stroke-width: 2;
}

.coef-ci.not-significant {
    stroke: var(--text-muted);
}

.coef-zero-line {
    stroke: var(--border-medium);
    stroke-width: 1;
    stroke-dasharray: 4, 4;
}

.coef-axis-label {
    font-size: 0.7rem;
    fill: var(--text-muted);
}

.coef-row-label {
    font-size: 0.75rem;
    fill: var(--text-secondary);
}

.coef-plot-placeholder {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}
