/* =====================================================
   DNA I REPLIKACJA – PODWÓJNA HELISA
   ===================================================== */

:root {
    --bg-primary: #f0f4f8;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8eef4;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --accent-primary: #8b5cf6;
    --accent-secondary: #7c3aed;
    --accent-gradient: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s ease;
    --canvas-bg: #edf1f7;
    --info-scale: 1;
}

[data-theme="dark"] {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --border-color: #30363d;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
    --canvas-bg: #060d14;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }

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

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

/* ── Header ──────── */
.header {
    display:flex; justify-content:space-between; align-items:center;
    padding:0.75rem 1.5rem;
    background:var(--bg-secondary);
    border-bottom:1px solid var(--border-color);
    box-shadow:var(--shadow-sm);
    z-index:100; flex-shrink:0;
}
.header h1 {
    font-size:1.35rem; font-weight:700;
    background:var(--accent-gradient);
    -webkit-background-clip:text; -webkit-text-fill-color:transparent; background-clip:text;
}
.header-controls { display:flex; gap:0.5rem; }
.control-btn {
    width:40px; height:40px; border:none;
    border-radius:var(--radius-sm); background:var(--bg-tertiary);
    color:var(--text-secondary); cursor:pointer;
    display:flex; align-items:center; justify-content:center;
    transition:var(--transition);
}
.control-btn:hover { background:var(--accent-primary); color:white; }
.control-btn svg { width:20px; height:20px; }
.moon-icon, .compress-icon { display:none; }
[data-theme="dark"] .sun-icon { display:none; }
[data-theme="dark"] .moon-icon { display:block; }
.fullscreen-active .expand-icon { display:none; }
.fullscreen-active .compress-icon { display:block; }

/* ── Layout ───────── */
.main-content {
    display:grid; grid-template-columns:270px 1fr 310px;
    gap:1rem; padding:1rem; flex:1; overflow:hidden;
    background:var(--bg-primary); min-height:0;
}

/* ── Panels ───────── */
.controls-panel, .info-panel {
    background:var(--bg-secondary); border-radius:var(--radius-lg);
    padding:1.25rem; box-shadow:var(--shadow-md);
    overflow-y:auto; border:1px 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); margin-bottom:1rem;
}
.control-section {
    margin-bottom:1.25rem; padding-bottom:1.25rem;
    border-bottom:1px solid var(--border-color);
}
.control-section:last-child { border-bottom:none; margin-bottom:0; padding-bottom:0; }
.control-section h3 { font-size:0.85rem; font-weight:500; color:var(--text-secondary); margin-bottom:0.75rem; }

/* ── Mode Buttons ─── */
.mode-buttons { display:flex; flex-direction:column; gap:0.4rem; }
.mode-btn {
    padding:0.6rem 0.75rem; border:1px solid var(--border-color);
    border-radius:var(--radius-sm); background:var(--bg-tertiary);
    color:var(--text-secondary); font-size:0.82rem; font-weight:500;
    cursor:pointer; transition:var(--transition); text-align:left; font-family:'Inter',sans-serif;
}
.mode-btn:hover { border-color:var(--accent-primary); color:var(--accent-primary); }
.mode-btn.active { background:var(--accent-gradient); color:white; border-color:transparent; }

/* ── Speed Buttons ── */
.speed-buttons { display:flex; gap:0.25rem; }
.speed-btn {
    flex:1; padding:0.4rem; border:1px solid var(--border-color);
    border-radius:var(--radius-sm); background:var(--bg-tertiary);
    color:var(--text-secondary); font-size:0.78rem; font-weight:500;
    cursor:pointer; transition:var(--transition); font-family:'Inter',sans-serif;
}
.speed-btn:hover { border-color:var(--accent-primary); }
.speed-btn.active { background:var(--accent-primary); color:white; border-color:var(--accent-primary); }

/* ── Sequence Input ─ */
.sequence-input {
    width:100%; padding:0.5rem 0.65rem;
    border:1px solid var(--border-color); border-radius:var(--radius-sm);
    background:var(--bg-tertiary); color:var(--text-primary);
    font-family:'Courier New',monospace; font-size:1rem; font-weight:700;
    letter-spacing:0.15em; text-transform:uppercase; outline:none;
    transition:var(--transition); margin-bottom:0.3rem;
}
.sequence-input:focus { border-color:var(--accent-primary); box-shadow:0 0 0 3px rgba(139,92,246,0.15); }
.seq-hint { font-size:0.72rem; color:var(--text-muted); margin-bottom:0.4rem; }
.shuffle-btn {
    width:100%; padding:0.4rem; border:1px dashed var(--border-color);
    border-radius:var(--radius-sm); background:transparent;
    color:var(--text-muted); font-size:0.78rem; font-family:'Inter',sans-serif;
    cursor:pointer; transition:var(--transition);
}
.shuffle-btn:hover { border-color:var(--accent-primary); color:var(--accent-primary); }

