/* ==============================
   Codebase Health Scorer — Styles
   Dark engineering dashboard
   ============================== */

:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
    --color-bg: #0B0E14;
    --color-surface: #141820;
    --color-surface-2: #1C2130;
    --color-border: rgba(108, 99, 255, 0.12);
    --color-border-hover: rgba(108, 99, 255, 0.3);
    --color-primary: #6C63FF;
    --color-primary-glow: rgba(108, 99, 255, 0.2);
    --color-green: #4ADE80;
    --color-green-dim: rgba(74, 222, 128, 0.15);
    --color-amber: #FBBF24;
    --color-amber-dim: rgba(251, 191, 36, 0.15);
    --color-red: #F87171;
    --color-red-dim: rgba(248, 113, 113, 0.15);
    --color-text: #E2E8F0;
    --color-text-muted: #8B95A8;
    --color-text-dim: #556070;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
    --transition: 0.25s ease;
}

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

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

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    background-image:
        radial-gradient(ellipse at 15% 0%, rgba(74, 222, 128, 0.06) 0%, transparent 40%),
        radial-gradient(ellipse at 85% 100%, rgba(108, 99, 255, 0.06) 0%, transparent 40%);
}

/* Header */
.header {
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--color-border);
    backdrop-filter: blur(12px);
    background: rgba(11, 14, 20, 0.8);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-green-dim);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

.logo-text {
    font-size: 1.15rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-green), var(--color-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-tagline {
    font-size: .8rem;
    color: var(--color-text-muted);
}

/* Main */
.main {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 2rem 3rem;
    width: 100%;
}

/* Cards */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    animation: fadeIn .5s ease backwards;
}

.section-title {
    font-size: .9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-text-muted);
    margin-bottom: 1.25rem;
}

/* Form */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.form-group--full {
    margin-bottom: 1.25rem;
}

.form-group label {
    font-size: .8rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.form-group label code {
    font-family: var(--font-mono);
    font-size: .75rem;
    background: var(--color-surface-2);
    padding: .1rem .3rem;
    border-radius: 4px;
}

.form-group input,
.form-group select,
.code-textarea {
    padding: .6rem .85rem;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: .85rem;
    outline: none;
    transition: border-color var(--transition);
}

.code-textarea {
    font-family: var(--font-mono);
    font-size: .8rem;
    resize: vertical;
    line-height: 1.5;
    width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.code-textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

.form-group select {
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s ease;
    white-space: nowrap;
}

.btn--primary {
    background: linear-gradient(135deg, var(--color-primary), #8B83FF);
    color: #fff;
    padding: .7rem 1.25rem;
    font-weight: 600;
    box-shadow: 0 4px 16px var(--color-primary-glow);
}

.btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px var(--color-primary-glow);
}

.btn--primary:active {
    transform: translateY(0);
}

.btn--ghost {
    background: transparent;
    color: var(--color-text-muted);
    padding: .5rem .85rem;
}

.btn--ghost:hover {
    background: rgba(108, 99, 255, .1);
    color: var(--color-text);
}

/* Score Hero */
.score-hero {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 2rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    animation: fadeIn .5s ease backwards;
}

.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 4px solid var(--color-green);
    background: var(--color-green-dim);
    flex-shrink: 0;
    transition: border-color .5s ease, background .5s ease;
}

.score-number {
    font-size: 2.5rem;
    font-weight: 800;
    font-family: var(--font-mono);
    line-height: 1;
}

.score-grade {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-green);
}

.score-meta h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.score-subtitle {
    color: var(--color-text-muted);
    font-size: .9rem;
}

/* Gauges Grid */
.gauges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.gauge-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    animation: fadeIn .4s ease backwards;
}

.gauge-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .5rem;
}

.gauge-name {
    font-size: .8rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.gauge-score {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1rem;
}

.gauge-bar {
    height: 6px;
    background: var(--color-surface-2);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: .5rem;
}

.gauge-fill {
    height: 100%;
    border-radius: 999px;
    transition: width .8s cubic-bezier(.16, 1, .3, 1);
}

.gauge-desc {
    font-size: .75rem;
    color: var(--color-text-dim);
    line-height: 1.4;
}

/* Chart */
.card--chart {
    text-align: center;
}

.chart-container {
    max-width: 420px;
    margin: 0 auto;
}

.chart-container canvas {
    width: 100% !important;
    height: auto !important;
}

/* Tree Analysis */
.tree-analysis {
    font-family: var(--font-mono);
    font-size: .8rem;
}

.tree-stat {
    display: flex;
    justify-content: space-between;
    padding: .4rem 0;
    border-bottom: 1px solid var(--color-border);
}

.tree-stat:last-child {
    border-bottom: none;
}

/* Recommendations */
.recommendations {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.rec-item {
    display: flex;
    gap: .75rem;
    padding: .85rem 1rem;
    background: var(--color-surface-2);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-primary);
}

.rec-priority {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: .15rem .5rem;
    border-radius: 4px;
    flex-shrink: 0;
    height: fit-content;
}

.rec-priority--high {
    background: var(--color-red-dim);
    color: var(--color-red);
}

.rec-priority--med {
    background: var(--color-amber-dim);
    color: var(--color-amber);
}

.rec-priority--low {
    background: var(--color-green-dim);
    color: var(--color-green);
}

.rec-text {
    font-size: .85rem;
}

/* Comparison Bars */
.comparison-bars {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.comp-row {
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.comp-label {
    font-size: .75rem;
    color: var(--color-text-muted);
    display: flex;
    justify-content: space-between;
}

.comp-bar-track {
    height: 8px;
    background: var(--color-surface-2);
    border-radius: 999px;
    position: relative;
    overflow: hidden;
}

.comp-bar-yours {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--color-primary);
    border-radius: 999px;
    transition: width .8s cubic-bezier(.16, 1, .3, 1);
}

.comp-bar-typical {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255, 255, 255, .1);
    border-radius: 999px;
    border-right: 2px dashed var(--color-text-dim);
}

/* Trend */
.trend-container canvas {
    width: 100% !important;
    height: auto !important;
}

.trend-actions {
    display: flex;
    gap: .5rem;
    margin-top: 1rem;
}

/* Export */
.export-bar {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    padding: .75rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: .85rem;
    font-weight: 500;
    box-shadow: var(--shadow-card);
    opacity: 0;
    pointer-events: none;
    transition: all .4s cubic-bezier(.16, 1, .3, 1);
    z-index: 100;
}

.toast.toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.toast--success {
    border-color: rgba(74, 222, 128, .3);
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--color-border);
    color: var(--color-text-dim);
    font-size: .8rem;
}

/* Responsive */
@media (max-width:768px) {
    .header {
        padding: 1rem;
    }

    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: .25rem;
    }

    .main {
        padding: 1rem 1rem 2rem;
    }

    .score-hero {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
        padding: 1.5rem;
    }

    .score-circle {
        width: 100px;
        height: 100px;
    }

    .score-number {
        font-size: 2rem;
    }

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

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}