:root {
    --primary-color: #dc2626;
    --secondary-color: #ea580c;
    --success-color: #16a34a;
    --danger-color: #dc2626;
    --warning-color: #f59e0b;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #475569;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.battery-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(220, 38, 38, 0.3);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Tabs Navigation */
.tabs-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.tab-btn {
    padding: 12px 24px;
    background: var(--surface);
    color: var(--text);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: var(--surface-light);
    border-color: var(--primary-color);
}

.tab-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Tab Content */
.tab-content {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    min-height: 600px;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Visualization Layout */
.visualization-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 1024px) {
    .visualization-layout {
        grid-template-columns: 1fr;
    }
}

/* Canvas Containers */
.battery-display,
.charge-display,
.voltage-display,
.ragone-display,
.lifecycle-display,
.safety-display {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border);
}

.battery-display h3,
.charge-display h3,
.voltage-display h3,
.ragone-display h3,
.lifecycle-display h3,
.safety-display h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
    font-size: 1.3rem;
}

canvas {
    width: 100%;
    border-radius: 8px;
    background: var(--background);
    display: block;
}

#structureCanvas,
#chargeCanvas,
#voltageCanvas,
#ragoneCanvas,
#lifecycleCanvas,
#safetyCanvas {
    height: 400px;
}

/* Info Displays */
.structure-legend,
.process-info,
.voltage-info,
.ragone-info,
.lifecycle-info,
.safety-info {
    margin-top: 15px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.legend-item,
.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: var(--surface-light);
    border-radius: 6px;
    font-size: 0.9rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Controls Panel */
.controls-panel {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border);
    height: fit-content;
}

.controls-panel h3 {
    margin-bottom: 20px;
    color: var(--primary-color);
    font-size: 1.2rem;
}

.control-group {
    margin-bottom: 20px;
}

.control-group h4 {
    margin-bottom: 10px;
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--surface-light);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.control-button {
    flex: 1;
    min-width: 120px;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-button.charge {
    background: var(--success-color);
    color: white;
}

.control-button.discharge {
    background: var(--warning-color);
    color: white;
}

.control-button.stop {
    background: var(--danger-color);
    color: white;
}

.control-button.reset,
.control-button.start {
    background: var(--surface-light);
    color: var(--text);
}

.control-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.control-button:active {
    transform: translateY(0);
}

.view-btn,
.curve-btn,
.battery-btn,
.test-btn {
    padding: 8px 16px;
    margin: 4px;
    background: var(--surface-light);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.view-btn:hover,
.curve-btn:hover,
.battery-btn:hover,
.test-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.view-btn.active,
.curve-btn.active,
.battery-btn.active,
.test-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Formula Section */
.formula-section {
    margin-top: 20px;
    padding: 15px;
    background: var(--surface-light);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.formula-section h4 {
    margin-bottom: 10px;
    color: var(--text);
}

.formula {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    color: var(--primary-color);
    text-align: center;
    padding: 10px;
    margin-bottom: 10px;
}

.formula-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.formula-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
}

.formula-label {
    font-weight: 600;
    color: var(--text);
}

.formula-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-top: 10px;
}

/* Explanation Section */
.explanation-section {
    margin-top: 20px;
    padding: 15px;
    background: var(--surface-light);
    border-radius: 8px;
}

.explanation-section h4 {
    margin-bottom: 10px;
    color: var(--text);
}

.explanation-section p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Main Explanation Section */
.explanation {
    margin-top: 40px;
    padding: 30px;
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.explanation h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.8rem;
}

.explanation h3 {
    color: var(--secondary-color);
    margin-top: 25px;
    margin-bottom: 15px;
    font-size: 1.4rem;
}

.explanation p {
    color: var(--text-muted);
    line-height: 1.8;
    margin-bottom: 15px;
}

.explanation strong {
    color: var(--text);
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .tabs-nav {
        flex-direction: column;
    }

    .tab-btn {
        width: 100%;
    }

    .button-group {
        flex-direction: column;
    }

    .control-button {
        width: 100%;
    }

    .structure-legend,
    .process-info,
    .voltage-info,
    .ragone-info,
    .lifecycle-info,
    .safety-info {
        grid-template-columns: 1fr;
    }
}

/* Animations */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px var(--primary-color);
    }
    50% {
        box-shadow: 0 0 20px var(--primary-color);
    }
}

.glow {
    animation: glow 2s ease-in-out infinite;
}