/* ── Checkbox ──────── */
.checkbox-label {
    display:flex; align-items:center; gap:0.5rem;
    font-size:0.85rem; color:var(--text-secondary); cursor:pointer; margin-bottom:0.5rem;
}
.checkbox-label input { display:none; }
.checkmark {
    width:18px; height:18px; flex-shrink:0;
    border:2px solid var(--border-color); border-radius:4px;
    position:relative; transition:var(--transition);
}
.checkbox-label input:checked + .checkmark { background:var(--accent-primary); border-color:var(--accent-primary); }
.checkbox-label input:checked + .checkmark::after {
    content:'✓'; position:absolute; left:50%; top:50%;
    transform:translate(-50%,-50%); color:white; font-size:0.7rem; font-weight:700;
}

/* ── Step Buttons ─── */
.step-buttons { display:flex; flex-direction:column; gap:0.3rem; }
.step-btn {
    padding:0.5rem 0.65rem; border:1px solid var(--border-color);
    border-radius:var(--radius-sm); background:var(--bg-tertiary);
    color:var(--text-secondary); font-size:0.8rem; font-weight:500;
    cursor:pointer; transition:var(--transition); text-align:left; font-family:'Inter',sans-serif;
}
.step-btn:hover { border-color:var(--accent-primary); color:var(--accent-primary); }
.step-btn.active { background:var(--accent-gradient); color:white; border-color:transparent; }

/* ── Action Buttons ─ */
.action-buttons { display:flex; gap:0.4rem; }
.action-btn {
    flex:1; padding:0.6rem; border:none; border-radius:var(--radius-md);
    font-size:0.78rem; font-weight:600; cursor:pointer;
    display:flex; align-items:center; justify-content:center; gap:0.3rem;
    transition:var(--transition); font-family:'Inter',sans-serif;
}
.action-btn.start { background:var(--accent-gradient); color:white; }
.action-btn.start:hover { transform:translateY(-2px); box-shadow:0 4px 12px rgba(139,92,246,0.4); }
.action-btn.reset { background:var(--bg-tertiary); color:var(--text-secondary); border:1px solid var(--border-color); }
.action-btn.reset:hover { background:var(--accent-primary); color:white; border-color:var(--accent-primary); }
.btn-icon { font-size:0.85rem; }

/* ── Simulation ────── */
.simulation-container { display:flex; flex-direction:column; min-height:0; }
.simulation-box {
    flex:1; background:var(--canvas-bg); border-radius:var(--radius-lg);
    overflow:hidden; position:relative; box-shadow:var(--shadow-lg); min-height:0;
}
#dnaCanvas { width:100%; height:100%; display:block; cursor:default; }
.canvas-overlay { position:absolute; top:1rem; left:1rem; pointer-events:none; display:flex; flex-direction:column; gap:0.4rem; }
.mode-badge {
    display:inline-block; background:rgba(0,0,0,0.65); color:white;
    padding:0.4rem 0.9rem; border-radius:var(--radius-sm);
    font-size:0.85rem; font-weight:600; backdrop-filter:blur(4px);
}
.click-hint {
    display:inline-block; background:rgba(0,0,0,0.45); color:rgba(255,255,255,0.7);
    padding:0.25rem 0.75rem; border-radius:var(--radius-sm);
    font-size:0.72rem; backdrop-filter:blur(4px); font-family:'Inter',sans-serif;
}

/* Selected base card */
.selected-base-card {
    border:2px solid transparent;
    background:linear-gradient(var(--bg-secondary),var(--bg-secondary)) padding-box,
               var(--accent-gradient) border-box;
    animation:cardIn 0.3s ease;
}
@keyframes cardIn { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:none; } }
.selected-base-header { display:flex; align-items:center; gap:0.6rem; margin-bottom:0.7rem; }
.selected-base-dot { width:14px; height:14px; border-radius:50%; flex-shrink:0; }
.selected-base-header h3 { font-size:0.83rem; margin:0; }
.selected-base-fact {
    margin-top:0.6rem; padding:0.5rem 0.65rem;
    background:rgba(139,92,246,0.08); border-radius:var(--radius-sm);
    font-size:0.76rem; color:var(--text-secondary); line-height:1.55;
    border-left:3px solid var(--accent-primary);
    font-style:italic;
}

