/* ══════════════════════════════════════════════════════════════
   Codebase Stats Dashboard — Premium Dark Mode Styles
   Primary #8B5CF6, Accent #06B6D4, BG #0F172A
   ══════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
    --primary: #8B5CF6;
    --primary-light: #A78BFA;
    --primary-dim: rgba(139, 92, 246, 0.15);
    --accent: #06B6D4;
    --accent-light: #22D3EE;
    --accent-dim: rgba(6, 182, 212, 0.15);
    --green: #10B981;
    --green-dim: rgba(16, 185, 129, 0.15);
    --red: #EF4444;
    --red-dim: rgba(239, 68, 68, 0.15);
    --orange: #F59E0B;
    --orange-dim: rgba(245, 158, 11, 0.15);
    --bg: #0F172A;
    --bg-card: rgba(30, 41, 59, 0.6);
    --bg-input: rgba(15, 23, 42, 0.8);
    --border: rgba(139, 92, 246, 0.12);
    --border-focus: rgba(139, 92, 246, 0.5);
    --text: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-dim: #64748B;
    --glass: rgba(255, 255, 255, 0.04);
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 15% 15%, rgba(139, 92, 246, 0.07) 0%, transparent 50%),
        radial-gradient(ellipse at 85% 85%, rgba(6, 182, 212, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

.app {
    position: relative;
    z-index: 1;
    max-width: 1360px;
    margin: 0 auto;
    padding: 20px;
}

/* ── Header ── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.header__brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header__icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3);
}

.header__title {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header__subtitle {
    font-size: 13px;
    color: var(--text-dim);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn--primary {
    background: linear-gradient(135deg, var(--primary), #7C3AED);
    color: #fff;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}

.btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35);
}

.btn--secondary {
    background: var(--glass);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn--secondary:hover {
    border-color: var(--primary);
    background: var(--bg-card);
}

.btn--small {
    padding: 6px 14px;
    font-size: 12px;
}

/* ── Input Zone ── */
.input-zone {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
    backdrop-filter: blur(16px);
    text-align: center;
}

.input-zone__title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
}

.input-zone__desc {
    font-size: 14px;
    color: var(--text-dim);
    margin-bottom: 20px;
}

.input-zone__row {
    display: flex;
    gap: 10px;
    max-width: 600px;
    margin: 0 auto 16px;
}

.input-zone__row input {
    flex: 1;
    padding: 11px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    transition: var(--transition);
}

.input-zone__row input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

.input-zone__row input::placeholder {
    color: var(--text-dim);
}

.input-zone__divider {
    color: var(--text-dim);
    font-size: 13px;
    margin-bottom: 16px;
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px;
    margin: 0 auto;
    max-width: 500px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-dim);
}

.drop-zone:hover,
.drop-zone--active {
    border-color: var(--primary);
    color: var(--primary-light);
}

.drop-zone__icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.drop-zone__text {
    font-size: 14px;
}

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    backdrop-filter: blur(8px);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.stat-card--purple::before {
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.stat-card--cyan::before {
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
}

.stat-card--green::before {
    background: linear-gradient(90deg, var(--green), #34D399);
}

.stat-card--orange::before {
    background: linear-gradient(90deg, var(--orange), #FBBF24);
}

.stat-card--red::before {
    background: linear-gradient(90deg, var(--red), #F87171);
}

.stat-card__label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.stat-card__value {
    font-size: 26px;
    font-weight: 800;
}

.stat-card--purple .stat-card__value {
    color: var(--primary-light);
}

.stat-card--cyan .stat-card__value {
    color: var(--accent-light);
}

.stat-card--green .stat-card__value {
    color: var(--green);
}

.stat-card--orange .stat-card__value {
    color: var(--orange);
}

.stat-card--red .stat-card__value {
    color: var(--red);
}

/* ── Chart Panels ── */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.chart-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    backdrop-filter: blur(8px);
}

.chart-panel--full {
    grid-column: 1 / -1;
}

.chart-panel__title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-panel canvas {
    width: 100%;
    height: 220px;
}

.chart-panel--tall canvas {
    height: 300px;
}

/* ── Legend ── */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.legend__item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.legend__dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* ── File Ranking Table ── */
.ranking-table {
    width: 100%;
    border-collapse: collapse;
}

.ranking-table th {
    text-align: left;
    padding: 8px 10px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
}

.ranking-table td {
    padding: 8px 10px;
    font-size: 13px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.06);
}

.ranking-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.ranking-table .file-path {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--accent-light);
}

.ranking-table .file-lang {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
}

/* ── Tech Debt ── */
.debt-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.06);
    font-size: 13px;
}

.debt-item__file {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-secondary);
}

.debt-item__count {
    background: var(--red-dim);
    color: var(--red);
    padding: 2px 10px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 12px;
}

/* ── Loading ── */
.loading {
    text-align: center;
    padding: 60px;
    color: var(--text-dim);
}

.loading__spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.8s linear infinite;
}

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

/* ── Hidden / Visible ── */
.hidden {
    display: none !important;
}

/* ── Toast ── */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    box-shadow: var(--shadow);
}

.toast--success {
    background: rgba(16, 185, 129, 0.9);
}

.toast--error {
    background: rgba(239, 68, 68, 0.9);
}

@keyframes toastIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes toastOut {
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

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

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

    .input-zone__row {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .app {
        padding: 12px;
    }

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

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}