/* ============================================
   LINEAR REGRESSION - STANDALONE STYLES
   ============================================ */

/* Theme Variables */
:root,
[data-theme="dark"] {
    /* Colors - Dark Theme */
    --bg-primary: #09090b;
    --bg-secondary: #18181b;
    --bg-card: #1c1c21;
    --bg-hover: #27272a;
    --text-primary: #fafafa;
    --text-secondary: #e4e4e7;
    --text-muted: #a1a1aa;
    --border-color: #27272a;
    --border-hover: #3f3f46;

    /* Accent Colors */
    --accent-it: #3b82f6;
    --accent-educational: #22c55e;
    --accent-calc: #f59e0b;
    --accent-data: #8b5cf6;
    --accent-error: #ef4444;
    --accent-warning: #f97316;
    --accent-success: #22c55e;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
}

[data-theme="light"] {
    /* Colors - Light Theme */
    --bg-primary: #fafafa;
    --bg-secondary: #f4f4f5;
    --bg-card: #ffffff;
    --bg-hover: #e4e4e7;
    --text-primary: #18181b;
    --text-secondary: #27272a;
    --text-muted: #71717a;
    --border-color: #d4d4d8;
    --border-hover: #a1a1aa;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }

code, pre, .mono {
    font-family: 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
}

/* Links */
a {
    color: var(--accent-educational);
    text-decoration: none;
    transition: opacity 0.15s ease;
}

a:hover {
    opacity: 0.8;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

/* Header */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg) 0;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    gap: var(--space-xs);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 2px;
}

.theme-toggle button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.theme-toggle button:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.theme-toggle button[aria-pressed="true"] {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.theme-toggle button svg {
    width: 16px;
    height: 16px;
}

/* Tool Icon Header */
.tool-icon-header {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 10px;
}

.tool-icon-header.educational {
    background: rgba(34, 197, 94, 0.15);
    color: var(--accent-educational);
}

/* Tagline */
.tagline {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Buttons */
button {
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
}

.tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: all 0.15s ease;
}

.tool-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.tool-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Primary Button */
.btn-primary {
    background: var(--accent-educational);
    border-color: var(--accent-educational);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #16a34a;
    border-color: #16a34a;
    color: white;
}

/* Forms */
input, select, textarea {
    font-family: inherit;
    font-size: 0.875rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    padding: var(--space-sm) var(--space-md);
    transition: border-color 0.15s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-educational);
}

input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

/* Labels */
label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-sm);
}

/* Utility Classes */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

/* Spacing Utilities */
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

/* Main Content */
main {
    padding: var(--space-lg) 0;
    min-height: calc(100vh - 200px);
}

/* ============================================================
   LINEAR REGRESSION SPECIFIC STYLES
   ============================================================ */

/* File Drop Zone */
.file-drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-card);
}

.file-drop-zone:hover,
.file-drop-zone:focus-visible,
.file-drop-zone.drag-over {
    border-color: var(--accent-educational);
    background: rgba(34, 197, 94, 0.05);
}

.file-drop-zone.error {
    border-color: var(--accent-error);
    background: rgba(239, 68, 68, 0.05);
}

.file-drop-zone svg {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.file-drop-zone p {
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.file-drop-zone .formats {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
    font-family: 'JetBrains Mono', monospace;
}

/* Paste Area */
.paste-area {
    margin-top: 16px;
}

.paste-area textarea {
    width: 100%;
    min-height: 100px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    color: var(--text-primary);
    resize: vertical;
    outline: none;
    transition: border-color 0.15s ease;
}

.paste-area textarea:focus {
    border-color: var(--accent-educational);
}

/* Chart Containers */
.chart-container {
    margin-top: 24px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.chart-wrapper {
    position: relative;
    height: 350px;
}

.chart-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

/* Statistics Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.stat-card .value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--accent-educational);
}

.stat-card .label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

/* Equation Box */
.equation-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-top: 16px;
}

.equation-box .equation {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9375rem;
    color: var(--text-primary);
    word-break: break-all;
}

/* Column Selectors */
.column-selectors {
    margin-top: 16px;
}

.selector-group {
    margin-bottom: 16px;
}

.selector-group label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 8px;
}

.selector-group select,
.selector-group input {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s ease;
}

.selector-group select:focus,
.selector-group input:focus {
    border-color: var(--accent-educational);
}

/* Variable Checkboxes */
.variable-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px;
}

.variable-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.variable-checkbox:hover {
    background: var(--bg-secondary);
}

.variable-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-educational);
}

.variable-checkbox span {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    color: var(--text-primary);
}

