/* ===== DESIGN TOKENS ===== */
:root {
    --bg-primary: #07080a;
    --bg-secondary: #0d0f13;
    --bg-card: #12151a;
    --bg-card-hover: #181c23;
    --border-color: #1e2330;
    --border-subtle: #161a22;

    --text-primary: #e8eaf0;
    --text-secondary: #8b90a0;
    --text-muted: #555a6b;

    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.15);
    --accent-soft: rgba(59, 130, 246, 0.08);

    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.08);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.08);
    --warning: #f59e0b;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

/* ===== HEADER ===== */
#main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(7, 8, 10, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.logo-text {
    letter-spacing: -0.3px;
}

#main-nav {
    display: flex;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
}

.nav-link:hover,
.nav-link.active {
    color: var(--text-primary);
    background: var(--accent-soft);
}

.header-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.3s;
}

.status-dot.connected {
    background: var(--success);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.status-dot.disconnected {
    background: var(--danger);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

/* ===== HERO ===== */
#hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    padding: 120px 24px 80px;
    overflow: hidden;
}

.hero-bg-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(59, 130, 246, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59, 130, 246, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    mask-image: radial-gradient(ellipse 60% 50% at 50% 40%, black, transparent);
    -webkit-mask-image: radial-gradient(ellipse 60% 50% at 50% 40%, black, transparent);
}

.hero-content {
    position: relative;
    max-width: 720px;
}

.hero-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 100px;
    background: var(--accent-soft);
    border: 1px solid rgba(59, 130, 246, 0.15);
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 24px;
}

#hero-title {
    font-size: clamp(2.5rem, 5.5vw, 4rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -1.5px;
    margin-bottom: 20px;
    background: linear-gradient(180deg, #ffffff 0%, #8b90a0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 560px;
    margin: 0 auto 36px;
    line-height: 1.7;
}

.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 60px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.25);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

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

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

/* Hero Stats */
.hero-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-divider {
    width: 1px;
    height: 36px;
    background: var(--border-color);
}

/* ===== SECTIONS (Common) ===== */
.section-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 100px 24px;
}

.section-header {
    text-align: center;
    margin-bottom: 56px;
}

.section-header h2 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 10px;
}

.section-header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* ===== UPLOAD SECTION ===== */
#upload-section {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}

.diagnosis-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    align-items: start;
}

/* Upload Panel */
.upload-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.upload-dropzone {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    min-height: 340px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
    background: var(--bg-card);
}

.upload-dropzone:hover,
.upload-dropzone.drag-over {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.dropzone-content {
    text-align: center;
    padding: 40px;
}

.dropzone-icon {
    color: var(--text-muted);
    margin-bottom: 16px;
}

.dropzone-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.dropzone-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Preview */
.preview-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 340px;
}

.preview-container img {
    width: 100%;
    height: 100%;
    min-height: 340px;
    object-fit: contain;
    padding: 16px;
    background: #000;
    border-radius: var(--radius-lg);
}

.btn-remove {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.7);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-remove:hover {
    background: var(--danger);
}

.btn-analyze {
    width: 100%;
    justify-content: center;
    padding: 14px;
    font-size: 0.95rem;
}

/* ===== RESULTS PANEL ===== */
.results-panel {
    min-height: 340px;
}

.results-empty {
    height: 340px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-muted);
    font-size: 0.9rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
}

/* Loading */
.results-loading {
    height: 340px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
}

.loader-ring {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loader-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    animation: pulse-text 1.5s ease-in-out infinite;
}

@keyframes pulse-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Result Cards */
.results-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: var(--transition);
    animation: fadeSlideUp 0.4s ease-out both;
}

.result-card:nth-child(2) { animation-delay: 0.1s; }
.result-card:nth-child(3) { animation-delay: 0.2s; }

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.card-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

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

/* Diagnosis Badge */
.diagnosis-badge {
    padding: 6px 16px;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: var(--bg-secondary);
    color: var(--text-muted);
}

.diagnosis-badge.normal {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.diagnosis-badge.pneumonia {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Confidence Bar */
.confidence-bar-container {
    margin-top: 4px;
}

.confidence-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

#confidence-value {
    font-weight: 700;
    color: var(--text-primary);
}

.confidence-track {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 100px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    border-radius: 100px;
    background: linear-gradient(90deg, var(--accent), #6366f1);
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.confidence-fill.high-danger {
    background: linear-gradient(90deg, var(--danger), #f97316);
}

/* Heatmap */
.heatmap-image-wrapper {
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #000;
    margin-bottom: 12px;
}

.heatmap-image-wrapper img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
}

.heatmap-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Security Hash */
.hash-display {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hash-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.hash-value {
    font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--accent);
    background: var(--bg-secondary);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    word-break: break-all;
    border: 1px solid var(--border-subtle);
}

/* ===== HOW IT WORKS / PIPELINE ===== */
#how-it-works {
    background: var(--bg-primary);
}

.pipeline {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    flex-wrap: wrap;
}

.pipeline-step {
    flex: 1;
    min-width: 170px;
    max-width: 200px;
    text-align: center;
    padding: 24px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: var(--transition);
    position: relative;
}

.pipeline-step:hover {
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.08);
}

.step-number {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 12px;
    letter-spacing: 1px;
}

.step-icon {
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
}

.pipeline-step h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.pipeline-step p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.pipeline-connector {
    width: 32px;
    height: 2px;
    background: var(--border-color);
    align-self: center;
    margin-top: 40px;
    flex-shrink: 0;
}

/* ===== TECH STACK ===== */
#tech-stack {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
}

