/* ===================================
   CSS Variables & Reset
   =================================== */
:root {
    /* Core Palette - Darker & Richer */
    --bg-primary: #09090b;
    /* Zinc 950 */
    --bg-secondary: #121217;
    --bg-card: rgba(24, 24, 32, 0.7);
    --bg-card-hover: rgba(32, 32, 42, 0.8);

    /* Lavender & Purple Accents */
    --accent-primary: #8b5cf6;
    /* Violet 500 */
    --accent-secondary: #a78bfa;
    /* Violet 400 */
    --accent-glow: rgba(139, 92, 246, 0.15);
    --accent-glow-strong: rgba(139, 92, 246, 0.4);

    /* Status Colors */
    --color-safe: #10b981;
    --color-low: #3b82f6;
    --color-medium: #f59e0b;
    --color-high: #f97316;
    --color-critical: #ef4444;

    /* Text Colors */
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;

    /* Spacing & Radii */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --border-radius: 16px;
    --border-radius-sm: 8px;

    /* Font */
    --font-family: 'Inter', -apple-system, sans-serif;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-family);
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background Glow Effect */
.background-glow {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.08) 0%, transparent 40%);
    pointer-events: none;
    z-index: -1;
    animation: pulseGlow 8s infinite alternate;
}

@keyframes pulseGlow {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    100% {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* ===================================
   Navigation
   =================================== */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1.5rem;
    z-index: 100;
    background: linear-gradient(to bottom, var(--bg-primary), transparent);
}

.nav-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-status {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--color-safe);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--color-safe);
    animation: blink 2s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ===================================
   Main Layout
   =================================== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 8rem 1.5rem 4rem;
}

.hero {
    text-align: center;
    margin-bottom: 4rem;
}

.hero-badge {
    display: inline-block;
    padding: 0.25rem 1rem;
    border-radius: 99px;
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: 1.5rem;
    letter-spacing: -0.02em;
}

.gradient-text {
    background: linear-gradient(135deg, var(--accent-secondary) 0%, var(--accent-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-text {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* ===================================
   Cards & Input
   =================================== */
.card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--border-radius);
    padding: 2rem;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.input-card {
    margin-bottom: 2rem;
}

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

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.character-count {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.input-wrapper {
    position: relative;
    margin-bottom: 1.5rem;
    border-radius: var(--border-radius-sm);
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

textarea {
    width: 100%;
    min-height: 200px;
    background: transparent;
    border: none;
    padding: 1.5rem;
    color: var(--text-primary);
    font-size: 1rem;
    resize: vertical;
    outline: none;
    line-height: 1.6;
}

.input-actions {
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem;
}

.btn {
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #7c3aed);
    color: white;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    box-shadow: 0 4px 12px var(--accent-glow-strong);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--accent-glow-strong);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: wait;
    transform: none;
}

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

.btn-ghost:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.btn-outline {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-outline:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.analyze-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.disclaimer {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===================================
   Results Section
   =================================== */
.results-container {
    animation: slideUp 0.4s ease-out;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 1.5rem;
}

.timestamp-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.risk-badge .badge {
    padding: 0.5rem 1.25rem;
    border-radius: 99px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.875rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.badge-safe {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-safe);
    border: 1px solid var(--color-safe);
}

.badge-low {
    background: rgba(59, 130, 246, 0.15);
    color: var(--color-low);
    border: 1px solid var(--color-low);
}

.badge-medium {
    background: rgba(245, 158, 11, 0.15);
    color: var(--color-medium);
    border: 1px solid var(--color-medium);
}

.badge-high {
    background: rgba(249, 115, 22, 0.15);
    color: var(--color-high);
    border: 1px solid var(--color-high);
}

.badge-critical {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-critical);
    border: 1px solid var(--color-critical);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

.score-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.score-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.score-value-large {
    font-size: 2.5rem;
    font-weight: 300;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-primary);
    border-radius: 3px;
    transition: width 1s ease-out;
}

.summary-box {
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-size: 0.9375rem;
    white-space: pre-wrap;
    border-left: 3px solid var(--accent-primary);
}

/* Categories Grid */
.categories-section {
    margin-top: 2rem;
}

.section-heading {
    font-size: 1.125rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.category-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--border-radius-sm);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: 0.2s;
}

.category-card:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-2px);
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.cat-name {
    font-weight: 600;
    color: var(--text-primary);
}

.cat-severity {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.cat-description {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.cat-match {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    color: var(--accent-secondary);
    font-family: monospace;
}

/* Resources */
.resources-section {
    margin-top: 2rem;
}

.resources-card {
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--border-radius);
    padding: 1.5rem;
}

.resources-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    color: var(--color-critical);
}

.resource-item {
    margin-bottom: 0.75rem;
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.resource-item strong {
    color: var(--text-primary);
}

/* Raw JSON */
.raw-data-toggle {
    margin-top: 2rem;
    text-align: center;
}

.raw-json-box {
    text-align: left;
    background: #000;
    padding: 1.5rem;
    border-radius: var(--border-radius-sm);
    margin-top: 1rem;
    font-family: monospace;
    font-size: 0.8125rem;
    color: #4ade80;
    overflow-x: auto;
    border: 1px solid #333;
}

.hidden {
    display: none;
}

/* Utilities */
.text-critical {
    color: var(--color-critical);
}

.text-high {
    color: var(--color-high);
}

.text-medium {
    color: var(--color-medium);
}

.text-safe {
    color: var(--color-safe);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

@media (max-width: 600px) {
    .hero-title {
        font-size: 2.5rem;
    }

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

    .card {
        padding: 1.5rem;
    }
}

/* Loading Spinner */
.btn-loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
    display: none;
}

.btn.loading .btn-text {
    display: none;
}

.btn.loading .btn-loader {
    display: block;
}

.btn.loading {
    pointer-events: none;
    opacity: 0.8;
}

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

/* ===================================
   Footer
   =================================== */
.footer {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding: 3rem 1.5rem;
    margin-top: 4rem;
    background: rgba(0, 0, 0, 0.2);
    text-align: center;
}

.footer-container {
    max-width: 900px;
    margin: 0 auto;
}

.footer-disclaimer {
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.6;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    opacity: 0.8;
}

.footer-disclaimer strong {
    color: var(--text-secondary);
}

/* ===================================
   Metrics Guide
   =================================== */
.metrics-guide {
    display: block;
    /* Ensure block display */
    background: rgba(255, 255, 255, 0.08);
    /* Even brighter bg */
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--border-radius-sm);
    padding: 1rem 1.25rem;
    margin-bottom: 2rem;
    font-size: 0.875rem;
    opacity: 1;
    /* Force opacity */
    visibility: visible;
    /* Force visibility */
}

.guide-title {
    color: var(--text-primary);
    font-size: 0.9375rem;
    margin-bottom: 0.75rem;
    font-weight: 700;
}

.guide-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.guide-list li {
    color: #e4e4e7;
    /* Zinc 200 - Explicitly bright */
    line-height: 1.5;
}

.guide-label {
    color: var(--accent-secondary);
    font-weight: 600;
}

.guide-list strong {
    color: var(--text-primary);
}