:root {
    /* Główne kolory */
    --sky-blue: #87CEEB;
    --ocean-blue: #006994;
    --land-brown: #8B7355;
    --grass-green: #4A7C3A;
    --cloud-white: rgba(255, 255, 255, 0.9);
    --cloud-gray: rgba(100, 100, 110, 0.8);

    /* Proces kolory */
    --vapor-color: rgba(173, 216, 230, 0.5);
    --rain-color: rgba(100, 150, 200, 0.7);
    --groundwater-color: #0D47A1;

    /* UI kolory */
    --primary: #2196F3;
    --primary-dark: #1976D2;
    --success: #4CAF50;
    --warning: #FF9800;
    --danger: #F44336;

    /* Tło i tekst */
    --bg-gradient-start: #ffffff;
    --bg-gradient-end: #ffffff;
    --panel-bg: rgba(255, 255, 255, 0.95);
    --text-primary: #1565C0;
    --text-secondary: #64B5F6;
    --border-color: rgba(33, 150, 243, 0.2);
}

[data-theme="dark"] {
    --bg-gradient-start: #0D47A1;
    --bg-gradient-end: #1565C0;
    --panel-bg: rgba(21, 101, 192, 0.15);
    --text-primary: #E3F2FD;
    --text-secondary: #BBDEFB;
    --border-color: rgba(144, 202, 249, 0.2);
}

[data-theme="dark"] .header h1,
[data-theme="dark"] .control-section h3,
[data-theme="dark"] .stats-section h3,
[data-theme="dark"] .control-group .value,
[data-theme="dark"] .percentage,
[data-theme="dark"] .process-rate,
[data-theme="dark"] .tab-btn.active,
[data-theme="dark"] .tab-content h3,
[data-theme="dark"] .tab-content h4 {
    color: var(--text-primary);
}

[data-theme="dark"] .stats-section,
[data-theme="dark"] .knowledge-fact,
[data-theme="dark"] .fact-item,
[data-theme="dark"] .modal-tabs {
    background: rgba(227, 242, 253, 0.12);
}

[data-theme="dark"] .balance-value,
[data-theme="dark"] .tab-btn,
[data-theme="dark"] .modal-close {
    color: var(--text-secondary);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    min-height: 100vh;
    color: var(--text-primary);
}

.container {
    width: 100%;
    max-width: 1920px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    border-bottom: 2px solid var(--border-color);
}

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

.header-left .icon {
    font-size: 2rem;
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

.header-right {
    display: flex;
    gap: 10px;
}

.icon-btn {
    width: 45px;
    height: 45px;
    border: none;
    background: var(--primary);
    color: white;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

/* Main Content */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr);
    gap: 20px;
    padding: 20px;
}

/* Panels */
.controls-panel,
.stats-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid var(--border-color);
    overflow-y: auto;
    max-height: calc(100vh - 140px);
}

.simulation-panel {
    min-width: 0;
    display: grid;
    grid-template-rows: minmax(420px, 1fr) auto;
    gap: 20px;
}

.visualization-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: stretch;
    justify-content: center;
    min-height: clamp(420px, 62vh, 760px);
}

.stats-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
    overflow: visible;
    max-height: none;
}

.stats-section {
    margin-bottom: 0;
    padding: 18px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid var(--border-color);
}

/* Control Section */
.control-section {
    margin-bottom: 25px;
}

.control-section h3 {
    font-size: 1rem;
    margin-bottom: 15px;
    color: var(--primary);
    font-weight: 600;
}

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

.control-group label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

.control-group .value {
    color: var(--primary);
    font-weight: 600;
}

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

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

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: var(--primary-dark);
}

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

/* Preset Buttons */
.preset-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.preset-btn {
    padding: 12px;
    border: 2px solid var(--border-color);
    background: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.preset-btn span:first-child {
    font-size: 1.5rem;
}

.preset-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
}

/* Simulation Controls */
.simulation-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

.control-btn {
    padding: 10px;
    border: none;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.control-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.control-btn.paused {
    background: var(--warning);
}

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

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

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

/* Canvas */
#waterCycle {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 12px;
    background: linear-gradient(to bottom, var(--sky-blue) 0%, #E0F6FF 100%);
}

/* Stats Section */
.stats-section h3 {
    font-size: 1rem;
    margin-bottom: 15px;
    color: var(--primary);
    font-weight: 600;
}

/* Water Balance */
.water-balance {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.balance-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.balance-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 500;
}

.percentage {
    color: var(--primary);
    font-weight: 600;
}

.balance-bar {
    width: 100%;
    height: 20px;
    background: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.balance-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s ease;
}

.balance-fill.vapor {
    background: linear-gradient(90deg, #b3e5fc, #81d4fa);
}

.balance-fill.clouds {
    background: linear-gradient(90deg, #e0e0e0, #bdbdbd);
}

.balance-fill.ocean {
    background: linear-gradient(90deg, #0288d1, #0277bd);
}

.balance-fill.groundwater {
    background: linear-gradient(90deg, #1565c0, #0d47a1);
}

.balance-fill.rivers {
    background: linear-gradient(90deg, #29b6f6, #039be5);
}

.balance-value {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Process Meters */
.processes {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.process-meter {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.process-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 500;
}

.process-rate {
    color: var(--primary);
    font-weight: 600;
}

.meter-bar {
    width: 100%;
    height: 12px;
    background: var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.3s ease;
}

.meter-fill.evap {
    background: linear-gradient(90deg, #ff9800, #f57c00);
}

.meter-fill.cond {
    background: linear-gradient(90deg, #9e9e9e, #757575);
}

.meter-fill.precip {
    background: linear-gradient(90deg, #2196f3, #1976d2);
}

/* Knowledge */
.knowledge-fact {
    padding: 15px;
    background: rgba(33, 150, 243, 0.1);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 15px;
}

.learn-btn {
    width: 100%;
    padding: 12px;
    border: none;
    background: var(--primary);
    color: white;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.learn-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    overflow: hidden;
    border: 2px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    border-bottom: 2px solid var(--border-color);
}

.modal-header h2 {
    color: var(--primary);
    font-size: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: var(--danger);
}

.modal-tabs {
    display: flex;
    padding: 0 30px;
    background: rgba(33, 150, 243, 0.05);
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    padding: 15px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    color: var(--primary);
}

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

.modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
}

.tab-content {
    display: none;
}

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

.tab-content h3 {
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.tab-content h4 {
    color: var(--primary);
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.tab-content p {
    line-height: 1.7;
    margin-bottom: 15px;
}

.tab-content ul {
    margin-left: 20px;
    margin-bottom: 15px;
    line-height: 1.7;
}

.fact-item {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(33, 150, 243, 0.05);
    border-radius: 10px;
}

.fact-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

/* Responsive */
@media (max-width: 880px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
    }

    .controls-panel,
    .stats-panel {
        max-height: none;
    }

    .simulation-panel {
        grid-template-rows: minmax(360px, auto) auto;
    }

    .preset-buttons {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 768px) {
    .header {
        padding: 15px 20px;
    }

    .header h1 {
        font-size: 1.3rem;
    }

    .main-content {
        padding: 15px;
        gap: 15px;
    }

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

    .preset-buttons {
        grid-template-columns: 1fr 1fr;
    }

    #waterCycle {
        max-height: 400px;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .modal-body {
        padding: 20px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Tryb pełnoekranowy — ciemne tło */
:fullscreen body,
:-webkit-full-screen body,
:-moz-full-screen body,
html:fullscreen body,
html:-webkit-full-screen body {
    background: linear-gradient(135deg, #0a0a0f, #0f0f1a) !important;
}
