/* Premium Water Electrolysis Simulation Stylesheet */
:root {
    --bg-gradient: radial-gradient(circle at top left, #08090f, #101422 65%, #05060b);
    --panel-bg: rgba(18, 24, 40, 0.7);
    --panel-border: rgba(255, 255, 255, 0.05);
    --text: #f8fafc;
    --text-muted: #94a3b8;
    
    --primary: #00f2fe;
    --primary-hover: #00c6ff;
    --primary-glow: rgba(0, 242, 254, 0.35);
    
    --cathode: #3b82f6; /* Blue (-) */
    --cathode-glow: rgba(59, 130, 246, 0.4);
    --anode: #ef4444;   /* Red (+) */
    --anode-glow: rgba(239, 68, 68, 0.4);
    
    --canvas-bg: #0b0d19;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-gradient);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 16px;
    overflow: hidden;
}

.app-container {
    width: 100%;
    max-width: 1300px;
    height: 94vh;
    max-height: 950px;
    background: rgba(8, 10, 18, 0.4);
    border-radius: 24px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.8), 
                inset 0 1px 0 rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(25px);
}

/* HEADER */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: rgba(6, 8, 16, 0.6);
    border-bottom: 1px solid var(--panel-border);
    backdrop-filter: blur(10px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #00f2fe, #3b82f6);
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.logo-icon::after {
    content: '';
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 0 8px #fff;
    position: absolute;
    animation: bubbleLogo 2.5s infinite ease-in-out;
}

@keyframes bubbleLogo {
    0% { transform: translateY(15px) scale(0.6); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translateY(-15px) scale(1.1); opacity: 0; }
}

h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(to right, #ffffff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    border: 1px solid var(--panel-border);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.nav-btn.info {
    background: rgba(0, 242, 254, 0.08);
    color: #38bdf8;
    border-color: rgba(0, 242, 254, 0.15);
}

.nav-btn.info:hover {
    background: rgba(0, 242, 254, 0.15);
    border-color: rgba(0, 242, 254, 0.35);
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.2);
}

/* MAIN LAYOUT */
.sim-wrapper {
    flex: 1;
    display: grid;
    grid-template-columns: 1.45fr 1.55fr;
    gap: 12px;
    padding: 12px;
    height: 0;
    overflow: hidden;
}

/* CANVAS SIMULATION SCREEN */
.sim-container {
    background: var(--canvas-bg);
    border-radius: 20px;
    border: 1px solid var(--panel-border);
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.8),
                0 15px 30px rgba(0, 0, 0, 0.4);
    height: 100%;
}

canvas#simCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.sim-overlay {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(8, 10, 20, 0.85);
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    pointer-events: none;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 5;
    white-space: nowrap;
}

.sim-overlay::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #00f2fe;
    box-shadow: 0 0 8px #00f2fe;
}

/* MATCH TEST POPUP EFFECT OVERLAY */
.test-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 8;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.15s ease;
}

.test-overlay.hidden {
    opacity: 0;
}

#test-balloon-text {
    font-family: 'Outfit', sans-serif;
    font-size: 3.5rem;
    font-weight: 900;
    color: #ff007f;
    text-shadow: 0 0 20px rgba(255, 0, 127, 0.8), 0 0 40px rgba(255, 0, 127, 0.5);
    transform: scale(0.5);
    animation: popEffect 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popEffect {
    0% { transform: scale(0.2); opacity: 0; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1.0); opacity: 0; }
}

/* RIGHT COLUMN - SCROLLABLE FALLBACK */
.right-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
    overflow-y: auto;
    padding-right: 2px;
}

/* Custom scrollbar for right column */
.right-column::-webkit-scrollbar {
    width: 6px;
}
.right-column::-webkit-scrollbar-track {
    background: transparent;
}
.right-column::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}
.right-column::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.24);
}

/* CONTROLS PANEL */
.controls-panel {
    background: var(--panel-bg);
    border-radius: 20px;
    border: 1px solid var(--panel-border);
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(20px);
}

