/* ==========================================================================
   app.css – Wallbox-Monitor im INEOS Corporate Design
   Markenfarbe: Britannia Blue #071637, roter Akzent #D62E2F.
   Industriell-cleaner Stil: flache Flächen, dezente Rundungen, klare Typo.
   Konsolidiert aus den früheren 7 CSS-Dateien.
   ========================================================================== */

:root {
    /* INEOS Corporate */
    --ineos-blue:       #071637;  /* Britannia Blue – Primär */
    --ineos-blue-700:   #0d2350;  /* Hover/dunkler */
    --ineos-blue-500:   #1c3f7c;  /* Akzent / Links / Chart */
    --ineos-red:        #d62e2f;  /* Akzent sparsam */
    --ineos-steel:      #5b6b85;  /* gedämpft */

    /* Flächen & Text */
    --surface:          #ffffff;
    --surface-muted:    #eef1f6;
    --panel:            rgba(255, 255, 255, 0.92);
    --text:             #1b2433;
    --text-muted:       #5b6b85;
    --border:           #d3d9e3;

    /* Status (funktional, klar unterscheidbar) */
    --free:     #1f9d55;
    --occupied: #c0392b;
    --offline:  #6c757d;
    --ok:       #1f9d55;
    --warn:     #d62e2f;

    --radius:   6px;
    --radius-sm:4px;
    --shadow:   0 2px 6px rgba(7, 22, 55, 0.12);
    --shadow-lg:0 8px 24px rgba(7, 22, 55, 0.25);
    --font:     'Segoe UI', Arial, 'Helvetica Neue', Helvetica, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--surface-muted);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    line-height: 1.45;
}

main {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 96px auto 24px auto;
    padding: clamp(1em, 3vw, 2em);
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

h1 {
    color: var(--ineos-blue);
    font-size: clamp(1.4em, 4vw, 2em);
    letter-spacing: .5px;
    margin: 0 0 .2em 0;
    text-transform: uppercase;
}
h2 { color: var(--ineos-blue); font-size: clamp(1.1em, 2.5vw, 1.4em); }
h3 { color: var(--ineos-blue-500); }

a { color: var(--ineos-blue-500); }

.background-image {
    position: fixed;
    inset: 0;
    background: url('/medien/hintergrund/background1.jpg') no-repeat center center fixed;
    background-size: cover;
    opacity: 0.18;
    z-index: -2;
}
/* dezenter Navy-Schleier über dem Foto – Markenton */
.background-image::after {
    content: "";
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg, rgba(7,22,55,.55), rgba(7,22,55,.35));
    z-index: -1;
}

/* ----- Navbar (Navy, weißes Logo-Chip) --------------------------------- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: var(--ineos-blue);
    border-bottom: 3px solid var(--ineos-red);
    box-shadow: var(--shadow);
    z-index: 1000;
}
.navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: .5em clamp(.8em, 2vw, 1.2em);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8em;
    flex-wrap: wrap;
}
.navbar-logo {
    background: #fff;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
}
.navbar-logo img { height: 42px; max-width: 160px; display: block; }
.navbar-links { display: flex; flex-wrap: wrap; gap: .5em; }

/* ----- Buttons --------------------------------------------------------- */
.button {
    display: inline-block;
    text-decoration: none;
    background: var(--ineos-blue);
    color: #fff;
    padding: .55em 1.1em;
    border: 1px solid var(--ineos-blue);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: .95em;
    font-weight: 600;
    transition: background .2s ease, border-color .2s ease;
}
.button:hover { background: var(--ineos-blue-700); border-color: var(--ineos-blue-700); }
/* Buttons in der Navbar: heller Rahmen auf Navy */
.navbar .button { background: transparent; border-color: rgba(255,255,255,.5); }
.navbar .button:hover { background: rgba(255,255,255,.15); border-color: #fff; }

.button-container { display: flex; flex-wrap: wrap; gap: .5em; margin-top: 1em; }

/* ----- Live-Leistung --------------------------------------------------- */
.live-power {
    text-align: center;
    margin: .25em 0 1.25em 0;
    padding: .8em;
    background: var(--ineos-blue);
    color: #fff;
    border-radius: var(--radius);
}
.live-power .value { font-size: clamp(1.6em, 5vw, 2.2em); font-weight: 700; letter-spacing: .5px; }
.live-power .label { color: rgba(255,255,255,.8); font-size: .9em; }

/* ----- Wallbox-Grid (responsiv, auto-flow) ----------------------------- */
.wallbox-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1em;
}
.wallbox {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 4px solid var(--offline);
    border-radius: var(--radius);
    padding: 1em;
    box-shadow: var(--shadow);
    text-align: center;
}
.wallbox h2 { margin-top: 0; }
.wallbox-free     { border-top-color: var(--free); }
.wallbox-occupied { border-top-color: var(--occupied); }
.wallbox-offline  { border-top-color: var(--offline); opacity: .85; }
.wallbox-brand    { border-top-color: var(--ineos-blue); }