/* Data Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    margin-top: 16px;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-secondary);
}

.data-table td {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
}

.data-table tr:hover td {
    background: var(--bg-secondary);
}

.table-container {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 16px;
}

/* Coefficients Table */
.coefficients-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.coefficients-table th,
.coefficients-table td {
    padding: 10px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

.coefficients-table th:first-child,
.coefficients-table td:first-child {
    text-align: left;
    font-weight: 500;
}

.coefficients-table th {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.coefficients-table td {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
}

.coefficients-table .positive {
    color: var(--accent-success);
}

.coefficients-table .negative {
    color: var(--accent-error);
}

/* VIF Table */
.vif-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    margin-top: 16px;
}

.vif-table th,
.vif-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.vif-table th:first-child,
.vif-table td:first-child {
    text-align: left;
    font-weight: 500;
}

.vif-table th {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.vif-table td {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
}

.vif-table .success {
    color: var(--accent-success);
}

.vif-table .warning {
    color: var(--accent-warning);
}

.vif-table .error {
    color: var(--accent-error);
}

/* Export Buttons */
.export-buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.export-buttons .tool-btn {
    flex: 1;
    justify-content: center;
}

/* Section Headers */
.section-header {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 24px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

/* Disclaimer */
.disclaimer-warning {
    background: var(--bg-card);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-left: 3px solid rgba(239, 68, 68, 0.7);
    border-radius: 6px;
    padding: 12px;
    margin-top: 16px;
    font-size: 0.75rem;
    line-height: 1.5;
}

.disclaimer-warning .warning-title {
    color: #ef4444;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.disclaimer-warning p {
    margin: 0 0 6px 0;
    color: var(--text-secondary);
}

.disclaimer-warning p:last-child {
    margin-bottom: 0;
}

.disclaimer-warning strong {
    color: var(--text-primary);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 0.875rem;
    animation: slideIn 0.3s ease;
    max-width: 300px;
}

.toast.success {
    border-color: var(--accent-success);
}

.toast.error {
    border-color: var(--accent-error);
}

.toast.warning {
    border-color: var(--accent-warning);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--text-muted);
    border-top-color: var(--accent-educational);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: text-bottom;
}

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

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-actions {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.modal-actions .tool-btn {
    flex: 1;
    justify-content: center;
}

/* Sheet Preview */
.sheet-preview {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    max-height: 150px;
    overflow: auto;
}

/* Collapsible Section */
.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    padding: 12px 0;
}

.collapsible-header:hover {
    opacity: 0.8;
}

.collapsible-header .title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.collapsible-header .icon {
    transition: transform 0.2s ease;
}

.collapsible-header.collapsed .icon {
    transform: rotate(-90deg);
}

.collapsible-content {
    max-height: 4000px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.collapsible-content.collapsed {
    max-height: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .calculator-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        order: 2;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-wrapper {
        height: 250px;
    }

    .export-buttons {
        flex-direction: column;
    }
}

/* License Card */
.license-card {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.license-card h4 {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.license-card h4 svg {
    width: 14px;
    height: 14px;
}

.license-content {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.license-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.license-content li {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.license-content li:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.license-content a {
    color: var(--accent-educational);
    text-decoration: none;
    font-weight: 500;
}

.license-content a:hover {
    text-decoration: underline;
}

.license-content span {
    display: block;
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ============================================================
   Diagnostics Panel Styles
   ============================================================ */

.diagnostics-empty {
    padding: 20px;
    text-align: center;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px dashed var(--border-color);
}

.diagnostics-section {
    margin-bottom: 16px;
}

.diagnostics-section:last-child {
    margin-bottom: 0;
}

.diagnostics-section-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.diagnostics-section-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0 0 12px 0;
}

.diagnostic-test-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 10px;
    transition: border-color 0.15s ease;
}

.diagnostic-test-card:last-child {
    margin-bottom: 0;
}

.diagnostic-test-card.pass {
    border-left: 3px solid var(--accent-success);
}

.diagnostic-test-card.fail {
    border-left: 3px solid var(--accent-error);
}

.test-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.test-name {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.test-status {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}

.test-status.pass {
    color: var(--accent-success);
    background: rgba(34, 197, 94, 0.1);
}

.test-status.fail {
    color: var(--accent-error);
    background: rgba(239, 68, 68, 0.1);
}

.test-details {
    display: flex;
    gap: 16px;
    margin-bottom: 8px;
}

.test-stat,
.test-p-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.test-interpretation {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.test-guidance {
    margin-top: 8px;
    padding: 8px 10px;
    background: rgba(239, 68, 68, 0.08);
    border-left: 2px solid var(--accent-error);
    border-radius: 4px;
}

.test-guidance strong {
    color: var(--text-primary);
    font-weight: 600;
}
