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

:root {
    --primary-color: #2c3e50;
    --accent-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #e74c3c;
    --bg-color: #ecf0f1;
    --card-bg: #ffffff;
    --text-color: #2c3e50;
    --border-color: #bdc3c7;
    --isothermal-color: #e74c3c;
    --adiabatic-color: #3498db;
    --heat-in-color: #e74c3c;
    --heat-out-color: #3498db;
    --work-color: #27ae60;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-color);
}

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

/* Header */
header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1.2em;
    opacity: 0.9;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 1100px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* Canvas Section */
.canvas-section {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Right Controls */
.right-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Bottom Controls Row */
.bottom-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .bottom-controls {
        grid-template-columns: 1fr;
    }
}

.canvas-container {
    width: 100%;
    height: 500px;
    position: relative;
    margin-bottom: 15px;
}

#pvCanvas {
    width: 100%;
    height: 100%;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: #fafafa;
}

/* Legend */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
}

.legend-color {
    width: 30px;
    height: 4px;
    border-radius: 2px;
}

.legend-color.isothermal {
    background: var(--isothermal-color);
}

.legend-color.adiabatic {
    background: var(--adiabatic-color);
}

.legend-color.heat-in {
    background: var(--heat-in-color);
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.legend-color.heat-out {
    background: var(--heat-out-color);
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

/* Control Cards */
.control-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.control-card h3 {
    color: var(--primary-color);
    margin-bottom: 12px;
    font-size: 0.95em;
    font-weight: 600;
}

/* Control Groups */
.control-group {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.control-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.control-group h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-item {
    margin-bottom: 15px;
}

.control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 500;
}

.value-display {
    background: var(--accent-color);
    color: white;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.9em;
    font-weight: 600;
    min-width: 70px;
    text-align: center;
}

/* Range Slider */
input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--bg-color);
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
}

/* Buttons */
.substance-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.substance-btn {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85em;
    text-align: center;
}

.substance-btn {
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9em;
    text-align: left;
}

.substance-btn:hover {
    border-color: var(--accent-color);
    background: #f0f8ff;
}

.substance-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.animation-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.control-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s;
    background: var(--accent-color);
    color: white;
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(52, 152, 219, 0.4);
}

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

/* Checkbox */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 0;
    transition: all 0.2s;
    font-size: 0.9em;
}

.checkbox-label:hover {
    color: var(--accent-color);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-color);
}

/* Stats Panel */
.stats-panel {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid var(--accent-color);
}

.stat-label {
    font-size: 0.85em;
    color: #7f8c8d;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.3em;
    font-weight: 700;
    color: var(--primary-color);
}

/* Formula Section */
.formula-section {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
}

.formula-section h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.1em;
}

.formula-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
}

.formula-item {
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid var(--accent-color);
}

.formula-item span {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--primary-color);
    font-size: 0.9em;
}

.formula-item code {
    background: white;
    padding: 8px 12px;
    border-radius: 5px;
    display: block;
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
    color: var(--accent-color);
    border: 1px solid var(--border-color);
}

/* Explanation Section */
.explanation {
    padding: 30px;
    background: #fafafa;
    border-top: 1px solid #e5e7eb;
    border-radius: 15px;
}

.explanation h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: #0c4a6e;
    margin-bottom: 15px;
}

.explanation h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #0369a1;
    margin: 20px 0 10px;
}

.explanation p {
    line-height: 1.8;
    color: #374151;
    margin-bottom: 12px;
}

/* Language Selector */
/* Removed - language is auto-detected from HTML lang attribute */

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

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

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

    .subtitle {
        font-size: 1em;
    }

    .canvas-container {
        height: 350px;
    }

    .stats-panel {
        grid-template-columns: 1fr;
    }

    .formula-list {
        grid-template-columns: 1fr;
    }
}