.controls-panel::-webkit-scrollbar {
    width: 5px;
}
.controls-panel::-webkit-scrollbar-track {
    background: transparent;
}
.controls-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}
.controls-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.12);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 6px;
    margin-bottom: 2px;
}

.btn-toggle-panel {
    display: none;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-toggle-panel:hover {
    background: rgba(255, 255, 255, 0.15);
}

.panel-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: #fff;
}

.badge {
    background: rgba(0, 242, 254, 0.1);
    color: #00f2fe;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    border: 1px solid rgba(0, 242, 254, 0.2);
    letter-spacing: 0.5px;
}

/* Parameters layout */
.parameter-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}

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

.section-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.slider-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slider-label-row label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.val-display {
    color: #fff;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    display: flex;
    align-items: baseline;
}

.unit {
    margin-left: 2px;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Radio buttons (Indicator selector) */
.radio-group {
    display: flex;
    background: rgba(0, 0, 0, 0.4);
    padding: 3px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    gap: 2px;
}

.radio-btn {
    flex: 1;
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 6px 4px;
    border-radius: 7px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.radio-btn:hover {
    color: #fff;
}

.radio-btn.active {
    background: rgba(255, 255, 255, 0.08);
    color: #00f2fe;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(0, 242, 254, 0.15);
}

/* Sliders */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    touch-action: none;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    margin-top: -5px;
    border: 3px solid #00f2fe;
    transition: transform 0.1s ease;
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

/* Action grids and buttons */
.action-grid-row {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 0px;
}

.actions {
    display: flex;
    gap: 6px;
}

.action-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    font-family: 'Inter', sans-serif;
}

.action-btn.toggle-micro, .action-btn.toggle-ions {
    background: rgba(0, 242, 254, 0.08);
    color: #00f2fe;
    border: 1px solid rgba(0, 242, 254, 0.2);
    flex: 1;
}

.action-btn.toggle-micro:hover, .action-btn.toggle-ions:hover {
    background: rgba(0, 242, 254, 0.16);
    border-color: rgba(0, 242, 254, 0.4);
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.15);
}

.action-btn.toggle-micro.active, .action-btn.toggle-ions.active {
    background: rgba(0, 242, 254, 0.25);
    color: #fff;
    border-color: #00f2fe;
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.3);
}

.action-btn.play {
    background: linear-gradient(135deg, #00f2fe, #00c6ff);
    color: #050811;
    font-weight: 700;
    box-shadow: 0 4px 12px var(--primary-glow);
    flex: 1.3;
}

.action-btn.play:hover {
    background: linear-gradient(135deg, #00c6ff, #0072ff);
    transform: translateY(-1px);
}

.action-btn.play.paused {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.action-btn.reset {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    border: 1px solid var(--panel-border);
    flex: 0.8;
}

.action-btn.reset:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.12);
}

/* Gas flame test UI */
.gas-test-panel {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.gas-test-panel h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    color: #cbd5e1;
}

.gas-test-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.action-btn.test-btn {
    border: 1px solid transparent;
    font-size: 0.74rem;
    padding: 10px 8px;
}

.action-btn.h2-test {
    background: rgba(59, 130, 246, 0.1);
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.2);
}

.action-btn.h2-test:not(:disabled):hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.25);
    transform: translateY(-1px);
}

.action-btn.o2-test {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.2);
}

.action-btn.o2-test:not(:disabled):hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.25);
    transform: translateY(-1px);
}

.action-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
    border-color: var(--panel-border) !important;
    color: var(--text-muted) !important;
    background: rgba(255, 255, 255, 0.02) !important;
}

/* ANALYSIS PANEL */
.chart-container {
    background: var(--panel-bg);
    border-radius: 20px;
    border: 1px solid var(--panel-border);
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(20px);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 4px;
}

.chart-header h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
}

/* Electrical stats card grid */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.stat-card {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.02);
    border-radius: 10px;
    padding: 4px 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 2px;
}

.stat-card.highlighted {
    border: 1px solid rgba(0, 242, 254, 0.15);
    background: rgba(0, 242, 254, 0.02);
}

.card-label {
    font-size: 0.58rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}

.card-val {
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
}

