/* ===== Douwco.be Theme ===== */

@font-face {
    font-family: 'Righteous';
    src: url('/fonts/Righteous.ttf') format('truetype');
}

@font-face {
    font-family: 'Montserrat';
    src: url('/fonts/Montserrat.ttf') format('truetype');
    font-weight: normal;
}

@font-face {
    font-family: 'Montserrat-Bold';
    src: url('/fonts/Montserrat.ttf') format('truetype');
    font-weight: bold;
}

:root {
    --background-clr: #283e3e;
    --background-accent-clr: #324f4f;
    --blue-clr: #47bcdf;
    --green-clr: #6ede9a;
    --purple-clr: #a48daa;
    --orange-clr: #e2a661;
    --white-clr: #ffffff;
    --text-clr: #e0e0e0;
    --border-clr: #47bcdf;
    --success-clr: #2ecc71;
    --warning-clr: #f39c12;
    --error-clr: #e74c3c;
}

/* ===== Base Styles ===== */

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Montserrat', sans-serif;
}

body {
    background-color: var(--background-clr);
    color: var(--text-clr);
    min-height: 100vh;
}

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Righteous', sans-serif;
    color: var(--white-clr);
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-align: center;
    color: var(--white-clr);
}

h2 {
    font-size: 1.8rem;
    margin: 0 0 1rem 0;
    color: var(--white-clr);
}

h3 {
    font-size: 1.2rem;
    margin: 1rem 0 0.75rem 0;
    color: var(--white-clr);
}

h4 {
    font-size: 1rem;
    margin: 1.25rem 0 0.5rem 0;
    color: var(--white-clr);
}

p {
    line-height: 1.6;
    margin: 0.5rem 0;
}

a {
    color: var(--blue-clr);
    text-decoration: none;
}

a:hover {
    color: var(--green-clr);
}

.subtitle {
    text-align: center;
    max-width: 760px;
    margin: 0 auto 2rem auto;
    color: var(--text-clr);
}

/* ===== Section cards (vertical, scrollable layout) ===== */

.section-card {
    background-color: var(--background-accent-clr);
    border-radius: 15px;
    padding: 1.5rem 2rem;
    margin: 0 auto 2rem auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.section-hint {
    font-size: 0.9rem;
    color: var(--text-clr);
    opacity: 0.85;
    margin: 0.5rem 0;
}

/* ===== Upload cards ===== */

.upload-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
}

.upload-card {
    background-color: var(--background-clr);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-clr);
}

.upload-card h3 {
    margin-top: 0;
}

.upload-info {
    font-size: 0.85rem;
    color: var(--green-clr);
    margin: 0.5rem 0 0 0;
}

.file-loaded {
    color: var(--success-clr);
}

/* File input: the whole dashed box is a <label> for the hidden file input */

.file-input-wrapper {
    display: block;
    cursor: pointer;
    border: 2px dashed var(--border-clr);
    border-radius: 8px;
    padding: 1.25rem;
    text-align: center;
    transition: all 0.3s ease;
    margin: 0.5rem 0;
}

.file-input-wrapper:hover {
    border-color: var(--blue-clr);
    background-color: rgba(71, 188, 223, 0.06);
}

.file-input-wrapper input[type="file"] {
    display: none;
}

.file-input-label {
    color: var(--blue-clr);
    font-weight: 600;
}

.file-name {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--green-clr);
    word-break: break-all;
}

/* ===== Dashboard: house on the left, graphs on the right ===== */

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(320px, 480px) 1fr;
    gap: 2rem;
    align-items: start;
}

.house-column {
    position: relative;
}

.house-layers {
    position: relative;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
}

.house-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.house-layer:first-child {
    position: relative;
    display: block;
}

.layer-on {
    filter: none;
}

.house-layer-clickable {
    pointer-events: auto;
    cursor: pointer;
}

.house-add-button {
    position: absolute;
    right: -10px;
    top: 42%;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid var(--green-clr);
    background-color: var(--background-clr);
    color: var(--green-clr);
    font-size: 1.8rem;
    line-height: 1;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 5;
}

.house-add-button:hover {
    background-color: var(--green-clr);
    color: var(--background-clr);
    transform: scale(1.1);
}

.water-status-panel {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--background-clr);
    border: 1px solid var(--border-clr);
    border-radius: 8px;
    padding: 0.5rem 0.9rem;
    font-size: 0.85rem;
    max-width: 480px;
    margin: 0.75rem auto 0 auto;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex: none;
}

.status-on {
    background-color: var(--blue-clr);
    box-shadow: 0 0 10px var(--blue-clr);
}

.status-off {
    background-color: #5a6a6a;
}

/* Improvement menu ("+" button) */

