/**
 * Thuisbatterij Simulatie - Stylesheet
 * Modern, clean, responsive design
 */

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #059669;
    --danger-color: #dc2626;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background);
}

/* Navigation */
nav {
    background-color: var(--surface);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

nav h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary-color);
}

/* Container */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
}

/* Two column layout */
.layout-two-column {
    display: grid;
    grid-template-columns: 450px 1fr;
    gap: 2rem;
    align-items: start;
}

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

/* Intro section */
.intro {
    text-align: center;
    margin-bottom: 3rem;
}

.intro h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.intro p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 800px;
    margin: 0 auto;
}

/* Form sections */
.simulation-form {
    background-color: var(--surface);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

@media (min-width: 1025px) {
    .simulation-form {
        position: sticky;
        top: 80px;
    }
}

.form-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.form-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.2rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-group small {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.form-group-inline {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.form-group-inline label {
    font-weight: 500;
    color: var(--text-primary);
    min-width: 220px;
    flex-shrink: 0;
}

.form-group-inline input {
    flex: 1;
    max-width: 120px;
}

.form-group .formula-display {
    display: block;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background-color: var(--background);
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    line-height: 1.6;
}

.form-group input[type="number"],
.form-group select {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input[type="number"]:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-actions {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
}

button {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

button[type="submit"] {
    background-color: var(--primary-color);
    color: white;
}

button[type="submit"]:hover:not(:disabled) {
    background-color: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

button[type="submit"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: var(--text-secondary);
    color: white;
}

.btn-secondary:hover {
    background-color: #475569;
}

/* Progress */
.progress-container {
    margin: 2rem 0;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 24px;
    background-color: var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.3s ease;
    border-radius: 12px;
}

#progressText {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Results section */
.results-section {
    margin-top: 3rem;
}

.results-section h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    text-align: center;
}

.totals-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 3rem;
}

/* Better layout for medium screens (13" laptops) */
@media (min-width: 769px) and (max-width: 1440px) {
    .totals-summary {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }

    .total-card {
        padding: 0.875rem 1rem;
    }

    .total-value {
        font-size: 1.35rem;
    }
}

.total-card {
    background-color: var(--surface);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.total-card h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.total-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.4;
}

.total-value small {
    font-size: 0.65rem;
    font-weight: 500;
}

.total-value.profit {
    color: var(--secondary-color);
}

/* Charts */
.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.chart-box {
    background-color: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.chart-box.full-width {
    grid-column: 1 / -1;
}

#timestepView {
    height: 500px;
}

#timestepChart {
    max-height: 450px;
}

.chart-box h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

/* Table */
.table-container {
    background-color: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    overflow-x: auto;
    margin-bottom: 2rem;
}

.table-container h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background-color: var(--background);
}

th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
}

td {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

tr:hover {
    background-color: var(--background);
}

.profit-positive {
    color: var(--secondary-color);
    font-weight: 600;
}

.profit-negative {
    color: var(--danger-color);
    font-weight: 600;
}

/* Export actions */
.export-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* Detail view */
.detail-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--background);
    z-index: 200;
    overflow-y: auto;
    padding: 2rem;
}

.detail-header {
    max-width: 1400px;
    margin: 0 auto 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.detail-nav {
    margin-left: auto;
    display: flex;
    gap: 0.5rem;
}

.btn-nav {
    background-color: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-nav:hover:not(:disabled) {
    background-color: #1d4ed8;
    transform: translateY(-1px);
}

.btn-nav:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-nav-small {
    background-color: var(--text-secondary);
    color: white;
    padding: 0.5rem 0.75rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-nav-small:hover:not(:disabled) {
    background-color: #475569;
    transform: translateY(-1px);
}

.btn-nav-small:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-back {
    background-color: var(--text-secondary);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-back:hover {
    background-color: #475569;
    transform: translateX(-3px);
}

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

/* Clickable rows */
.clickable-row {
    cursor: pointer;
    transition: background-color 0.2s;
}

.clickable-row:hover {
    background-color: rgba(37, 99, 235, 0.1);
}

/* Compact monthly table (9 columns) */
#monthlyTable {
    font-size: 0.9rem;
}

#monthlyTable th,
#monthlyTable td {
    padding: 0.625rem 0.5rem;
    white-space: nowrap;
}

#monthlyTable th {
    font-size: 0.85rem;
    line-height: 1.3;
}

#monthlyTable th small {
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

/* Hide some columns on smaller screens */
@media (max-width: 1200px) {
    #monthlyTable {
        font-size: 0.85rem;
    }

    #monthlyTable th,
    #monthlyTable td {
        padding: 0.5rem 0.375rem;
    }
}

