/* =====================================================
   MITOZA I MEJOZA – PODZIAŁ KOMÓRKI
   ===================================================== */

: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;
}

[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; }

/* ── Step Buttons (fazy) ──────────────────────── */
.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; }

/* ── Speed Row ────────────────────────────────── */
.speed-row { margin-top: 0.75rem; }
.speed-label { font-size: 0.8rem; color: var(--text-secondary); display: block; margin-bottom: 0.35rem; }
input[type="range"] {
    width: 100%; accent-color: var(--accent-primary);
    cursor: pointer; height: 5px; border-radius: 4px;
}

/* ── 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;
}

/* ── 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;
}
#cellCanvas { width: 100%; height: 100%; display: block; }
.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.8);
    padding: 0.25rem 0.75rem; border-radius: var(--radius-sm);
    font-size: 0.72rem; backdrop-filter: blur(4px); font-family: 'Inter', sans-serif;
}

/* ── Phase dots bar ───────────────────────────── */
.phase-dots-bar {
    position: absolute; bottom: 0.75rem; left: 50%; transform: translateX(-50%);
    display: flex; gap: 0.5rem; align-items: center; pointer-events: none;
    background: rgba(0,0,0,0.5); padding: 0.4rem 0.75rem; border-radius: 20px;
    backdrop-filter: blur(6px);
}
.phase-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: rgba(255,255,255,0.25); transition: var(--transition);
    pointer-events: all; cursor: pointer;
}
.phase-dot.active {
    background: var(--accent-primary);
    box-shadow: 0 0 8px rgba(139,92,246,0.7);
    width: 14px; height: 14px;
}
.phase-dot:hover { background: rgba(255,255,255,0.5); }

/* ── Info panel ───────────────────────────────── */
.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: 0.85rem; 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-header { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.6rem; }
.stage-emoji { font-size: 1.4rem; }
.stage-header h3 { margin-bottom: 0; }
#stageDesc { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.65; }

.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: 0.8rem;
}
.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; }

.gc-bar { width: 100%; height: 6px; background: var(--bg-primary); border-radius: 3px; overflow: hidden; }
.gc-bar-fill { height: 100%; background: var(--accent-gradient); border-radius: 3px; transition: width 0.3s ease; }
.progress-label { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.3rem; }

.physics-info p { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.65; font-style: italic; padding: 0.3rem 0.5rem; border-left: 3px solid var(--accent-primary); background: rgba(139,92,246,0.06); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ── 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; }
}
