:root {
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --card-bg-light: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --border-color: #e2e8f0;
    --border: #e2e8f0;
    --success: #059669;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Navbar */
.navbar {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.navbar-content {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.nav-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

header {
    text-align: left;
    margin-bottom: 2rem;
}

h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

header p {
    color: var(--text-secondary);
    font-size: 1.15rem;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
}

#analysis-form {
    margin-bottom: 0;
    padding-bottom: 0;
}

h2 {
    margin-top: 0;
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.config-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.config-card h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.15rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
}

/* Form Styles */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

select,
input[type="number"],
input[type="text"] {
    background-color: #ffffff;
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: var(--font-family);
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

select:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
}

.radio-group {
    display: flex;
    gap: 1rem;
    background-color: #ffffff;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 400;
    color: var(--text-primary);
}

.badge {
    background-color: var(--card-bg-light);
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--border);
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-top: 1rem;
}

.btn {
    display: inline-block;
    background: var(--accent);
    color: white;
    font-weight: 500;
    padding: 0.7rem 1.8rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.4);
}

.error-msg {
    background-color: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.3);
    color: #fca5a5;
    padding: 1rem;
    border-radius: 8px;
}

/* HTMX Loading Indicator */
.htmx-indicator {
    display: none;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.htmx-request .htmx-indicator {
    display: flex;
}

.htmx-request .btn-text {
    opacity: 0.5;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 1s ease-in-out infinite;
}

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

/* Results Component Styles */
.empty-metrics {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 250px;
    background-color: var(--card-bg-light);
    border: 1px dashed var(--border);
    border-top: none;
    border-radius: 0 0 12px 12px;
    padding: 2rem;
}

.empty-content {
    text-align: center;
    color: var(--text-secondary);
}

.empty-content .icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    display: block;
    opacity: 0.4;
    font-weight: bold;
}

.metrics-grid {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.metrics-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: auto;
}

.dataset-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}

.tag {
    background-color: var(--card-bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.tag-blue {
    background-color: #e0e7ff;
    color: #4338ca;
    border-color: #c7d2fe;
}

.stat-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.stat-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.minor-row {
    opacity: 0.7;
    font-size: 0.8em;
}

.stat-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.stat-value.good {
    color: var(--success);
}

.stat-value.warning {
    color: var(--warning);
}

/* Bivariate Card integration into column grid */
.bivariate-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--accent);
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.1);
    display: flex;
    flex-direction: column;
}

.bivariate-header h3 {
    margin: 0 0 0.25rem 0;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.bivariate-header p {
    margin: 0 0 1rem 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.bivariate-stats {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.biv-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg-light);
    border-radius: 6px;
    padding: 0.75rem;
    border: 1px solid var(--border);
}

.biv-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-width: 60%;
}

.biv-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin: 0;
}

.biv-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: ui-monospace, monospace;
    margin: 0;
}

.biv-sub {
    font-size: 0.75rem;
    color: var(--accent);
    line-height: 1.3;
}

/* Tooltip basic implementation for stats */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    background-color: var(--text-primary);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    width: max-content;
    max-width: 250px;
    z-index: 10;
    border: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.tooltip.tooltip-right:hover::after {
    left: auto;
    right: 0;
    transform: none;
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--card-bg);
    width: 95%;
    max-width: 1200px;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--text-primary);
}

.ablation-trigger {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.2rem 0.6rem;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--accent);
    margin-left: auto;
    transition: all 0.2s;
}

.ablation-trigger:hover {
    background: var(--accent);
    color: white;
}

/* Responsive Layout Breakpoints */
@media (max-width: 1200px) {
    .results-grid {
        grid-template-columns: 1fr;
    }

    .config-grid {
        grid-template-columns: 1fr;
    }

    .dual-metric-container {
        flex-direction: column;
    }
}