/* ====================================================================
   CodePulse -- Dark-theme design system
   ==================================================================== */

:root {
    --bg: #0d1117;
    --bg-alt: #0a0e14;
    --surface: #161b22;
    --surface-hover: #1c2129;
    --surface-raised: #1e242c;
    --border: #30363d;
    --border-light: #21262d;
    --text: #c9d1d9;
    --text-muted: #8b949e;
    --text-bright: #f0f6fc;
    --accent: #58a6ff;
    --accent-hover: #79b8ff;
    --accent-dim: rgba(88, 166, 255, 0.15);
    --green: #3fb950;
    --green-dim: rgba(63, 185, 80, 0.15);
    --yellow: #d29922;
    --yellow-dim: rgba(210, 153, 34, 0.15);
    --orange: #db6d28;
    --orange-dim: rgba(219, 109, 40, 0.15);
    --red: #f85149;
    --red-dim: rgba(248, 81, 73, 0.15);
    --purple: #bc8cff;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4);
    --transition: 0.2s ease;
}

/* ── Reset ─────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-family);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }
code { font-family: var(--font-mono); font-size: 0.88em; }

/* ── Layout ────────────────────────────────────────────────────────── */

.container { max-width: 1140px; margin: 0 auto; padding: 0 1.5rem; width: 100%; }
.main-content { flex: 1; padding: 2rem 0; }

/* ── Navbar ────────────────────────────────────────────────────────── */

.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
    position: sticky; top: 0; z-index: 100;
    backdrop-filter: blur(8px);
}
.nav-container {
    max-width: 1140px; margin: 0 auto; padding: 0 1.5rem;
    display: flex; align-items: center; justify-content: space-between;
}
.nav-logo {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 1.25rem; font-weight: 700; color: var(--text-bright);
}
.logo-icon { font-size: 1.5rem; color: var(--accent); }
.nav-links { display: flex; gap: 1.5rem; }
.nav-link {
    color: var(--text-muted); font-weight: 500; font-size: 0.95rem;
    transition: color var(--transition); padding: 0.25rem 0;
    border-bottom: 2px solid transparent;
}
.nav-link:hover { color: var(--text-bright); border-bottom-color: var(--accent); }
.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 0.5rem; }
.nav-toggle span {
    display: block; width: 20px; height: 2px; background: var(--text);
    margin: 4px 0; transition: var(--transition);
}

/* ── Hero ──────────────────────────────────────────────────────────── */

.hero { text-align: center; margin-bottom: 2.5rem; padding: 1rem 0; }
.hero h1 {
    font-size: 2.5rem; font-weight: 700; color: var(--text-bright);
    background: linear-gradient(135deg, var(--accent), var(--purple));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero-subtitle { color: var(--text-muted); margin-top: 0.75rem; font-size: 1.1rem; max-width: 600px; margin-left: auto; margin-right: auto; }
.hero-actions { margin-top: 1.5rem; display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

.section-title { font-size: 1.25rem; font-weight: 700; color: var(--text-bright); margin-bottom: 1rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }

.page-header { margin-bottom: 2rem; }
.page-header h1 { font-size: 1.75rem; font-weight: 700; color: var(--text-bright); }
.page-header p { color: var(--text-muted); margin-top: 0.25rem; }
.page-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ── Code Input ────────────────────────────────────────────────────── */

.code-input-panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
}
.panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
    background: var(--surface-raised); flex-wrap: wrap; gap: 0.5rem;
}
.panel-header h2 { font-size: 1rem; font-weight: 600; color: var(--text-bright); }
.panel-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.filename-input {
    background: var(--bg); color: var(--text); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 0.4rem 0.75rem; font-size: 0.85rem;
    font-family: var(--font-mono); width: 160px; transition: border-color var(--transition);
}
.filename-input:focus { outline: none; border-color: var(--accent); }

.editor-container { min-height: 340px; }
.code-textarea {
    width: 100%; min-height: 340px; padding: 1rem;
    background: var(--bg-alt); color: var(--text); border: none;
    font-family: var(--font-mono); font-size: 0.9rem; line-height: 1.6;
    resize: vertical; tab-size: 4;
}
.code-textarea:focus { outline: none; }