.wallbox-free .status-pill     { background: var(--free); }
.wallbox-occupied .status-pill { background: var(--occupied); }
.wallbox-offline .status-pill  { background: var(--offline); }
.status-pill {
    display: inline-block;
    color: #fff;
    font-size: .8em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: .2em .8em;
    border-radius: 999px;
}

.energy-info { font-size: .88em; color: var(--text); margin-top: 8px; }
.penalty-info { font-size: .85em; color: var(--text-muted); margin-top: 4px; }
.total-info  { margin-top: 6px; }

.info-button {
    margin-top: 10px;
    background: var(--ineos-blue);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: .45em 1em;
    cursor: pointer;
    font-weight: 600;
    transition: background .2s ease;
}
.info-button:hover { background: var(--ineos-blue-700); }

/* ----- Fortschritts-/Blockierbalken ------------------------------------ */
.penalty-bar {
    margin-top: 10px;
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 14px;
    background: var(--surface-muted);
    border-radius: 999px;
}
.penalty-bar > .bar-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--ok);
    transition: width .3s ease;
}
.penalty-bar > .bar-fill.is-high { background: var(--warn); }

/* ----- Tabellen -------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); min-width: 480px; }
.data-table th {
    background: var(--ineos-blue);
    color: #fff;
    text-align: left;
    padding: 10px;
    font-weight: 600;
}
.data-table td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); }
.data-table tr:nth-child(even) td { background: var(--surface-muted); }
.data-table tr:last-child td { border-bottom: none; }

/* ----- Charts ---------------------------------------------------------- */
.charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1em;
    margin-top: 1em;
}
.chartbox {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1em;
    box-shadow: var(--shadow);
}
.chartbox h3 { margin: 0 0 .6em 0; font-size: 1em; color: var(--ineos-blue); }
.chartbox canvas { width: 100% !important; height: 280px !important; }

/* ----- Modals ---------------------------------------------------------- */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    inset: 0;
    overflow-y: auto;                 /* der GESAMTE Overlay scrollt – Ende immer erreichbar */
    -webkit-overflow-scrolling: touch;
    background: rgba(7, 22, 55, 0.6);
    padding: 24px 12px;               /* Abstand oben/unten, damit Anfang + Ende frei stehen */
}
.modal-content {
    background: var(--surface);
    margin: 0 auto;
    padding: 1.2em;
    padding-top: 2.4em;               /* Platz für den Close-Button */
    border-radius: var(--radius);
    border-top: 4px solid var(--ineos-red);
    max-width: 640px;
    width: 100%;
    position: relative;
    box-shadow: var(--shadow-lg);
    color: var(--text);
}
.modal-content h2 { margin-top: 0; text-align: center; }
.modal-content h3 { margin-bottom: .3em; border-bottom: 1px solid var(--border); padding-bottom: .2em; }

.close {
    position: absolute;
    top: 8px;
    right: 14px;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    color: var(--ineos-blue);
    line-height: 1;
    transition: color .2s ease;
}
.close:hover, .close:focus { color: var(--ineos-red); }

.lageplan-content { max-width: 900px; }
.lageplan-content img, .lageplan-image { max-width: 100%; height: auto; border-radius: var(--radius-sm); }

.tech-data-container {
    background: var(--surface);
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
    padding: 1.2em;
    border-radius: var(--radius);
    border-top: 4px solid var(--ineos-red);
    box-shadow: var(--shadow-lg);
}
.tech-data-container h4 {
    margin: 0 0 10px 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
    font-size: 1.1em;
    color: var(--ineos-blue);
}
.tech-data-container p { margin: 8px 0; font-size: .92em; }
.tech-data-container strong { color: var(--ineos-blue); }

/* ----- Footer ---------------------------------------------------------- */
footer {
    text-align: center;
    padding: 1em;
    color: rgba(255,255,255,.85);
    background: var(--ineos-blue);
    border-top: 3px solid var(--ineos-red);
    font-size: .9em;
}

/* ----- Responsive Feinschliff ------------------------------------------ */
@media (max-width: 768px) {
    main { margin: 84px 10px 16px 10px; }
    .navbar-container { padding: .5em .8em; }
    .navbar-logo img { height: 34px; }
    .chartbox canvas { height: 240px !important; }
}

@media (max-width: 480px) {
    .wallbox-container { grid-template-columns: 1fr 1fr; }
    .wallbox { padding: .7em; }
    .wallbox h2 { font-size: 1em; }
    .button { font-size: .85em; padding: .45em .8em; }
    .live-power .label { font-size: .8em; }
}

@media (max-width: 360px) {
    .wallbox-container { grid-template-columns: 1fr; }
}

/* Großzügige Displays: bis zu 4 Spalten */
@media (min-width: 1100px) {
    .wallbox-container { grid-template-columns: repeat(4, 1fr); }
}