.improvement-menu {
    background-color: var(--background-clr);
    border: 1px solid var(--green-clr);
    border-radius: 10px;
    padding: 0.75rem;
    margin-top: 1rem;
    max-width: 480px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.improvement-menu .section-hint {
    margin-top: 0.75rem;
    margin-bottom: 0;
}

.improvement-menu-header {
    font-family: 'Montserrat-Bold', sans-serif;
    color: var(--white-clr);
    margin-bottom: 0.5rem;
}

.improvement-icon {
    width: 34px;
    height: 34px;
    flex: none;
}

.improvement-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    text-align: left;
    background-color: var(--background-accent-clr);
    border: 1px solid var(--border-clr);
    border-radius: 8px;
    color: var(--text-clr);
    padding: 0.6rem 0.9rem;
    margin: 0.35rem 0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.improvement-option:hover {
    border-color: var(--green-clr);
    background-color: rgba(110, 222, 154, 0.08);
}

.improvement-option.locked {
    opacity: 0.45;
    cursor: not-allowed;
}

.improvement-option-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
}

.improvement-option-title {
    font-family: 'Montserrat-Bold', sans-serif;
    color: var(--white-clr);
}

.improvement-option-hint {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* ===== Charts column ===== */

.charts-column {
    min-width: 0;
}

.chart-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.view-toggle {
    display: flex;
    gap: 0.5rem;
}

.chart-card {
    background-color: var(--background-clr);
    border: 1px solid var(--border-clr);
    border-radius: 12px;
    padding: 1rem 1.25rem 1.5rem 1.25rem;
    margin-bottom: 1.5rem;
}

.chart-card h3 {
    margin-top: 0;
}

.wattif-chart {
    width: 100%;
}

.estimated-note {
    font-size: 0.8rem;
    color: var(--warning-clr);
    margin: 0.5rem 0 0 0;
}

/* Time Period Toggle */

.time-toggle-container {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.time-toggle-button {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-clr);
    background-color: var(--background-accent-clr);
    color: var(--text-clr);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.9rem;
}

.time-toggle-button:hover {
    border-color: var(--blue-clr);
    background-color: rgba(71, 188, 223, 0.1);
}

.time-toggle-button.active {
    background: linear-gradient(135deg, var(--blue-clr), var(--green-clr));
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(71, 188, 223, 0.4);
}

/* ===== Improvement configuration cards ===== */

.improvement-config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
}

.improvement-config {
    background-color: var(--background-clr);
    border: 1px solid var(--border-clr);
    border-radius: 10px;
    overflow: hidden;
}

.improvement-config.open {
    border-color: var(--green-clr);
}

.improvement-config-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    color: var(--white-clr);
    background-color: var(--background-accent-clr);
}

.improvement-config-header .improvement-config-title {
    flex: 1;
    font-family: 'Montserrat-Bold', sans-serif;
}

.improvement-config-header:hover {
    background-color: rgba(71, 188, 223, 0.08);
}

.improvement-config-body {
    padding: 0.5rem 1rem 1rem 1rem;
}

.btn-remove {
    padding: 0.25rem 0.7rem;
    border: 1px solid var(--error-clr);
    border-radius: 6px;
    background: none;
    color: var(--error-clr);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-remove:hover {
    background-color: var(--error-clr);
    color: white;
}

.simulate-bar {
    display: flex;
    align-items: flex-start;
    gap: 2rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.sim-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.5rem 1.5rem;
    flex: 1;
    background-color: var(--background-clr);
    border-left: 4px solid var(--blue-clr);
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
}

.sim-summary strong {
    color: var(--green-clr);
}

/* ===== Forms ===== */

.input-group {
    margin-bottom: 1rem;
    flex: 1;
    min-width: 140px;
}

.input-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: var(--text-clr);
    font-size: 0.9rem;
}

.input-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

input[type="number"],
select {
    padding: 0.5rem 0.6rem;
    border: 2px solid var(--background-clr);
    border-radius: 8px;
    background-color: var(--background-clr);
    color: var(--white-clr);
    font-family: 'Montserrat', sans-serif;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    width: 130px;
}

select {
    width: 100%;
    max-width: 320px;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--blue-clr);
    box-shadow: 0 0 10px rgba(71, 188, 223, 0.5);
}

input[type="number"] {
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0.75rem 0;
    cursor: pointer;
    font-size: 0.95rem;
}

input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--green-clr);
}

/* Buttons */

.btn-primary,
.btn-secondary {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--blue-clr), var(--green-clr));
    color: white;
    font-family: 'Montserrat-Bold', sans-serif;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-secondary {
    background: var(--background-clr);
    border: 2px solid var(--border-clr);
    color: var(--text-clr);
    font-size: 0.85rem;
    text-transform: none;
}

