/* Custom CSS for KEJD 3D Visualisering */

:root {
    --primary-color: #003989;
    --background-color: #F5F3E8;
    --border-color: #ddd;
    --text-color: #333;
    --panel-width: 60%;
    --panel-collapsed-width: 50px;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Roboto', sans-serif;
    background-color: var(--background-color);
    overflow: hidden;
}

.container-fluid, .row, .col, .side-panel {
    height: 100%;
    min-height: 0;
}

#sceneView {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

/* Side Panel Styles */
.side-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: var(--panel-width);
    background-color: white;
    border-left: 2px solid var(--border-color);
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: transform 0.3s ease-in-out;
    transform: translateX(100%);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.side-panel.collapsed {
    transform: translateX(calc(100% - 40px));
}

.side-panel.expanded {
    transform: translateX(0);
}

.side-panel-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 5px;
    background-color: var(--primary-color);
    color: white;
    border-bottom: 1px solid var(--border-color);
    min-height: 50px;
    gap: 0;
    flex: 0 0 auto;
}

.side-panel-header h5 {
    margin: 0;
    font-weight: 500;
    font-size: 14px;
    flex: 1;
    transition: opacity 0.2s;
}

.side-panel.collapsed .side-panel-header h5 {
    opacity: 0;
    width: 0;
    overflow: hidden;
    padding: 0;
    margin: 0;
}

.toggle-btn {
    background: transparent;
    border: none;
    color: white;
    padding: 5px;
    border-radius: 3px;
    transition: all 0.3s ease;
    font-size: 14px;
    min-width: 30px;
    min-height: 30px;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: none;
}

.toggle-btn:focus {
    outline: none;
    box-shadow: none;
}

.side-panel-content {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    padding: 8px;
    overflow: hidden;
}

.placeholder-content {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-color);
    min-height: 200px;
}

/* Bootstrap overrides */
.btn-outline-secondary {
    border-color: white;
    color: white;
}

.btn-outline-secondary:hover {
    background-color: white;
    color: var(--primary-color);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .side-panel {
        width: 80%;
    }
    
    .side-panel.collapsed {
        transform: translateX(calc(100% - 40px));
    }
}

/* Loading spinner */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
    color: var(--primary-color);
}

.collapsed-label {
    position: absolute;
    top: 50%;
    left: 20px;
    transform: translate(-50%, -50%) rotate(-90deg);
    white-space: nowrap;
    color: #003989;
    font-weight: bold;
    font-size: 16px;
    letter-spacing: 2px;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.2s;
    z-index: 1050;
}

.side-panel.expanded .collapsed-label {
    opacity: 0;
    pointer-events: none;
}

.side-panel.collapsed .collapsed-label {
    opacity: 1;
    pointer-events: auto;
}