/* CodeMirror overrides */
.CodeMirror { height: 340px; font-size: 0.9rem; font-family: var(--font-mono); }

/* ── Buttons ───────────────────────────────────────────────────────── */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
    padding: 0.5rem 1.15rem; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 0.875rem; font-weight: 500;
    cursor: pointer; transition: all var(--transition); font-family: var(--font-family);
    text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); }
.btn-secondary:hover { background: var(--surface-hover); color: var(--text-bright); }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.btn-lg { padding: 0.65rem 1.5rem; font-size: 1rem; }
.btn-icon { font-size: 0.8em; }

/* ── Loading ───────────────────────────────────────────────────────── */

.loading-indicator { text-align: center; padding: 2.5rem; color: var(--text-muted); }
.spinner {
    width: 40px; height: 40px; border: 3px solid var(--border);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin 0.8s linear infinite; margin: 0 auto 0.75rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Results ───────────────────────────────────────────────────────── */

.results-section { margin-top: 1rem; }
.results-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.5rem;
}
.results-header h2 { font-size: 1.35rem; font-weight: 700; color: var(--text-bright); }

/* ── Grade Badge ───────────────────────────────────────────────────── */

.grade-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 50%;
    font-size: 1rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.grade-sm { width: 28px; height: 28px; font-size: 0.8rem; }
.grade-lg { width: 56px; height: 56px; font-size: 1.75rem; }
.grade-a { background: var(--green); }
.grade-b { background: var(--accent); }
.grade-c { background: var(--yellow); }
.grade-d { background: var(--orange); }
.grade-f { background: var(--red); }

/* ── Stats Grid ────────────────────────────────────────────────────── */

.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem; margin-bottom: 2rem;
}
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem;
    text-align: center; display: flex; flex-direction: column; gap: 0.25rem;
    transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--accent); }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--text-bright); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Metric cards ──────────────────────────────────────────────────── */

.metrics-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 2rem; }
.metric-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem;
}
.metric-card h3 { font-size: 1rem; font-weight: 600; color: var(--text-bright); margin-bottom: 1rem; }
.metric-list { display: flex; flex-direction: column; gap: 0.5rem; }
.metric-item {
    display: flex; justify-content: space-between; padding: 0.4rem 0;
    border-bottom: 1px solid var(--border-light); font-size: 0.9rem;
}
.metric-label { color: var(--text-muted); }
.metric-val { color: var(--text-bright); font-weight: 500; font-family: var(--font-mono); }

/* ── Detail Panels ─────────────────────────────────────────────────── */

.detail-panels { display: grid; grid-template-columns: 1fr; gap: 1.5rem; margin-bottom: 2rem; }
.detail-panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem;
}
.detail-panel h3 {
    font-size: 1rem; font-weight: 600; color: var(--text-bright);
    margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem;
}

/* ── Smells ────────────────────────────────────────────────────────── */

.smells-list { display: flex; flex-direction: column; gap: 0.5rem; }
.smell-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.6rem 0.85rem; background: var(--bg);
    border-radius: var(--radius-sm); font-size: 0.9rem; flex-wrap: wrap;
    border-left: 3px solid var(--border);
}
.smell-message { flex: 1; color: var(--text); min-width: 200px; }
.smell-line { color: var(--text-muted); font-size: 0.8rem; font-family: var(--font-mono); }
.smell-type-tag {
    font-size: 0.7rem; padding: 0.1rem 0.4rem; border-radius: 3px;
    background: var(--accent-dim); color: var(--accent); font-family: var(--font-mono);
}

/* ── Badges ────────────────────────────────────────────────────────── */

.badge {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.1rem 0.5rem; border-radius: 10px;
    font-size: 0.75rem; font-weight: 600; background: var(--border); color: var(--text);
}
.severity-badge {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.15rem 0.5rem; border-radius: 10px;
    font-size: 0.7rem; font-weight: 600; text-transform: uppercase; flex-shrink: 0;
}
.severity-warning { background: var(--yellow-dim); color: var(--yellow); }
.severity-error { background: var(--red-dim); color: var(--red); }
.severity-info { background: var(--accent-dim); color: var(--accent); }