@media (max-width: 1024px) {
    /* Hide least important columns on tablets */
    #monthlyTable th:nth-child(8),
    #monthlyTable td:nth-child(8),
    #monthlyTable th:nth-child(9),
    #monthlyTable td:nth-child(9) {
        display: none;
    }
}

@media (max-width: 768px) {
    /* Show only essential columns on mobile */
    #monthlyTable th:nth-child(4),
    #monthlyTable td:nth-child(4),
    #monthlyTable th:nth-child(5),
    #monthlyTable td:nth-child(5),
    #monthlyTable th:nth-child(6),
    #monthlyTable td:nth-child(6),
    #monthlyTable th:nth-child(7),
    #monthlyTable td:nth-child(7) {
        display: none;
    }
}

/* Content pages */
.content-page {
    background-color: var(--surface);
    border-radius: 12px;
    padding: 3rem;
    box-shadow: var(--shadow);
    margin: 2rem auto;
}

.content-page h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.content-page h3 {
    font-size: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.content-page h4 {
    font-size: 1.2rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.content-page section {
    margin-bottom: 2rem;
}

.content-page p {
    margin-bottom: 1rem;
    line-height: 1.8;
}

.content-page ul, .content-page ol {
    margin-left: 2rem;
    margin-bottom: 1rem;
}

.content-page li {
    margin-bottom: 0.5rem;
}

.content-page a {
    color: var(--primary-color);
    text-decoration: none;
}

.content-page a:hover {
    text-decoration: underline;
}

.content-page code {
    background-color: var(--background);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    background-color: var(--surface);
    margin-top: 4rem;
    border-top: 1px solid var(--border-color);
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive design */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    .container {
        padding: 1rem;
    }

    .intro h2 {
        font-size: 1.5rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .charts-container {
        grid-template-columns: 1fr;
    }

    .total-value {
        font-size: 1.25rem;
    }

    .content-page {
        padding: 1.5rem;
    }

    table {
        font-size: 0.9rem;
    }

    th, td {
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    nav h1 {
        font-size: 1.2rem;
    }

    .nav-links a {
        font-size: 0.9rem;
    }

    .intro h2 {
        font-size: 1.3rem;
    }

    .intro p {
        font-size: 1rem;
    }
}

/* Advanced page styles */

/* Compact form sections for advanced page */
.advanced-form .form-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
}

.advanced-form .form-section h3 {
    margin-bottom: 0.5rem;
}

.advanced-form .form-group-inline {
    margin-bottom: 0.5rem;
}

/* Heatmap */
.heatmap-container {
    width: 100%;
    overflow-x: auto;
}

.heatmap-grid {
    display: grid;
    gap: 2px;
    background: var(--border-color);
    padding: 2px;
    font-size: 0.85rem;
    width: fit-content;
    margin: 0 auto;
}

.heatmap-header-corner {
    background: var(--surface);
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.75rem;
    line-height: 1.2;
}

.heatmap-header {
    background: var(--surface);
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
}

.heatmap-row-header {
    background: var(--surface);
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
}

.heatmap-cell {
    padding: 0.75rem;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    min-width: 60px;
    font-weight: 500;
}

.heatmap-cell:not(.empty):hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
    z-index: 10;
}

.heatmap-cell.best {
    border: 3px solid var(--secondary-color);
    font-weight: bold;
    box-shadow: 0 0 10px rgba(5, 150, 105, 0.3);
}

.heatmap-cell.empty {
    background: var(--background);
    cursor: default;
    color: var(--text-secondary);
}

/* Color scale legend */
.color-scale {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
}

.color-scale-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.color-scale-bar {
    flex: 1;
    height: 20px;
    background: linear-gradient(to right,
        rgb(59, 130, 246),   /* blue */
        rgb(16, 185, 129),   /* green */
        rgb(251, 191, 36),   /* yellow */
        rgb(245, 158, 11)    /* orange */
    );
    border-radius: 4px;
}

.color-scale-range {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 600;
    min-width: 120px;
    text-align: right;
}

/* Efficiency preview */
.efficiency-preview {
    background: var(--background);
    padding: 1rem;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    margin-top: 1rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-content {
    background-color: var(--surface);
    border-radius: 12px;
    padding: 2rem;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin: 0;
}

/* Config details */
.config-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.detail-card {
    background: var(--background);
    padding: 1.5rem;
    border-radius: 8px;
}

.detail-card h4 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.detail-card p {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* Responsive heatmap */
@media (max-width: 768px) {
    .heatmap-grid {
        font-size: 0.75rem;
    }

    .heatmap-cell {
        min-width: 50px;
        padding: 0.5rem;
    }

    .heatmap-header,
    .heatmap-row-header {
        padding: 0.5rem;
    }

    .config-details {
        grid-template-columns: 1fr;
    }
}