/* Zoom controls */
.zoom-controls {
    position:absolute; top:0.75rem; right:0.75rem;
    display:flex; align-items:center; gap:0.25rem;
    background:rgba(0,0,0,0.55); backdrop-filter:blur(6px);
    border-radius:var(--radius-sm); padding:0.25rem 0.4rem;
}
.zoom-btn {
    width:28px; height:28px; border:none;
    background:rgba(255,255,255,0.12); color:white;
    border-radius:6px; font-size:1rem; font-weight:700;
    cursor:pointer; transition:background 0.2s;
    display:flex; align-items:center; justify-content:center;
    font-family:'Inter',sans-serif; line-height:1;
}
.zoom-btn:hover { background:var(--accent-primary); }
.zoom-reset { font-size:0.9rem; }
.zoom-label {
    color:rgba(255,255,255,0.85); font-size:0.75rem; font-weight:600;
    font-family:'Inter',sans-serif; min-width:38px; text-align:center;
}

/* Info panel header with text-size controls */
.info-panel-header {
    display:flex; justify-content:space-between; align-items:center;
    margin-bottom:1rem;
}
.info-panel-header h2 { margin-bottom:0; }
.text-size-controls { display:flex; gap:0.2rem; }
.text-size-btn {
    padding:0.18rem 0.4rem; border:1px solid var(--border-color);
    border-radius:5px; background:var(--bg-tertiary);
    color:var(--text-secondary); cursor:pointer;
    font-family:'Inter',sans-serif; font-size:0.72rem;
    transition:var(--transition); line-height:1.4;
}
.text-size-btn:hover { border-color:var(--accent-primary); color:var(--accent-primary); }
.text-size-btn.active { background:var(--accent-primary); color:white; border-color:transparent; }

.info-card { background:var(--bg-tertiary); border-radius:var(--radius-md); padding:1rem; margin-bottom:0.85rem; }
.info-card:last-child { margin-bottom:0; }
.info-card h3 { font-size:calc(0.85rem * var(--info-scale)); font-weight:600; color:var(--text-primary); margin-bottom:0.75rem; }
.stage-card {
    background:linear-gradient(135deg,rgba(139,92,246,0.1) 0%,rgba(99,102,241,0.1) 100%);
    border:1px solid rgba(139,92,246,0.25);
}
.stage-card p { font-size:calc(0.8rem * var(--info-scale)); color:var(--text-secondary); line-height:1.6; }

.values-grid { display:flex; flex-direction:column; gap:0.35rem; }
.value-item {
    display:flex; justify-content:space-between; align-items:center;
    padding:0.3rem 0; border-bottom:1px solid var(--border-color);
    font-size:calc(0.8rem * var(--info-scale));
}
.value-item:last-child { border-bottom:none; }
.value-item .label { color:var(--text-secondary); }
.value-item .data { font-weight:700; color:var(--accent-primary); font-family:'Courier New',monospace; }

/* Chargaff */
.chargaff-row {
    display:flex; justify-content:space-between; align-items:center;
    padding:0.3rem 0; border-bottom:1px solid var(--border-color);
    font-size:calc(0.8rem * var(--info-scale));
}
.chargaff-row:last-child { border-bottom:none; }
.chargaff-ok { color:#22c55e; font-weight:700; font-size:1rem; }
.chargaff-fail { color:#ef4444; font-weight:700; font-size:1rem; }
.gc-bar { width:100%; height:6px; background:var(--bg-primary); border-radius:3px; margin-top:0.4rem; overflow:hidden; }
.gc-bar-fill { height:100%; background:linear-gradient(90deg,#f59e0b,#22c55e); border-radius:3px; transition:width 0.5s ease; }

/* Params table */
.params-table { width:100%; border-collapse:collapse; font-size:calc(0.78rem * var(--info-scale)); }
.params-table td { padding:0.35rem 0.5rem; border-bottom:1px solid var(--border-color); color:var(--text-secondary); }
.params-table tr:last-child td { border-bottom:none; }
.params-table td:last-child { font-weight:600; color:var(--accent-primary); text-align:right; }

.physics-info p { font-size:calc(0.8rem * var(--info-scale)); color:var(--text-secondary); line-height:1.6; }
/* Selected base scale-aware overrides */
.selected-base-header h3 { font-size:calc(0.83rem * var(--info-scale)) !important; }
.selected-base-fact { font-size:calc(0.76rem * var(--info-scale)) !important; }

/* ── Scrollbar ──────── */
.controls-panel::-webkit-scrollbar, .info-panel::-webkit-scrollbar { width:5px; }
.controls-panel::-webkit-scrollbar-track, .info-panel::-webkit-scrollbar-track { background:transparent; }
.controls-panel::-webkit-scrollbar-thumb, .info-panel::-webkit-scrollbar-thumb { background:var(--border-color); border-radius:3px; }

/* ── Responsive ──────── */
@media (max-width:1200px) { .main-content { grid-template-columns:240px 1fr 280px; } }
@media (max-width:992px) {
    .main-content { grid-template-columns:1fr; overflow-y:auto; }
    .controls-panel, .info-panel { max-height:220px; }
    .controls-panel { order:1; }
    .simulation-container { order:2; min-height:400px; }
    .info-panel { order:3; }
    .header h1 { font-size:1rem; }
}