/* ── Text colors ───────────────────────────────────────────────────── */

.text-green { color: var(--green); }
.text-yellow { color: var(--yellow); }
.text-red { color: var(--red); }
.complexity-val { font-weight: 600; font-family: var(--font-mono); }

/* ── Tables ────────────────────────────────────────────────────────── */

.table-container { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td {
    padding: 0.6rem 0.75rem; text-align: left;
    border-bottom: 1px solid var(--border-light);
}
.data-table th {
    font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.06em;
    background: var(--surface-raised);
}
.data-table td { color: var(--text); }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--surface-hover); }
.data-table code { color: var(--accent); font-size: 0.85rem; }

/* ── Charts ────────────────────────────────────────────────────────── */

.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 2rem; }
.chart-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem;
}
.chart-card h3 { font-size: 1rem; font-weight: 600; color: var(--text-bright); margin-bottom: 1rem; }
.chart-card canvas { max-width: 100%; }

/* ── Dashboard ─────────────────────────────────────────────────────── */

.dashboard-stats { margin-bottom: 2rem; }
.dashboard-recent { margin-bottom: 2rem; }

/* ── About page ────────────────────────────────────────────────────── */

.about-content { max-width: 900px; }
.about-section { margin-bottom: 2.5rem; }
.about-section h2 { font-size: 1.35rem; font-weight: 700; color: var(--text-bright); margin-bottom: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
.about-section p { color: var(--text); line-height: 1.8; margin-bottom: 0.75rem; }

.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.feature-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem;
}
.feature-card h3 { font-size: 1rem; font-weight: 600; color: var(--text-bright); margin-bottom: 0.5rem; }
.feature-card p { font-size: 0.9rem; color: var(--text-muted); line-height: 1.6; }

.grade-scale { display: flex; flex-direction: column; gap: 0.75rem; }
.grade-item { display: flex; align-items: center; gap: 1rem; font-size: 0.95rem; }

.api-docs { display: flex; flex-direction: column; gap: 0.5rem; }
.api-endpoint {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.85rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 0.9rem;
}
.api-method {
    padding: 0.15rem 0.5rem; border-radius: 3px; font-size: 0.7rem;
    font-weight: 700; text-transform: uppercase; flex-shrink: 0;
}
.api-method.get { background: var(--green-dim); color: var(--green); }
.api-method.post { background: var(--accent-dim); color: var(--accent); }
.api-method.delete { background: var(--red-dim); color: var(--red); }
.api-desc { color: var(--text-muted); font-size: 0.85rem; }

.tech-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tech-tag {
    padding: 0.35rem 0.8rem; background: var(--surface); border: 1px solid var(--border);
    border-radius: 20px; font-size: 0.85rem; color: var(--text);
}

/* ── Empty state ───────────────────────────────────────────────────── */

.empty-state { color: var(--text-muted); text-align: center; padding: 1.5rem; }
.empty-state-container { padding: 4rem 1rem; text-align: center; }
.empty-state-container h3 { color: var(--text-bright); margin-bottom: 0.5rem; }
.empty-state-container p { color: var(--text-muted); margin-bottom: 1.5rem; }
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; }
.error-banner {
    background: var(--red-dim); border: 1px solid var(--red);
    border-radius: var(--radius); padding: 1rem; margin-bottom: 1.5rem;
    color: var(--red);
}

.action-bar { display: flex; gap: 1rem; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }

/* ── Footer ────────────────────────────────────────────────────────── */

.footer {
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 1.25rem 0; text-align: center; color: var(--text-muted);
    font-size: 0.85rem;
}

/* ── Responsive ────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .hero h1 { font-size: 1.75rem; }
    .panel-header { flex-direction: column; align-items: flex-start; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .metrics-row { grid-template-columns: 1fr; }
    .chart-row { grid-template-columns: 1fr; }
    .feature-grid { grid-template-columns: 1fr; }
    .nav-links { display: none; }
    .nav-toggle { display: block; }
    .nav-links.active { display: flex; flex-direction: column; position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: 1rem 1.5rem; gap: 0.75rem; }
    .page-header-row { flex-direction: column; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .hero h1 { font-size: 1.4rem; }
    .container { padding: 0 1rem; }
}
