/* ============================================================
   UKŁAD KRĄŻENIA – SERCE I OBIEGI KRWI
   ============================================================ */

:root {
    --bg-primary: #eef2e6;
    --bg-secondary: rgba(255, 255, 255, 0.96);
    --bg-secondary-solid: #ffffff;
    --bg-tertiary: #f7f3e8;
    --bg-panel: #ffffff;
    --text-primary: #1f3447;
    --text-secondary: #4e6478;
    --text-muted: #78889b;

    /* Kolory specyficzne dla krwi */
    --accent-primary: #e34854; /* Czerwony - krew utlenowana */
    --accent-secondary: #bf3144;
    --accent-blue: #2f7be7; /* Niebieski - krew odtlenowana */
    --accent-gradient: linear-gradient(135deg, #ef5f67 0%, #3b82f6 100%);
    --accent-warm: #ffb25b;
    --panel-stroke: #cdd8e3;

    --border-color: #cfdae5;
    --canvas-bg: #f7f3e8;

    --shadow-sm: 0 3px 0 rgba(174, 187, 201, 0.45);
    --shadow-md: 0 6px 0 rgba(174, 187, 201, 0.42);
    --shadow-lg: 0 10px 0 rgba(174, 187, 201, 0.36);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --transition: all 0.3s ease;
}

[data-theme="dark"] {
    --bg-primary: #08131d;
    --bg-secondary: rgba(15, 23, 35, 0.86);
    --bg-secondary-solid: #111b27;
    --bg-tertiary: #162433;
    --bg-panel: rgba(10, 18, 28, 0.72);
    --text-primary: #edf5ff;
    --text-secondary: #a0b4c8;
    --text-muted: #6e8197;
    --border-color: rgba(94, 118, 145, 0.26);
    --canvas-bg: #07111a;
    --panel-stroke: rgba(255, 255, 255, 0.08);

    --shadow-sm: 0 10px 24px rgba(0,0,0,0.22);
    --shadow-md: 0 18px 50px rgba(0,0,0,0.34);
    --shadow-lg: 0 28px 70px rgba(0,0,0,0.46);

    --accent-primary: #fb7185;
    --accent-secondary: #ef4444;
    --accent-blue: #60a5fa;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 14px;
    background:
        linear-gradient(180deg, #fbfcf8 0%, #f3f6ee 58%, var(--bg-primary) 100%);
    color: var(--text-primary);
    transition: var(--transition);
}

[data-theme="dark"] body {
    background:
        radial-gradient(circle at top left, rgba(59,130,246,0.14), transparent 32%),
        radial-gradient(circle at top right, rgba(244,63,94,0.16), transparent 30%),
        linear-gradient(180deg, #08111b 0%, #0c1520 40%, var(--bg-primary) 100%);
}

/* ─── LAYOUT ─────────────────────────────────────────────────────────────────── */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
    gap: 1rem;
    z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 1rem; }

.app-header h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #536e87;
    white-space: nowrap;
}

.mode-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    background: #6a77c9;
    color: #fff;
    white-space: nowrap;
    border: 2px solid rgba(255,255,255,0.8);
    box-shadow: none;
}

.header-right { display: flex; gap: 0.5rem; }

.icon-btn {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.65rem;
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
    color: var(--text-primary);
}
.icon-btn:hover { background: #fffdf7; box-shadow: none; }

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


.main-content {
    display: grid;
    grid-template-columns: 270px 1fr 310px;
    flex: 1;
    overflow: hidden;
}

/* ─── PANELS ──────────────────────────────────────────────────────────────── */
.controls-panel,
.info-panel {
    background: var(--bg-panel);
    border-color: var(--border-color);
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.controls-panel { border-right: 2px solid var(--border-color); }
.info-panel     { border-left:  2px solid var(--border-color); }

.controls-panel h2,
.info-panel h2 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--border-color);
}