.tech-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.tech-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 28px 24px;
    transition: var(--transition);
}

.tech-card:hover {
    border-color: var(--border-color);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
}

.tech-icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.tech-card h4 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.tech-card p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ===== FOOTER ===== */
#main-footer {
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

.footer-top {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    gap: 48px;
    padding: 56px 0 40px;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.footer-tagline {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.7;
    max-width: 340px;
}

.footer-col-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* Contributors */
.contributors-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

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

.contributor-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.contributor-info {
    display: flex;
    flex-direction: column;
}

.contributor-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

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

/* Footer Links */
.footer-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.footer-links a {
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--text-primary);
    padding-left: 4px;
}

/* Footer Bottom */
.footer-bottom {
    border-top: 1px solid var(--border-subtle);
    padding: 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

/* ===== HAMBURGER MENU ===== */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    z-index: 110;
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
    transform-origin: center;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Mobile Nav */
.mobile-nav {
    display: none;
    flex-direction: column;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    padding: 8px 24px 16px;
}

.mobile-nav.open {
    display: flex;
}

.mobile-nav-link {
    padding: 12px 0;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
    transition: var(--transition);
}

.mobile-nav-link:last-child {
    border-bottom: none;
}

.mobile-nav-link:hover {
    color: var(--text-primary);
    padding-left: 8px;
}

/* ===== RESPONSIVE: TABLET (max-width: 900px) ===== */
@media (max-width: 900px) {
    .section-container {
        padding: 72px 20px;
    }

    .section-header {
        margin-bottom: 40px;
    }

    .section-header h2 {
        font-size: 1.7rem;
    }

    /* Upload Section */
    .diagnosis-layout {
        grid-template-columns: 1fr;
    }

    .upload-dropzone {
        min-height: 280px;
    }

    .preview-container,
    .preview-container img {
        min-height: 280px;
    }

    /* Pipeline */
    .pipeline {
        flex-direction: column;
        align-items: center;
    }

    .pipeline-connector {
        width: 2px;
        height: 24px;
        margin-top: 0;
    }

    .pipeline-step {
        max-width: 100%;
        width: 100%;
    }

    /* Tech Grid */
    .tech-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Footer */
    .footer-top {
        grid-template-columns: 1fr 1fr;
        gap: 32px;
    }

    .footer-brand {
        grid-column: 1 / -1;
    }
}

/* ===== RESPONSIVE: MOBILE (max-width: 640px) ===== */
@media (max-width: 640px) {
    /* Header */
    #main-nav {
        display: none;
    }

    .header-status {
        display: none;
    }

    .hamburger {
        display: flex;
    }

    .header-inner {
        padding: 0 16px;
        height: 56px;
    }

    /* Hero */
    #hero {
        min-height: auto;
        padding: 100px 16px 60px;
    }

    #hero-title {
        font-size: 2rem;
        letter-spacing: -0.8px;
    }

    .hero-subtitle {
        font-size: 0.95rem;
        margin-bottom: 28px;
    }

    .hero-actions {
        flex-direction: column;
        align-items: stretch;
        margin-bottom: 40px;
    }

    .hero-actions .btn {
        justify-content: center;
    }

    .hero-stats {
        flex-direction: column;
        gap: 16px;
    }

    .stat-divider {
        width: 40px;
        height: 1px;
    }

    /* Upload Section */
    .section-container {
        padding: 56px 16px;
    }

    .section-header h2 {
        font-size: 1.5rem;
    }

    .upload-dropzone {
        min-height: 220px;
    }

    .preview-container,
    .preview-container img {
        min-height: 220px;
    }

    .dropzone-icon svg {
        width: 36px;
        height: 36px;
    }

    .dropzone-title {
        font-size: 0.95rem;
    }

    .dropzone-hint {
        font-size: 0.8rem;
    }

    /* Results */
    .results-empty,
    .results-loading {
        height: 240px;
    }

    .result-card {
        padding: 16px;
    }

    .heatmap-image-wrapper img {
        aspect-ratio: auto;
    }

    /* Pipeline */
    .pipeline-step {
        padding: 20px 16px;
    }

    .pipeline-step h3 {
        font-size: 0.9rem;
    }

    .pipeline-connector {
        height: 16px;
    }

    /* Tech Grid */
    .tech-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .tech-card {
        padding: 20px 18px;
    }

    /* Footer */
    .footer-top {
        grid-template-columns: 1fr;
        gap: 28px;
        padding: 40px 0 28px;
    }

    .footer-tagline {
        max-width: 100%;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
}

/* ===== RESPONSIVE: SMALL MOBILE (max-width: 380px) ===== */
@media (max-width: 380px) {
    #hero-title {
        font-size: 1.7rem;
    }

    .hero-subtitle {
        font-size: 0.88rem;
    }

    .btn {
        padding: 10px 18px;
        font-size: 0.85rem;
    }

    .logo-icon {
        width: 32px;
        height: 32px;
    }

    .logo-icon svg {
        width: 20px;
        height: 20px;
    }

    .logo-text {
        font-size: 0.95rem;
    }

    .stat-value {
        font-size: 0.85rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }
}