.card-val-accent {
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #00f2fe;
    text-shadow: 0 0 8px rgba(0, 242, 254, 0.35);
}

/* Collected volume analysis cards */
.analysis-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.val-card {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.val-card.card-h2 { border-left: 4px solid var(--cathode); }
.val-card.card-o2 { border-left: 4px solid var(--anode); }

.val-card.card-h2 .card-val { color: #bfdbfe; text-shadow: 0 0 8px var(--cathode-glow); font-size: 1rem; }
.val-card.card-o2 .card-val { color: #fca5a5; text-shadow: 0 0 8px var(--anode-glow); font-size: 1rem; }

/* Progress bar inside volume card */
.progress-bar-container {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 2px;
}

.progress-bar {
    height: 100%;
    width: 0%;
    transition: width 0.1s linear;
}

.progress-bar.h2-color {
    background: var(--cathode);
    box-shadow: 0 0 8px var(--cathode);
}

.progress-bar.o2-color {
    background: var(--anode);
    box-shadow: 0 0 8px var(--anode);
}

.progress-bar.cl2-color {
    background: #a3e635; /* Yellow-green for chlorine */
    box-shadow: 0 0 8px #a3e635;
}

.progress-bar.i2-color {
    background: #d97706; /* Yellow-brown for Iodine */
    box-shadow: 0 0 8px #d97706;
}

.progress-bar.i2-starch-color {
    background: #4c1d95; /* Dark blue-purple for Starch-Iodine reaction */
    box-shadow: 0 0 8px #4c1d95;
}

/* Status Banner */
.stats-box.single-col {
    display: flex;
    justify-content: center;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.02);
    border-radius: 10px;
    padding: 6px 12px;
}

.stat-banner {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.stat-banner .stat-value {
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
}

/* INFO MODAL */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(3, 4, 8, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.25s ease;
}

.modal-backdrop.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: rgba(15, 20, 35, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    width: 90%;
    max-width: 480px;
    padding: 20px 24px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.7);
    transform: translateY(0) scale(1);
    transition: transform 0.25s ease;
    backdrop-filter: blur(10px);
}

.modal-backdrop.hidden .modal-content {
    transform: translateY(20px) scale(0.96);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 8px;
}

.modal-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: #fff;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 50vh;
    overflow-y: auto;
}

.modal-body::-webkit-scrollbar {
    width: 4px;
}
.modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.modal-body h3 {
    font-family: 'Outfit', sans-serif;
    color: #38bdf8;
    font-size: 0.95rem;
    margin-bottom: 2px;
    font-weight: 600;
}

.modal-body p {
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.5;
}

.modal-body hr {
    border: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
}

.modal-body code {
    background: rgba(0, 0, 0, 0.3);
    padding: 1px 4px;
    border-radius: 3px;
    font-family: monospace;
    color: #00f2fe;
    font-size: 0.8rem;
}

/* RESPONSIVE SCALING */
@media (max-width: 900px) {
    body {
        overflow-y: auto;
        padding: 8px;
    }
    
    .app-container {
        height: auto;
        max-height: none;
    }
    
    .sim-wrapper {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        height: auto;
        padding: 8px;
        gap: 8px;
    }
    
    .sim-container {
        height: 320px;
    }
    
    .right-column {
        height: auto;
    }
    
    .controls-panel {
        max-height: none;
    }
    
    .btn-toggle-panel {
        display: block;
    }
    
    .controls-panel.collapsed {
        height: auto !important;
        max-height: none !important;
        padding-bottom: 12px;
    }
    
    .controls-panel.collapsed > *:not(.panel-header):not(.play-reset-row):not(.gas-test-panel) {
        display: none !important;
    }
    
    .sim-overlay {
        display: none !important;
    }
}

@media (max-width: 600px) {
    header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 12px;
    }
    .header-left {
        width: 100%;
        justify-content: space-between;
    }
    .nav-btn.info {
        width: 100%;
        justify-content: center;
        margin-top: 4px;
    }
    .stats-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    .analysis-grid {
        grid-template-columns: 1fr;
    }
}