/* ─── CONTROL SECTIONS ───────────────────────────────────────────────────── */
.control-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.control-section h3 {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.mode-btn {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    font-family: inherit;
    text-align: left;
    line-height: 1.35;
    transition: var(--transition);
    box-shadow: none;
}
.mode-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}
.mode-btn:not(.active) {
    color: var(--text-primary);
}
.mode-btn.active {
    background: linear-gradient(90deg, #df6872, #537fe8);
    border-color: #5c6fb7;
    color: #fff;
    box-shadow: none;
}

.action-buttons { flex-direction: row; margin-top: 0.5rem; }
.action-btn {
    flex: 1;
    padding: 0.6rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    transition: var(--transition);
    display: flex; align-items: center; justify-content: center;
}
.action-btn.start {
    background: linear-gradient(90deg, #df6872, #537fe8);
    color: #fff;
    box-shadow: none;
}
.action-btn:hover { transform: translateY(-1px); box-shadow: none; }

.speed-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.speed-row label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.speed-row input[type="range"] {
    width: 100%;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.checkbox-label input { display: none; }
.checkmark {
    width: 18px; height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}
.checkbox-label input:checked + .checkmark {
    background: var(--accent-primary);
    border-color: transparent;
}
.checkbox-label input:checked + .checkmark::after {
    content: '✓';
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

/* ─── SIMULATION AREA ────────────────────────────────────────────────────── */
.simulation-area {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    background: transparent;
    min-height: 0;
}
.simulation-box {
    flex: 1;
    background: var(--canvas-bg);
    border-radius: var(--radius-lg);
    border: 2px solid var(--panel-stroke);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] .simulation-box {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01)),
        var(--canvas-bg);
}

.simulation-box::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(59,130,246,0.06) 0%, rgba(59,130,246,0.06) 42%, rgba(239,68,68,0.06) 58%, rgba(239,68,68,0.06) 100%);
    pointer-events: none;
}

.simulation-overlay {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(60%, 420px);
}

.flow-legend {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.legend-pill,
.gesture-hint {
    border: 2px solid var(--panel-stroke);
    box-shadow: none;
}

.legend-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.42rem 0.75rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--text-primary);
    background: #ffffff;
}

.legend-pill::before {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: block;
    box-shadow: none;
}

.legend-pill.oxygenated::before {
    background: linear-gradient(135deg, #ff7a85, #e34854);
}

.legend-pill.deoxygenated::before {
    background: linear-gradient(135deg, #7db7ff, #2f7be7);
}

.gesture-hint {
    align-self: flex-start;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: #ffffff;
}

[data-theme="dark"] .legend-pill,
[data-theme="dark"] .gesture-hint {
    background: rgba(9, 15, 24, 0.58);
}

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    z-index: 50;
}
.zoom-btn {
    width: 32px; height: 32px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #ffffff;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
    font-size: 0.9rem;
    box-shadow: none;
}
.zoom-btn:hover { background: var(--bg-tertiary); color: var(--accent-primary); border-color: var(--accent-primary); }

[data-theme="dark"] .zoom-btn {
    background: rgba(8, 14, 22, 0.72);
}

[data-theme="dark"] .mode-btn {
    background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.04)), rgba(22, 36, 51, 0.96);
    color: var(--text-primary);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

.canvas-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s ease-out;
}
canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ─── INFO PANEL CARDS ────────────────────────────────────────────────────── */
.info-card {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.info-card h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.stage-card {
    background: #f8eef0;
    border-color: #e8c7cf;
}
.stage-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.stage-header h3 {
    font-size: 1rem;
    margin: 0;
}

/* Values grid */
.values-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}
.value-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.8rem;
    border: 2px solid var(--border-color);
}

[data-theme="dark"] .value-item {
    background: rgba(8, 14, 22, 0.52);
}
.value-item .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.value-item .data {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.physics-info {
    background: #f5f1e6;
    border-color: #e3d7ba;
}

/* ─── SCROLLBAR ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    .main-content { grid-template-columns: 240px 1fr 280px; }
}
@media (max-width: 850px) {
    .main-content { grid-template-columns: 1fr; overflow-y: auto; display: block; }
    .simulation-area { height: 400px; }
    .simulation-overlay {
        max-width: calc(100% - 5rem);
    }
}
