@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;700&display=swap');

:root {
    --bg-main: #0b0d12;
    --bg-panel: #141a29;
    --bg-elevated: #1e2638;
    --primary: #06b6d4;
    --primary-glow: rgba(6, 182, 212, 0.15);
    --border: #2a344a;
    --border-primary: rgba(6, 182, 212, 0.4);
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
}

.gate-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0b0d12;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(20px);
    pointer-events: all;
}
.gate-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px;
    width: 90%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 20px 80px rgba(0,0,0,0.6);
}
.gate-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 8px;
}
.gate-input {
    width: 100%;
    padding: 14px 18px;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: white;
    margin: 24px 0 16px;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s ease;
}
.gate-input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 15px var(--primary-glow);
}
.gate-error {
    color: var(--danger);
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 12px;
    display: none;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
    padding-bottom: 80px;
}

.noise-overlay {
    position: fixed;
    inset: 0;
    z-index: -1;
    opacity: 0.03;
    pointer-events: none;
    background-image: url('data:image/svg+xml,%3Csvg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"%3E%3Cfilter id="noiseFilter"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/%3E%3C/filter%3E%3Crect width="100%25" height="100%25" filter="url(%23noiseFilter)"/%3E%3C/svg%3E');
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 24px;
}

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

.logo-word {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo-word span {
    color: var(--primary);
}

.header h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2.8rem;
    margin: 16px 0 12px;
}

.header p {
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
    font-size: 1.1rem;
}

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

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
}

/* Controls */
.controls {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
    align-items: flex-end;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.control-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

select {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
}

select:focus {
    border-color: var(--border-primary);
}

.btn {
    background: var(--primary);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    display: inline-block;
}

.btn:hover {
    background: #0891b2;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--primary-glow);
}

/* Canvas Viewport */
.canvas-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--bg-main);
}

#output-canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.status-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--text-muted);
    font-size: 1.2rem;
    pointer-events: none;
}

/* Results Section */
.results-section h2 {
    font-family: 'Space Grotesk', sans-serif;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1.4rem;
    margin-bottom: 16px;
}

.badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.badge.success {
    background: var(--success-bg);
    color: var(--success);
    border-color: var(--success);
}

.badge.scanning {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: var(--warning);
    animation: pulse 1.5s infinite;
}

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

.divider {
    height: 1px;
    background: var(--border);
    margin-bottom: 24px;
}

.result-box {
    margin-bottom: 32px;
}

.result-box h3 {
    font-size: 0.95rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
}

.issues-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.issue-item {
    background: var(--danger-bg);
    border-left: 3px solid var(--danger);
    padding: 12px 16px;
    border-radius: 4px;
    font-size: 0.95rem;
    font-weight: 500;
}

.issue-item.good {
    background: var(--success-bg);
    border-left: 3px solid var(--success);
}

.empty-state {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9rem;
}

.exercises-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.exercise-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    transition: transform 0.2s;
}

.exercise-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-primary);
}

.exercise-card h4 {
    color: var(--primary);
    margin-bottom: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.exercise-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.disclaimer {
    margin-top: 40px;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px dashed var(--border);
    padding-top: 16px;
}

@media (max-width: 900px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    .sidebar { display: none !important; }
}

/* Full App Dashboard Layout */
html, body {
    height: 100%;
    margin: 0;
    overflow: hidden; /* App feels */
}

.app-wrapper {
    display: flex;
    height: 100vh;
    width: 100vw;
    background: var(--bg-main);
}

.sidebar {
    width: 260px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    height: 72px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
}

.sidebar-nav {
    padding: 24px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background: var(--bg-elevated);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--primary-glow);
    color: var(--primary);
    border-left: 3px solid var(--primary);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    opacity: 0.8;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: var(--bg-main);
    border-bottom: 1px solid var(--border);
}

.breadcrumb {
    font-size: 0.95rem;
    color: var(--text-muted);
}

.breadcrumb span {
    color: var(--text-main);
    font-weight: 600;
}

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

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: bold;
    font-size: 0.9rem;
}

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

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

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

.content-area {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    position: relative;
    padding-bottom: 80px;
}

.app-view {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.app-view.active {
    display: block;
}

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

/* Clinical Printing Layout */
@media print {
    .sidebar, .top-bar, .no-print, .controls, #demo-gate, .noise-overlay {
        display: none !important;
    }
    
    body, .app-wrapper, .main-content, .content-area {
        background: white !important;
        color: black !important;
        height: auto !important;
        overflow: visible !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .panel, .control-group, select, .btn {
        background: white !important;
        border: 1px solid #eee !important;
        box-shadow: none !important;
        padding: 0 !important;
    }
    
    .metric-card {
        background: #f9f9f9 !important;
        border: 1px solid #ddd !important;
        color: black !important;
    }

    .metric-value, .metric-label {
        color: black !important;
    }

    .main-grid {
        display: block !important;
    }

    .canvas-container {
        border: 1px solid #ccc !important;
        margin-bottom: 20px !important;
    }

    h1, h2, h3, h4 {
        color: #0b0d12 !important;
        margin-top: 0 !important;
    }

    .results-section {
        page-break-inside: avoid;
    }

    /* Add a report header for print only */
    .content-area::before {
        content: "CYRAX HEALTH — HAIR DONOR DENSITY REPORT";
        display: block;
        font-family: 'Space Grotesk', sans-serif;
        font-weight: 800;
        font-size: 1.5rem;
        border-bottom: 2px solid #06b6d4;
        margin-bottom: 30px;
        padding-bottom: 10px;
    }
}