.consumption-overlay {
    position: absolute;
    top: 80px; /* Lidt luft under uge-vælgeren */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    z-index: 1200;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.side-panel.expanded ~ .consumption-overlay {
    top: 140px; /* Lidt luft under uge-vælgeren */
    left: 20px;
    transform: none;
}

.consumption-btn-row {
    display: flex;
    gap: 24px;
    margin-bottom: 8px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.consumption-btn {
    background: #fff;
    color: #003989;
    border: 2px solid #003989;
    border-radius: 18px;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 6px 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border 0.2s, box-shadow 0.2s;
    outline: none;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.consumption-btn:hover, .consumption-btn.active {
    background: #003989;
    color: #fff;
    border-color: #003989;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.week-selector-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
    gap: 16px;
    height: 36px;
}

.week-arrow {
    background: none;
    border: none;
    color: #003989;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 8px;
    transition: color 0.2s;
    outline: none;
    display: flex;
    align-items: center;
}

.week-arrow:hover {
    color: #0055cc;
}

.week-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #003989;
    background: #fff;
    border-radius: 18px;
    padding: 6px 18px;
    cursor: pointer;
    border: 1.5px solid #003989;
    transition: background 0.2s, color 0.2s;
    user-select: none;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.week-label:hover {
    background: #003989;
    color: #fff;
}


/* NYT: Juster legend-position når sidepanelet er åbent */
.side-panel.expanded ~ .col .legend-container {
    left: calc(50% - (var(--panel-width) / 4)); /* Centrer mellem venstre side og sidepanelet */
}

/* Forbedret Loading spinner */
/* Tilføj dette til din styles.css */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
    display: none; /* Skjult som standard */
    flex-direction: column;
    align-items: center;
    gap: 15px;
    background-color: rgba(255, 255, 255, 0.85);
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.loading-text {
    font-size: 1rem;
    font-weight: 500;
    color: var(--primary-color);
}

/* Skjul ArcGIS' standard navigationsknapper */
.esri-view-controls {
    display: none !important;
}

/* Skjul også andre ArcGIS UI elementer der ikke passer til designet */
.esri-attribution {
    display: none !important;
}

.esri-view-height-medium .esri-view-controls {
    display: none !important;
}

/* Styling for Power BI container i sidepanelet */
.power-bi-container {
    width: 100%;
    aspect-ratio: 16 / 9;
    position: relative;
    margin-bottom: 8px;
    flex: 0 0 auto;
}

.power-bi-container iframe,
.powerbi-placeholder {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 100%;
}

/* Placeholder styling */
.powerbi-placeholder {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 1.1rem;
    font-weight: 500;
    background-color: #ffffff;
    border-radius: 8px;
    z-index: 2;
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

.powerbi-placeholder.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Chart container styling */
.chart-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    margin-top: 0;
    display: flex;
    flex-direction: column;
}

/* Info container */
.info-container {
    flex: 0 0 auto;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
}

.info-container.visible {
    max-height: 200px;
    opacity: 1;
}

.info-placeholder {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
    background-color: #f8f9fa;
    border-radius: 5px;
    border: 1px dashed #ccc;
}

.info-table {
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.info-table h6 {
    margin-bottom: 15px;
    color: var(--primary-color);
    font-weight: 600;
}

.info-table .table {
    margin-bottom: 0;
}

.info-table .table td {
    padding: 8px 12px;
    border: none;
    font-size: 14px;
}

.info-table .table td:first-child {
    font-weight: 500;
    color: #555;
    width: 40%;
}

/* Layout ændringer når bygning er valgt */
.chart-container.with-info {
    flex: 0 0 66.666667%; /* 2/3 af pladsen */
}

.info-container.with-info {
    flex: 0 0 33.333333%; /* 1/3 af pladsen */
    max-height: none;
    opacity: 1;
}

#myCustomChart {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* Styling for det nye søgefelt */
.search-widget {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 50;
    display: flex;
    background-color: white;
    padding: 5px;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 2px solid #003989;
}

.search-widget input {
    border: none;
    padding: 6px 12px;
    font-size: 0.9rem;
    outline: none;
    background: transparent;
    color: #003989;
    font-weight: 600;
    min-width: 200px;
}

.search-widget input::placeholder {
    color: #003989;
    opacity: 0.7;
}

.search-widget button {
    border: none;
    background-color: #003989;
    color: white;
    padding: 6px 12px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.2s;
}

.search-widget button:hover {
    background-color: #0055cc;
}

/* NYT: Styling for clear-knappen */
.clear-btn {
    border: none;
    background-color: #dc3545;
    color: white;
    padding: 6px 12px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.2s;
    margin-left: 5px;
}

.clear-btn:hover {
    background-color: #c82333;
}

/* Styling for uge-vælger overlay */
.week-selector-overlay {
    position: absolute;
    top: 20px; /* Matcher søgefeltets top */
    left: 50%;
    transform: translateX(-50%);
    z-index: 1200;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.week-selector-overlay .week-selector-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    height: 36px;
}

/* Animation når sidepanelet åbnes - flyt til venstre side og lav vertikal stak */
.side-panel.expanded ~ .week-selector-overlay {
    top: 80px; /* Lidt længere nede for at centrere under søgefeltet */
}

.side-panel.expanded ~ .consumption-overlay {
    top: 140px; /* Lidt luft under uge-vælgeren */
}

/* Vertikal stak når sidepanelet er åbent */
.side-panel.expanded ~ .consumption-overlay .consumption-btn-row {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 0;
}

.side-panel.expanded ~ .consumption-overlay .consumption-btn {
    width: 120px;
    justify-content: center;
}

#customChartContainer {
    width: 100%;
    margin-top: 0px; /* Lidt luft op til Power BI-sektionen */
    background: #ffffff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.07);
}

/* NYT: Styling for chart container og canvas */
#chartContainer {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.07);
    margin-top: 20px;
}

.tooltip {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    pointer-events: none; /* Vigtigt, så den ikke blokerer for muse-events */
    z-index: 1500;
    opacity: 0;
    transform: translate(-50%, -120%); /* Positioner over cursoren */
    transition: opacity 0.1s ease-in-out;
    white-space: nowrap;
}

.tooltip.visible {
    opacity: 1;
}

/* --- Styling for Legend --- */
.legend-container {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    width: 30%;
    max-width: 400px;
    background-color: white;
    border-radius: 16px;
    padding: 15px 20px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    z-index: 40;
    transition: left 0.3s ease-in-out, opacity 0.3s, visibility 0.3s;
    opacity: 0;
    visibility: hidden;
    border: 2px solid #003989;
}

.legend-container.visible {
    opacity: 1;
    visibility: visible;
}

.legend-title {
    text-align: center;
    font-weight: 500;
    margin-bottom: 10px;
    font-size: 15px;
    color: #333;
}

/* Wrapper der styrer placering af labels og markører */
.legend-gradient-wrapper {
    position: relative;
    padding-top: 25px; /* Plads til min/max over stregen */
    padding-bottom: 40px; /* Plads til markører under stregen */
}

/* Min/Max labels placeret ØVERST */
.legend-labels-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    padding: 0 2px;
}

/* Selve farvebjælken */
#legendGradient {
    height: 15px;
    border-radius: 7.5px;
    width: 100%;
}

/* Fælles styling for markører placeret NEDERST */
.legend-boundary-marker, .legend-avg-marker {
    position: absolute;
    bottom: 0;
    transform: translateX(-50%);
    text-align: center;
}

/* Linjerne på markørerne */
.legend-boundary-line, .legend-avg-line {
    width: 2px;
    height: 15px;
    background-color: #333;
    margin: 0 auto; /* Centrerer linjen */
}
.legend-avg-line {
    background-color: #003989; /* Gør gns-stregen blå */
}

/* Label-boksene under markør-linjerne */
.legend-boundary-label, .legend-avg-label {
    font-size: 11px;
    font-weight: 600;
    color: #333;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 2px 5px;
    border-radius: 4px;
    white-space: nowrap;
    margin-top: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.legend-avg-label {
    color: #003989;
}

/* Gammel container, der skal være skjult */
.legend-labels {
    display: none;
}