/* Dark theme (default) */
:root {
    --bg-primary: #0a0c10;
    --bg-secondary: #111318;
    --bg-tertiary: #1a1d24;
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    --text-muted: #6b7280;
    --accent: #3b82f6;
    --accent-light: #60a5fa;
    --accent-rgb: 59, 130, 246;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --critical: #dc2626;
    --border: #2a2f3a;
    --gradient: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    --terminal-bg: #0f1318;
    --terminal-header: #1a1f28;
}

/* Light theme */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #2563eb;
    --accent-light: #3b82f6;
    --accent-rgb: 37, 99, 235;
    --border: #e2e8f0;
    --gradient: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    --terminal-bg: #1e293b;
    --terminal-header: #334155;
}

/* System preference detection (when no manual override) */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]):not([data-theme="light"]) {
        --bg-primary: #f8fafc;
        --bg-secondary: #ffffff;
        --bg-tertiary: #f1f5f9;
        --text-primary: #0f172a;
        --text-secondary: #475569;
        --text-muted: #94a3b8;
        --accent: #2563eb;
        --accent-light: #3b82f6;
        --accent-rgb: 37, 99, 235;
        --border: #e2e8f0;
        --gradient: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
        --terminal-bg: #1e293b;
        --terminal-header: #334155;
    }
}

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

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

h1, h2, h3, h4, h5, h6 {
    font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo svg {
    width: 40px;
    height: 40px;
    color: var(--accent);
}

.logo .header-logo-canvas {
    width: 100px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
}

.logo .header-logo-canvas canvas {
    display: block;
}

.logo h1 {
    font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 2rem;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Scan Form */
.scan-form {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 2.5rem;
    border: 1px solid var(--border);
}

.scan-form h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.scan-form > p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.input-group input {
    flex: 1;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.1);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.input-group button {
    font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-group button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(var(--accent-rgb), 0.3);
}

.input-group button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-loader {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.scan-options {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
}

.option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.option input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

/* Features */
.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.feature {
    text-align: center;
}

.feature-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    background: var(--bg-tertiary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feature-icon svg {
    width: 24px;
    height: 24px;
    color: var(--accent);
}

.feature h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.feature p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Progress Section */
.scan-progress {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 2.5rem;
    border: 1px solid var(--border);
}

.scan-progress h2 {
    text-align: center;
    margin-bottom: 2rem;
}

.progress-container {
    margin-bottom: 2rem;
}

.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-fill {
    height: 100%;
    background: var(--gradient);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Scan Steps */
.scan-steps {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.step {
    text-align: center;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.step.active {
    opacity: 1;
}

.step.completed {
    opacity: 1;
}

.step-icon {
    width: 32px;
    height: 32px;
    margin: 0 auto 0.5rem;
    border: 2px solid var(--border);
    border-radius: 50%;
    position: relative;
}

.step.active .step-icon {
    border-color: var(--accent);
    animation: pulse 1.5s infinite;
}

.step.completed .step-icon {
    background: var(--success);
    border-color: var(--success);
}

.step.completed .step-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E") center/contain no-repeat;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(var(--accent-rgb), 0); }
}

.step span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Terminal */
.terminal {
    background: var(--terminal-bg);
    border-radius: 12px;
    overflow: hidden;
    font-family: 'JetBrains Mono', monospace;
}

.terminal-header {
    background: var(--terminal-header);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.terminal-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.terminal-dot.red { background: #ff5f57; }
.terminal-dot.yellow { background: #febc2e; }
.terminal-dot.green { background: #28c840; }

.terminal-title {
    margin-left: 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.terminal-body {
    padding: 1rem;
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.875rem;
    line-height: 1.8;
}

.terminal-line {
    color: var(--text-secondary);
}

.terminal-line.success { color: var(--success); }
.terminal-line.error { color: var(--danger); }

/* Results Section */
.scan-results {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 2.5rem;
    border: 1px solid var(--border);
}

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

.score-container {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.score-circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 4px solid var(--success);
}

.score-circle.warning { border-color: var(--warning); }
.score-circle.danger { border-color: var(--danger); }

.score-value {
    font-size: 2rem;
    font-weight: 700;
}

.score-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.grade-badge {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
}

.grade-badge.warning { background: var(--warning); }
.grade-badge.danger { background: var(--danger); }

/* Results Summary */
.results-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.summary-card {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    border-left: 4px solid;
}

.summary-card.critical { border-color: var(--critical); }
.summary-card.high { border-color: var(--danger); }
.summary-card.medium { border-color: var(--warning); }
.summary-card.low { border-color: var(--success); }

.summary-card .count {
    display: block;
    font-size: 2rem;
    font-weight: 700;
}

.summary-card .label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Buttons */
.results-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn {
    font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: var(--gradient);
    color: white;
    border: none;
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--border);
}

.btn:hover {
    transform: translateY(-2px);
}

/* Footer */
footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
}

footer strong {
    color: var(--accent);
}

footer .footer-logo-text {
    font-family: 'Black Echo', sans-serif;
    font-size: 1.25rem;
    letter-spacing: 0.06em;
    color: var(--text-primary);
    text-decoration: none;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

footer .footer-logo-text:hover {
    opacity: 1;
    text-decoration: none;
}

footer p {
    font-size: 0.875rem;
}

footer a {
    color: var(--accent);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 1000;
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.theme-toggle:hover svg {
    color: var(--accent);
}

/* Sun icon hidden by default (dark mode), moon icon visible */
.theme-toggle .icon-sun {
    display: none;
}

.theme-toggle .icon-moon {
    display: block;
}

/* In light mode, show sun, hide moon */
[data-theme="light"] .theme-toggle .icon-sun {
    display: block;
}

[data-theme="light"] .theme-toggle .icon-moon {
    display: none;
}

/* System preference light mode */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]):not([data-theme="light"]) .theme-toggle .icon-sun {
        display: block;
    }
    :root:not([data-theme="dark"]):not([data-theme="light"]) .theme-toggle .icon-moon {
        display: none;
    }
}

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

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

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

    .scan-steps {
        grid-template-columns: repeat(3, 1fr);
    }

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