.btn-primary:hover,
.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(71, 188, 223, 0.4);
}

/* ===== Contract editors ===== */

.contract-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.5rem;
    margin: 1rem 0;
}

.contract-editor {
    background-color: var(--background-clr);
    border: 1px solid var(--border-clr);
    border-radius: 10px;
    padding: 1rem 1.25rem;
}

.contract-editor h3 {
    margin-top: 0;
}

.gas-editor {
    max-width: 520px;
}

.alt-contract-header {
    margin: 0.75rem 0;
}

.monthly-rates-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.monthly-rate-cell label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-clr);
    margin-bottom: 0.25rem;
}

.monthly-rate-cell input {
    width: 100%;
}

/* ===== Cost results ===== */

.cost-results {
    margin-top: 1.5rem;
}

.cost-table,
.peak-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.92rem;
}

.cost-table th,
.cost-table td,
.peak-table th,
.peak-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-clr);
}

.cost-table th,
.peak-table th {
    color: var(--blue-clr);
    font-family: 'Montserrat-Bold', sans-serif;
}

.cost-table .cost-total td {
    border-top: 2px solid var(--green-clr);
    background-color: rgba(110, 222, 154, 0.06);
}

.cost-table .cost-saving td {
    color: var(--green-clr);
    font-family: 'Montserrat-Bold', sans-serif;
    background-color: rgba(110, 222, 154, 0.1);
}

.approximation-note {
    font-size: 0.8rem;
    opacity: 0.8;
    background-color: rgba(243, 156, 18, 0.08);
    border-left: 4px solid var(--warning-clr);
    padding: 0.75rem 1rem;
    border-radius: 8px;
}

.peak-improved {
    color: var(--success-clr);
}

/* ===== Messages ===== */

.info-text {
    background-color: rgba(71, 188, 223, 0.1);
    border-left: 4px solid var(--blue-clr);
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    font-size: 0.95rem;
}

.success-message {
    background-color: rgba(46, 204, 113, 0.2);
    border-left: 4px solid var(--success-clr);
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    font-size: 1rem;
    color: var(--success-clr);
}

.error-message {
    background-color: rgba(231, 76, 60, 0.2);
    border-left: 4px solid var(--error-clr);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    font-size: 0.9rem;
    color: var(--error-clr);
}

/* ===== Loading states ===== */

.loading-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--orange-clr);
}

.spinner {
    width: 22px;
    height: 22px;
    border: 3px solid var(--background-clr);
    border-top-color: var(--blue-clr);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

/* ===== Chart Styling (Radzen) ===== */

:root {
    --rz-color-primary: var(--blue-clr);
    --rz-color-secondary: var(--green-clr);
    --rz-color-text: var(--white-clr);
    --rz-color-surface: var(--background-accent-clr);
    --rz-color-border: var(--border-clr);
}

.rz-chart text {
    fill: var(--white-clr) !important;
    font-family: 'Montserrat', sans-serif !important;
}

.rz-gridline line {
    stroke: var(--background-accent-clr) !important;
}

/* The chart frame is a light "paper" panel inside the dark UI: dark lines read best
   on it. It also reserves the band below the chart where the embedded legend sits,
   so the legend stays part of the graph without covering the X-axis labels. */
.chart-frame {
    background-color: #e9ede8;
    border-radius: 10px;
    padding: 0.5rem 0.5rem 0 0.5rem;
    height: 536px;
    position: relative;
}

.wattif-chart text {
    fill: #263838 !important;
    font-family: 'Montserrat', sans-serif !important;
}

/* Radzen renders the legend as HTML spans, not SVG text: recolor those too. */
.wattif-chart .rz-legend-item-text {
    color: #263838;
}

/* The embedded legend is absolutely positioned inside the chart div; offset it into
   the frame's bottom band (below the chart drawing) so it can never cover the
   X-axis labels. The chart div itself has a fixed height through Radzen's Style
   parameter, so Radzen measures it correctly. */
.wattif-chart .rz-legend-bottom {
    bottom: -84px;
}

.wattif-chart .rz-legend-items {
    flex-wrap: wrap;
    padding: 0 0.5rem;
}

.wattif-chart .rz-gridline line {
    stroke: #c8d2ca !important;
}

/* ===== Responsive ===== */

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

    .house-layers,
    .water-status-panel,
    .improvement-menu {
        max-width: 420px;
    }

    .monthly-rates-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    main {
        padding: 10px;
    }

    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.4rem;
    }

    .section-card {
        padding: 1rem;
    }

    .monthly-rates-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .cost-table {
        font-size: 0.8rem;
    }
}
