/**
 * components.css
 *
 * Modern HMI component styles for the Heliotherm heat pump interface.
 * Replaces SVG gradients with flat, modern CSS design.
 *
 * Color scheme based on Heliotherm branding.
 */

/* ==========================================================================
   CSS Custom Properties (Design Tokens)
   ========================================================================== */

:root {
    /* Primary Colors */
    --hmi-primary: #c00a26;           /* Heliotherm Rot */
    --hmi-primary-light: #e01030;
    --hmi-primary-dark: #9a0820;

    /* Status Colors */
    --hmi-success: #4caf50;
    --hmi-warning: #ff9800;
    --hmi-error: #f44336;
    --hmi-error-dark: #a7112d;        /* From SVG: EVU/Hauptschalter warning */
    --hmi-info: #2196f3;

    /* Neutral Colors */
    --hmi-background: #1a1a1a;
    --hmi-background-light: #2d2d2d;
    --hmi-surface: #333333;
    --hmi-surface-light: #424242;
    --hmi-border: #555555;
    --hmi-border-light: #666666;

    /* Text Colors */
    --hmi-text: #ffffff;
    --hmi-text-secondary: #b0b0b0;
    --hmi-text-disabled: #666666;

    /* Sizing */
    --hmi-button-size: 80px;
    --hmi-button-size-small: 60px;
    --hmi-button-size-large: 100px;
    --hmi-spacing: 1rem;
    --hmi-radius: 8px;
    --hmi-radius-round: 50%;

    /* Master scale factor for font sizes. All hardcoded `font-size: Npx`
       rules are wrapped in calc(Npx * var(--hmi-scale)) so a single media
       query can enlarge text on large displays without touching each style.
       Must be declared before the --hmi-font-size-* tokens below so they
       can reference it. */
    --hmi-scale: 1;

    /* Typography */
    --hmi-font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    --hmi-font-size: calc(14px * var(--hmi-scale));
    --hmi-font-size-small: calc(12px * var(--hmi-scale));
    --hmi-font-size-large: calc(18px * var(--hmi-scale));

    /* Transitions */
    --hmi-transition: 0.2s ease-in-out;
    --hmi-transition-slow: 0.4s ease-in-out;
}


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

.hmi-page {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    background: var(--hmi-background);
    color: var(--hmi-text);
    font-family: var(--hmi-font-family);
    font-size: var(--hmi-font-size);
    padding: var(--hmi-spacing);
    box-sizing: border-box;
}

.hmi-page h1,
.hmi-page h2,
.hmi-page h3 {
    margin: 0 0 var(--hmi-spacing) 0;
    font-weight: 400;
}

.hmi-page h1 { font-size: calc(24px * var(--hmi-scale)); }
.hmi-page h2 { font-size: calc(20px * var(--hmi-scale)); }
.hmi-page h3 { font-size: calc(16px * var(--hmi-scale)); }


/* ==========================================================================
   Grid Layouts
   ========================================================================== */

.hmi-grid {
    display: grid;
    gap: var(--hmi-spacing);
}

.hmi-grid-2 { grid-template-columns: repeat(2, 1fr); }
.hmi-grid-3 { grid-template-columns: repeat(3, 1fr); }
.hmi-grid-4 { grid-template-columns: repeat(4, 1fr); }
.hmi-grid-5 { grid-template-columns: repeat(5, 1fr); }

.hmi-grid-auto {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
}

/* Flexbox alternative */
.hmi-flex {
    display: flex;
    flex-wrap: wrap;
    gap: var(--hmi-spacing);
}

.hmi-flex-center {
    justify-content: center;
    align-items: center;
}


/* ==========================================================================
   HMI Button Component
   ========================================================================== */

.hmi-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: var(--hmi-button-size);
    height: var(--hmi-button-size);
    padding: 8px;
    border: 2px solid var(--hmi-border);
    border-radius: var(--hmi-radius-round);
    background: var(--hmi-surface);
    color: var(--hmi-text);
    font-family: inherit;
    font-size: var(--hmi-font-size-small);
    text-align: center;
    cursor: pointer;
    transition: all var(--hmi-transition);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.hmi-button:hover {
    transform: scale(1.1);
}

.hmi-button:active {
    transform: scale(0.95);
}

.hmi-button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(192, 10, 38, 0.3);
}

/* Active/Selected state - styling handled by page-specific CSS on .icon element */
.hmi-button.active,
.hmi-button[data-active="true"] {
    /* border-color and box-shadow applied to .icon child, not here */
}

/* Warning state (EVU, Hauptschalter) - styling handled by page-specific CSS on .icon element */
.hmi-button.warning,
.hmi-button[data-warning="true"] {
    /* border-color and box-shadow applied to .icon child, not here */
}

/* Disabled state */
.hmi-button:disabled,
.hmi-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Size variants */
.hmi-button.small {
    width: var(--hmi-button-size-small);
    height: var(--hmi-button-size-small);
    font-size: calc(10px * var(--hmi-scale));
}

.hmi-button.large {
    width: var(--hmi-button-size-large);
    height: var(--hmi-button-size-large);
    font-size: var(--hmi-font-size);
}

/* Square variant */
.hmi-button.square {
    border-radius: var(--hmi-radius);
}

/* Button with icon */
.hmi-button .icon {
    font-size: calc(24px * var(--hmi-scale));
    margin-bottom: 4px;
}

.hmi-button .label {
    font-size: inherit;
    line-height: 1.2;
}


/* ==========================================================================
   HMI Value Component
   ========================================================================== */

.hmi-value {
    display: flex;
    align-items: baseline;
    gap: 4px;
    font-family: var(--hmi-font-family);
}

.hmi-value .value {
    font-size: var(--hmi-font-size-large);
    font-weight: 500;
    color: var(--hmi-text);
}

.hmi-value .unit {
    font-size: var(--hmi-font-size-small);
    color: var(--hmi-text-secondary);
}

.hmi-value .label {
    font-size: var(--hmi-font-size-small);
    color: var(--hmi-text-secondary);
    margin-right: 8px;
}

/* Value in a box */
.hmi-value-box {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    background: var(--hmi-surface);
    border: 1px solid var(--hmi-border);
    border-radius: var(--hmi-radius);
}

.hmi-value-box .label {
    margin-bottom: 4px;
}

/* Size variants */
.hmi-value.large .value {
    font-size: calc(28px * var(--hmi-scale));
}

.hmi-value.small .value {
    font-size: var(--hmi-font-size);
}


/* ==========================================================================
   HMI Status Indicator Component
   ========================================================================== */

.hmi-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.hmi-status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--hmi-text-disabled);
    transition: background var(--hmi-transition);
}

/* Status states */
.hmi-status-dot.off,
.hmi-status-dot[data-state="0"] {
    background: #808080;
}

.hmi-status-dot.on,
.hmi-status-dot.active,
.hmi-status-dot[data-state="1"] {
    background: var(--hmi-success);
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
}

.hmi-status-dot.error,
.hmi-status-dot[data-state="2"] {
    background: var(--hmi-error);
    box-shadow: 0 0 8px rgba(244, 67, 54, 0.5);
}

.hmi-status-dot.warning,
.hmi-status-dot[data-state="3"] {
    background: var(--hmi-warning);
    box-shadow: 0 0 8px rgba(255, 152, 0, 0.5);
}

/* Blinking animation for alerts */
.hmi-status-dot.blink {
    animation: status-blink 1s ease-in-out infinite;
}

@keyframes status-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Size variants */
.hmi-status-dot.small {
    width: 8px;
    height: 8px;
}

.hmi-status-dot.large {
    width: 16px;
    height: 16px;
}


/* ==========================================================================
   HMI Toggle Component
   ========================================================================== */

.hmi-toggle {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.hmi-toggle-track {
    position: relative;
    width: 48px;
    height: 24px;
    background: var(--hmi-surface);
    border: 2px solid var(--hmi-border);
    border-radius: 12px;
    transition: all var(--hmi-transition);
}

.hmi-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--hmi-text);
    border-radius: 50%;
    transition: transform var(--hmi-transition);
}

.hmi-toggle.active .hmi-toggle-track,
.hmi-toggle[data-active="true"] .hmi-toggle-track {
    background: var(--hmi-primary);
    border-color: var(--hmi-primary);
}

.hmi-toggle.active .hmi-toggle-thumb,
.hmi-toggle[data-active="true"] .hmi-toggle-thumb {
    transform: translateX(24px);
}

.hmi-toggle:hover .hmi-toggle-track {
    border-color: var(--hmi-border-light);
}

.hmi-toggle .label {
    font-size: var(--hmi-font-size);
    color: var(--hmi-text);
}


/* ==========================================================================
   HMI Navbar Component
   ========================================================================== */

.hmi-navbar {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    background: var(--hmi-surface);
    border-bottom: 1px solid var(--hmi-border);
}

.hmi-navbar-logo {
    height: 32px;
    margin-right: auto;
}

.hmi-navbar-items {
    display: flex;
    gap: 8px;
}

.hmi-navbar-item {
    padding: 8px 16px;
    color: var(--hmi-text);
    text-decoration: none;
    border-radius: var(--hmi-radius);
    transition: background var(--hmi-transition);
    cursor: pointer;
}

.hmi-navbar-item:hover {
    background: var(--hmi-surface-light);
}

.hmi-navbar-item.active {
    background: var(--hmi-primary);
}

.hmi-navbar-time {
    margin-left: 16px;
    font-size: var(--hmi-font-size-small);
    color: var(--hmi-text-secondary);
}


/* ==========================================================================
   HMI Data Grid Component
   ========================================================================== */

.hmi-data-grid {
    width: 100%;
    border-collapse: collapse;
    background: var(--hmi-surface);
    border: 1px solid var(--hmi-border);
    border-radius: var(--hmi-radius);
    overflow: hidden;
}

.hmi-data-grid th,
.hmi-data-grid td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--hmi-border);
}

.hmi-data-grid th {
    background: var(--hmi-background-light);
    font-weight: 500;
    color: var(--hmi-text-secondary);
}

.hmi-data-grid tr:last-child td {
    border-bottom: none;
}

.hmi-data-grid tr:hover td {
    background: var(--hmi-surface-light);
}

/* Compact variant */
.hmi-data-grid.compact th,
.hmi-data-grid.compact td {
    padding: 8px 12px;
}


/* ==========================================================================
   HMI Card Component
   ========================================================================== */

.hmi-card {
    background: var(--hmi-surface);
    border: 1px solid var(--hmi-border);
    border-radius: var(--hmi-radius);
    overflow: hidden;
}

.hmi-card-header {
    padding: 12px 16px;
    background: var(--hmi-background-light);
    border-bottom: 1px solid var(--hmi-border);
    font-weight: 500;
}

.hmi-card-body {
    padding: 16px;
}

.hmi-card-footer {
    padding: 12px 16px;
    background: var(--hmi-background-light);
    border-top: 1px solid var(--hmi-border);
}


/* ==========================================================================
   Utility Classes
   ========================================================================== */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.text-primary { color: var(--hmi-primary); }
.text-success { color: var(--hmi-success); }
.text-warning { color: var(--hmi-warning); }
.text-error { color: var(--hmi-error); }
.text-secondary { color: var(--hmi-text-secondary); }

.bg-primary { background-color: var(--hmi-primary); }
.bg-surface { background-color: var(--hmi-surface); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }

.hidden { display: none !important; }
.invisible { visibility: hidden; }


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

@media (max-width: 768px) {
    :root {
        --hmi-button-size: 70px;
        --hmi-button-size-small: 50px;
        --hmi-spacing: 0.75rem;
    }

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

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

@media (max-width: 480px) {
    :root {
        --hmi-button-size: 60px;
        --hmi-spacing: 0.5rem;
    }

    .hmi-grid-5,
    .hmi-grid-4,
    .hmi-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Large desktop displays (QHD 2560x1440 and above).
   Drives --hmi-scale which is applied to every hardcoded `font-size: Npx`
   via calc(Npx * var(--hmi-scale)). Factor 1.4 makes text on a 2560px
   display roughly match the visual size on a 1830px one. */
@media (min-width: 2000px) {
    :root {
        /* Single source of truth: --hmi-scale cascades through every
           `font-size: calc(Npx * var(--hmi-scale))` rule and through the
           --hmi-font-size-* tokens. 1.4 makes text on 2560px feel like 1830px. */
        --hmi-scale: 1.4;
    }
}


/* ==========================================================================
   HMI Climate Control Component
   ========================================================================== */

.hmi-climate-control {
    display: block;
    aspect-ratio: 1;
    margin: 0 auto;
}

.climate-control-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.climate-control-svg {
    width: 100%;
    height: 100%;
}

/* Inner content overlay */
.climate-control-container .inner-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48%;
    height: 48%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    box-sizing: border-box;
    pointer-events: none; /* Allow clicks through to SVG indicators */
}

/* Mode icon container - circular background, inside temp-display */
.climate-control-container .mode-icon-container {
    width: 50px;
    height: 50px;
    color: rgba(255, 255, 255, 0.9);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    /* Circular background */
    background: radial-gradient(circle, rgba(80, 80, 80, 0.5) 0%, rgba(60, 60, 60, 0.7) 100%);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    padding: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    margin-bottom: 4px;
}

/* SVG icon styles (extracted from Main.svg) */
.climate-control-container .mode-svg-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Mischer icon wrapper with number overlay */
.climate-control-container .mode-icon-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

.climate-control-container .mode-icon-wrapper .mode-svg-icon {
    width: 100%;
    height: 100%;
}

.climate-control-container .mischer-number {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    background: rgb(192, 10, 38);
    border-radius: 50%;
    font-size: calc(14px * var(--hmi-scale));
    font-weight: bold;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Temperature display in center - contains icon, soll, and ist */
.climate-control-container .temp-display {
    text-align: center;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    pointer-events: none;
}

.climate-control-container .temp-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* SOLL row with symmetric +/- buttons */
.climate-control-container .temp-row.soll-row {
    margin-bottom: 4px;
    gap: 16px;
}

/* Wrapper for SOLL label and temperature */
.climate-control-container .temp-soll-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
}

.climate-control-container .temp-label {
    font-size: calc(11px * var(--hmi-scale));
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-weight: 500;
    margin-bottom: 2px;
    opacity: 0.8;
}

.climate-control-container .temp-soll {
    font-size: calc(52px * var(--hmi-scale));
    font-weight: 300;
    color: #ffffff;
    line-height: 1;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.climate-control-container .temp-ist {
    font-size: calc(32px * var(--hmi-scale));
    font-weight: 300;
    color: rgba(255, 255, 255, 0.75);
    line-height: 1;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.climate-control-container .temp-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.climate-control-container .temp-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    transform: scale(1.05);
}

.climate-control-container .temp-btn:active {
    transform: scale(0.92);
    background: rgba(192, 10, 38, 0.35);
    border-color: rgba(192, 10, 38, 0.5);
}

.climate-control-container .temp-btn svg {
    width: 16px;
    height: 16px;
}

/* Mode navigation at bottom */
.climate-control-container .mode-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    pointer-events: auto;
}

/* Navigation arrows - compact size for better spacing */
.climate-control-container .nav-arrow {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.25);
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.climate-control-container .nav-arrow:hover {
    background: rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.4);
    color: #ffffff;
    transform: scale(1.05);
}

.climate-control-container .nav-arrow:active {
    transform: scale(0.95);
    background: rgba(192, 10, 38, 0.4);
    border-color: rgba(192, 10, 38, 0.6);
}

.climate-control-container .nav-arrow svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.5;
}

/* Mode indicator dots */
.climate-control-container .mode-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.climate-control-container .mode-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.2s ease;
}

.climate-control-container .mode-dot:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: scale(1.2);
}

.climate-control-container .mode-dot.active {
    background: #c00a26;
    box-shadow: 0 0 10px rgba(192, 10, 38, 0.7);
    transform: scale(1.4);
}

/* Current mode label */
.climate-control-container .current-mode-label {
    font-size: calc(22px * var(--hmi-scale));
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    margin-top: 4px;
    letter-spacing: 0.5px;
    pointer-events: none;
}

/* SOLL indicator - draggable */
.climate-control-container .soll-indicator {
    cursor: grab;
    pointer-events: auto;
    transition: r 0.15s ease, filter 0.15s ease;
}

.climate-control-container .soll-indicator:hover {
    filter: url(#indicatorGlow) brightness(1.2);
}

.climate-control-container .soll-indicator:active,
.climate-control-container .soll-indicator.dragging {
    cursor: grabbing;
}

/* IST indicator - display only */
/* Animation is handled by JavaScript to move along the arc path */
.climate-control-container .ist-indicator {
    pointer-events: none;
}

/* Inner circle - no pointer events so indicators can be clicked */
.climate-control-container .inner-circle-bg,
.climate-control-container .inner-circle-border {
    pointer-events: none;
}

/* Responsive adjustments for tablets */
@media (max-width: 768px) {
    .hmi-climate-control {
        max-width: 90vw;
        max-height: 70vh;
        margin: 0 auto;
    }

    .climate-control-container .inner-content {
        width: 50%;
        height: 50%;
        gap: 0;
    }

    .climate-control-container .mode-icon-container {
        width: 50px;
        height: 50px;
        padding: 6px;
        margin-bottom: 2px;
    }

    .climate-control-container .temp-btn {
        width: 36px;
        height: 36px;
        background: rgba(0, 0, 0, 0.4);
        border: 1px solid rgba(255, 255, 255, 0.3);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .climate-control-container .temp-btn svg {
        width: 18px;
        height: 18px;
    }

    .climate-control-container .nav-arrow {
        width: 38px;
        height: 38px;
    }

    .climate-control-container .nav-arrow svg {
        width: 22px;
        height: 22px;
    }

    .climate-control-container .temp-btn:hover {
        background: rgba(0, 0, 0, 0.5);
        border-color: rgba(255, 255, 255, 0.5);
    }

    .climate-control-container .temp-btn:active {
        background: rgba(192, 10, 38, 0.5);
        border-color: rgba(192, 10, 38, 0.7);
        transform: scale(0.95);
    }

    .climate-control-container .temp-btn svg {
        width: 24px;
        height: 24px;
        stroke-width: 3;
    }

    .climate-control-container .temp-row.soll-row {
        gap: 20px;
    }
}

/* Responsive adjustments for mobile phones */
@media (max-width: 480px) {
    .hmi-climate-control {
        max-width: 95vw;
        max-height: 65vh;
    }

    .climate-control-container .inner-content {
        width: 52%;
        height: 52%;
        gap: 0;
    }

    .climate-control-container .mode-icon-container {
        width: 50px;
        height: 50px;
        padding: 5px;
        margin-bottom: 0;
    }

    .climate-control-container .temp-soll {
        font-size: calc(44px * var(--hmi-scale));
    }

    .climate-control-container .temp-ist {
        font-size: calc(26px * var(--hmi-scale));
    }

    /* Touch-friendly +/- buttons on mobile */
    .climate-control-container .temp-btn {
        width: 40px;
        height: 40px;
        background: rgba(0, 0, 0, 0.5);
        border: 1px solid rgba(255, 255, 255, 0.4);
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
    }

    .climate-control-container .temp-btn svg {
        width: 20px;
        height: 20px;
    }

    .climate-control-container .temp-row.soll-row {
        gap: 16px;
    }

    .climate-control-container .temp-soll-wrapper {
        min-width: 80px;
    }

    /* Touch-friendly nav arrows on mobile */
    .climate-control-container .nav-arrow {
        width: 40px;
        height: 40px;
        background: rgba(0, 0, 0, 0.4);
        border: 1px solid rgba(255, 255, 255, 0.3);
    }

    .climate-control-container .nav-arrow svg {
        width: 22px;
        height: 22px;
    }

    .climate-control-container .mode-dot {
        width: 10px;
        height: 10px;
    }

    .climate-control-container .mode-indicator {
        gap: 10px;
    }

    .climate-control-container .current-mode-label {
        font-size: calc(16px * var(--hmi-scale));
        margin-top: 6px;
    }

    .climate-control-container .temp-label {
        font-size: calc(10px * var(--hmi-scale));
    }

    .climate-control-container .temp-soll-wrapper {
        min-width: 80px;
    }
}

/* Extra small screens (iPhone SE, etc.) */
@media (max-width: 375px) {
    .hmi-climate-control {
        max-width: 100vw;
        max-height: 60vh;
    }

    .climate-control-container .inner-content {
        width: 54%;
        height: 54%;
    }

    .climate-control-container .mode-icon-container {
        width: 50px;
        height: 50px;
        padding: 4px;
        margin-bottom: 0;
    }

    .climate-control-container .temp-soll {
        font-size: calc(36px * var(--hmi-scale));
    }

    .climate-control-container .temp-soll-wrapper {
        min-width: 65px;
    }

    .climate-control-container .temp-row.soll-row {
        gap: 12px;
    }

    .climate-control-container .temp-btn {
        width: 36px;
        height: 36px;
    }

    .climate-control-container .nav-arrow {
        width: 36px;
        height: 36px;
    }

    .climate-control-container .temp-ist {
        font-size: calc(24px * var(--hmi-scale));
    }

    .climate-control-container .temp-btn {
        width: 44px;
        height: 44px;
    }

    .climate-control-container .nav-arrow {
        width: 40px;
        height: 40px;
    }

    .climate-control-container .nav-arrow svg {
        width: 24px;
        height: 24px;
    }

    .climate-control-container .current-mode-label {
        font-size: calc(14px * var(--hmi-scale));
    }
}


/* ==========================================================================
   HMI Header Component
   ========================================================================== */

.hmi-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: transparent;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    pointer-events: none;
}

.hmi-header > * {
    pointer-events: auto;
}

.hmi-header .clock-display {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.hmi-header .time {
    font-size: calc(24px * var(--hmi-scale));
    font-weight: 300;
    color: #ffffff;
}

.hmi-header .date {
    font-size: calc(12px * var(--hmi-scale));
    color: rgba(255, 255, 255, 0.7);
}

.hmi-header .logo {
    height: 40px;
}

.hmi-header .logo img {
    height: 100%;
    width: auto;
}


/* ==========================================================================
   HMI Navbar Component
   ========================================================================== */

hmi-navbar {
    display: block;
    position: fixed;
    z-index: 300;
}

/* Bottom position (default) */
hmi-navbar .hmi-navbar.bottom {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 24px 24px 0 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: none;
}

/* Right position (vertical) */
hmi-navbar .hmi-navbar.right {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    flex-direction: column;
    padding: 16px 8px;
    border-radius: 24px 0 0 24px;
    border-right: none;
}

/* Navbar items container */
.hmi-navbar .navbar-items {
    display: flex;
    align-items: center;
    gap: 4px;
}

.hmi-navbar.right .navbar-items {
    flex-direction: column;
}

/* Individual nav item */
.hmi-navbar .navbar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 16px;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 64px;
}

.hmi-navbar .navbar-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

.hmi-navbar .navbar-item.active {
    background: rgba(192, 10, 38, 0.3);
    color: #ffffff;
}

.hmi-navbar .navbar-item.active .navbar-icon {
    color: var(--hmi-primary, #c00a26);
}

/* Nav icon */
.hmi-navbar .navbar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.hmi-navbar .navbar-icon svg {
    width: 100%;
    height: 100%;
}

/* Nav label */
.hmi-navbar .navbar-label {
    font-size: calc(10px * var(--hmi-scale));
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* Toggle button (for mobile) */
.hmi-navbar .navbar-toggle {
    display: none;
    padding: 8px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    border-radius: 50%;
}

.hmi-navbar .navbar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Collapsed state on small screens */
@media (max-width: 600px) {
    hmi-navbar .hmi-navbar.bottom {
        left: 20px;
        right: 20px;
        transform: none;
        padding: 6px 12px;
    }

    .hmi-navbar .navbar-items {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .hmi-navbar .navbar-items::-webkit-scrollbar {
        display: none;
    }

    .hmi-navbar .navbar-item {
        padding: 6px 12px;
        min-width: 56px;
    }

    .hmi-navbar .navbar-label {
        font-size: calc(9px * var(--hmi-scale));
    }

    .hmi-navbar .navbar-icon {
        width: 20px;
        height: 20px;
    }
}

/* Very small screens - show toggle and collapse */
@media (max-width: 400px) {
    .hmi-navbar .navbar-toggle {
        display: flex;
    }

    .hmi-navbar .navbar-items {
        display: none;
    }

    .hmi-navbar.expanded .navbar-items {
        display: flex;
        position: absolute;
        bottom: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        padding: 8px;
        background: rgba(0, 0, 0, 0.8);
        border-radius: 16px 16px 0 0;
        margin-bottom: 4px;
    }

    .hmi-navbar.expanded .navbar-item {
        flex-direction: row;
        justify-content: flex-start;
        gap: 12px;
        padding: 12px 16px;
        width: 100%;
    }

    .hmi-navbar.expanded .navbar-label {
        font-size: calc(12px * var(--hmi-scale));
    }
}

/* Medium screens: hide decorative elements to free horizontal space */
@media (max-width: 1400px) {
    #edelweissContainer,
    #globalClockContainer,
    #backgroundDotsContainer {
        display: none !important;
    }
}

/* Narrow (non-mobile) screens: navbar full width + scrollable */
@media (max-width: 1140px) and (min-width: 769px) {
    hmi-navbar .hmi-navbar.bottom {
        left: 0;
        right: 0;
        transform: none;
        border-radius: 0;
        padding: 6px 12px;
    }

    .hmi-navbar .navbar-items {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .hmi-navbar .navbar-items::-webkit-scrollbar {
        display: none;
    }

    .hmi-navbar .navbar-item {
        padding: 6px 12px;
        min-width: 56px;
        flex-shrink: 0;
    }
}


/* ==========================================================================
   HMI Hamburger Menu Component (Mobile)
   ========================================================================== */

hmi-hamburger-menu {
    display: none;
    position: fixed;
    z-index: 400;
}

/* Show hamburger menu only on mobile */
@media (max-width: 768px) {
    hmi-hamburger-menu {
        display: block;
    }
}

/* Hamburger Trigger Button */
.hamburger-trigger {
    position: fixed;
    top: 16px;
    left: 16px;
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 401;
}

.hamburger-trigger:hover {
    background: rgba(0, 0, 0, 0.8);
    border-color: rgba(255, 255, 255, 0.25);
}

.hamburger-trigger:active {
    transform: scale(0.95);
}

/* Status dot on hamburger trigger button */
.hamburger-trigger-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.6);
    background-color: #6ea439;
    pointer-events: none;
}

/* Overlay */
.hamburger-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 402;
}

.hamburger-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* Slide-in Panel */
.hamburger-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100%;
    background: rgba(25, 25, 30, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 403;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
}

.hamburger-panel.open {
    transform: translateX(0);
}

/* Panel Header */
.hamburger-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.hamburger-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.hamburger-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* Clock Display in Menu */
.hamburger-clock {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
}

.hamburger-time {
    font-size: calc(36px * var(--hmi-scale));
    font-weight: 300;
    color: #ffffff;
    line-height: 1;
    letter-spacing: 2px;
}

.hamburger-date {
    font-size: calc(14px * var(--hmi-scale));
    color: rgba(255, 255, 255, 0.6);
    margin-top: 4px;
    letter-spacing: 1px;
}

/* Status Display in Menu */
.hamburger-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.hamburger-status-labels {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hamburger-status-sub {
    font-size: calc(11px * var(--hmi-scale));
    color: rgba(255, 255, 255, 0.45);
    font-weight: 400;
    font-family: monospace;
    line-height: 1.2;
}

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

.hamburger-status-dot.status-off,
.hamburger-trigger-dot.status-off {
    background-color: #ffffff;
}

.hamburger-status-dot.status-standby,
.hamburger-trigger-dot.status-standby {
    background-color: #ffeb0e;
}

.hamburger-status-dot.status-standby-pulse,
.hamburger-trigger-dot.status-standby-pulse {
    background-color: #ffeb0e;
    animation: statusBlink 1s step-end infinite;
}

.hamburger-status-dot.status-heizung,
.hamburger-trigger-dot.status-heizung {
    background-color: #6ea439;
}

.hamburger-status-dot.status-warmwasser,
.hamburger-trigger-dot.status-warmwasser {
    background-color: #3b82f6;
}

.hamburger-status-dot.status-kuehlen,
.hamburger-trigger-dot.status-kuehlen {
    background-color: #06b6d4;
}

.hamburger-status-dot.status-abtauung,
.hamburger-trigger-dot.status-abtauung {
    background-color: #ff8c00;
}

.hamburger-status-dot.status-error,
.hamburger-trigger-dot.status-error {
    background-color: #ff0000;
}

.hamburger-status-text {
    font-size: calc(14px * var(--hmi-scale));
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

/* Navigation Section */
.hamburger-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.hamburger-nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 14px 20px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.hamburger-nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.hamburger-nav-item.active {
    background: rgba(192, 10, 38, 0.2);
    color: #ffffff;
    border-left: 3px solid var(--hmi-primary, #c00a26);
}

.hamburger-nav-item.active .hamburger-nav-icon {
    color: var(--hmi-primary, #c00a26);
}

.hamburger-nav-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hamburger-nav-icon svg {
    width: 100%;
    height: 100%;
}

.hamburger-nav-label {
    font-size: calc(15px * var(--hmi-scale));
    font-weight: 400;
}

/* Footer Section */
.hamburger-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: auto;
}

/* Background Picker in Menu */
.hamburger-background-picker {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    margin-bottom: 12px;
}

.hamburger-bg-dot {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: transparent;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hamburger-bg-dot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.hamburger-bg-dot:hover {
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.05);
}

.hamburger-bg-dot.selected {
    border-color: var(--hmi-primary, #c00a26);
    box-shadow: 0 0 8px rgba(192, 10, 38, 0.5);
}

/* Update Notification in Menu */
.hamburger-update {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: rgba(192, 10, 38, 0.15);
    border: 1px solid rgba(192, 10, 38, 0.3);
    border-radius: 10px;
    margin-bottom: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hamburger-update.visible {
    display: flex;
}

.hamburger-update:hover {
    background: rgba(192, 10, 38, 0.25);
    border-color: rgba(192, 10, 38, 0.5);
}

.hamburger-update svg {
    color: var(--hmi-primary, #c00a26);
    flex-shrink: 0;
    animation: updatePulse 2s ease-in-out infinite;
}

.hamburger-update span {
    font-size: calc(13px * var(--hmi-scale));
    color: rgba(255, 255, 255, 0.9);
}

.hamburger-update-version {
    margin-left: auto;
    font-family: monospace;
    color: var(--hmi-primary, #c00a26) !important;
    font-weight: 500;
}

/* Branding */
.hamburger-branding {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.4);
    font-size: calc(12px * var(--hmi-scale));
}

.hamburger-logo {
    width: 32px;
    height: 32px;
    opacity: 0.6;
}

/* Hide global elements on mobile when hamburger menu is active */
@media (max-width: 768px) {
    /* Hide the original navbar on mobile */
    hmi-navbar {
        display: none !important;
    }

    /* Hide status indicator on mobile - it's in hamburger menu now */
    #statusIndicatorContainer {
        display: none !important;
    }

    /* Hide the global circles (clock, edelweiss) on mobile - they're in hamburger menu now */
    #edelweissContainer,
    #globalClockContainer {
        display: none !important;
    }

    /* Hide update notification on mobile - it's in hamburger menu now */
    #updateNotification {
        display: none !important;
    }

    /* Hide background dots on mobile - they're in hamburger menu now */
    #backgroundDotsContainer {
        display: none !important;
    }

    /* Adjust logo position on mobile */
    #logoContainer {
        width: 30%;
        top: 8px;
        right: -10px;
    }
}

/* ==========================================================================
   Dark Mode Enhancements (for future light mode support)
   ========================================================================== */

@media (prefers-color-scheme: light) {
    /* Keep dark theme for now - industrial HMI typically uses dark backgrounds */
}


/* ==========================================================================
   HMI Login Modal Component
   ========================================================================== */

.hmi-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.hmi-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.hmi-modal {
    background: rgba(40, 40, 40, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 32px;
    min-width: 320px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.9) translateY(-20px);
    transition: transform 0.3s ease;
}

.hmi-modal-overlay.active .hmi-modal {
    transform: scale(1) translateY(0);
}

.hmi-modal-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    position: relative;
}

.hmi-modal-title {
    font-size: calc(20px * var(--hmi-scale));
    font-weight: 500;
    color: #ffffff;
    margin: 0;
    text-align: center;
}

.hmi-modal-close {
    position: absolute;
    right: -8px;
    top: -8px;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.hmi-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.hmi-modal-close svg {
    width: 20px;
    height: 20px;
}

.hmi-modal-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Form Input Group */
.hmi-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hmi-input-label {
    font-size: calc(13px * var(--hmi-scale));
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hmi-input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #ffffff;
    font-size: calc(16px * var(--hmi-scale));
    font-family: inherit;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.hmi-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.hmi-input:focus {
    outline: none;
    border-color: var(--hmi-primary, #c00a26);
    box-shadow: 0 0 0 3px rgba(192, 10, 38, 0.2);
}

.hmi-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Error message */
.hmi-input-error {
    font-size: calc(12px * var(--hmi-scale));
    color: var(--hmi-error, #f44336);
    display: none;
}

.hmi-input-group.error .hmi-input {
    border-color: var(--hmi-error, #f44336);
}

.hmi-input-group.error .hmi-input-error {
    display: block;
}

/* Modal footer with buttons */
.hmi-modal-footer {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.hmi-modal-footer .hmi-btn {
    flex: 1;
}

/* Button styles for modal */
.hmi-btn {
    padding: 14px 24px;
    border-radius: 999px;
    font-size: calc(14px * var(--hmi-scale));
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.hmi-btn-primary {
    background: var(--hmi-primary, #c00a26);
    color: #ffffff;
    border-color: var(--hmi-primary, #c00a26);
}

.hmi-btn-primary:hover:not(:disabled) {
    background: #a00820;
    border-color: #a00820;
}

.hmi-btn-primary:active:not(:disabled) {
    transform: scale(0.97);
}

.hmi-btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.2);
}

.hmi-btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.hmi-btn-secondary:active:not(:disabled) {
    transform: scale(0.97);
}

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

/* Loading spinner for button */
.hmi-btn .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: hmi-spin 0.8s linear infinite;
    display: none;
}

.hmi-btn.loading .spinner {
    display: block;
}

.hmi-btn.loading .btn-text {
    display: none;
}

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

/* Login status message */
.hmi-login-status {
    text-align: center;
    font-size: calc(14px * var(--hmi-scale));
    padding: 12px;
    border-radius: 8px;
    display: none;
}

.hmi-login-status.error {
    display: block;
    background: rgba(244, 67, 54, 0.15);
    color: var(--hmi-error, #f44336);
    border: 1px solid rgba(244, 67, 54, 0.3);
}

.hmi-login-status.success {
    display: block;
    background: rgba(76, 175, 80, 0.15);
    color: var(--hmi-success, #4caf50);
    border: 1px solid rgba(76, 175, 80, 0.3);
}

/* Responsive adjustments */
@media (max-width: 400px) {
    .hmi-modal {
        padding: 24px 20px;
        min-width: unset;
    }

    .hmi-modal-title {
        font-size: calc(18px * var(--hmi-scale));
    }

    .hmi-input {
        padding: 12px 14px;
        font-size: calc(16px * var(--hmi-scale)); /* Prevent zoom on iOS */
    }

    .hmi-btn {
        padding: 12px 20px;
        font-size: calc(13px * var(--hmi-scale));
    }
}


/* ==========================================================================
   HMI Time Program Editor Component (Dark Theme)
   ========================================================================== */

.zeitprogramm-page {
    background: transparent;
    color: var(--hmi-text, #ffffff);
    min-height: 100%;
    height: 100%;
    max-height: 100dvh;
    /* 60px top for status header, 90px bottom for the nav bar — same as
       heizkurve/betriebsart so the three pages share a consistent frame. */
    padding: 60px 20px 90px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.zeitprogramm-page * {
    box-sizing: border-box;
}

/* Container — vertical centering via auto-margins (mirrors heizkurve .page-content).
   Scrolls safely when viewport is too short instead of clipping at the top. */
.tp-container {
    max-width: 900px;
    width: 100%;
    margin: auto;
}

/* Schedule Panel - glassmorphism box like Heizkurve */
.tp-panel {
    background: rgba(40, 40, 40, 0.6);
    border-radius: 16px;
    padding: 16px;
    border: 1px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
}

/* Header Section - no longer needed but kept for backwards compatibility */
.tp-header {
    background: var(--hmi-surface, #333333);
    border-radius: calc(var(--hmi-radius, 8px) + 1rem);
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--hmi-border, #555555);
}

.tp-title-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.tp-title-text {
    flex: 1;
}

.tp-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--hmi-text, #ffffff);
    margin: 0;
    text-align: center;
}

/* Tab Navigation */
.tp-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.tp-tab {
    padding: 0.5rem 1rem;
    border-radius: var(--hmi-radius, 8px);
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
    border: 1px solid var(--hmi-border, #555555);
    font-size: 0.85rem;
    font-family: inherit;
}

.tp-tab:not(.active) {
    background: var(--hmi-surface-light, #424242);
    color: var(--hmi-text-secondary, #b0b0b0);
}

.tp-tab:not(.active):hover {
    background: var(--hmi-border, #555555);
    color: var(--hmi-text, #ffffff);
}

.tp-tab.active {
    background: var(--hmi-primary, #c00a26);
    color: white;
    border-color: var(--hmi-primary, #c00a26);
}

/* Legend Panel - Hidden */
.tp-legend-panel {
    display: none;
}

/* Schedule Container */
.tp-schedule-container {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.tp-loading {
    text-align: center;
    padding: 2rem;
    color: var(--hmi-text-secondary, #b0b0b0);
}

/* Day Cards - more transparent to match glassmorphism */
.tp-day-card {
    background: rgba(50, 50, 50, 0.5);
    border-radius: 0.8rem;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.08);
}

.tp-day-header {
    padding: 0.7rem;
    cursor: pointer;
    transition: background-color 0.2s;
    background: rgba(60, 60, 60, 0.5);
}

.tp-day-header:hover {
    background: rgba(80, 80, 80, 0.5);
}

.tp-day-header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.tp-day-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--hmi-text, #e2e8f0);
    width: 6rem;
    flex-shrink: 0;
    margin: 0 !important;
}

.tp-timeline-container {
    flex: 1;
}

/* Timeline */
.tp-timeline {
    position: relative;
    height: 1.5rem;
    background: var(--hmi-background, #1a1a1a);
    border-radius: 0.25rem;
    overflow: hidden;
    cursor: crosshair;
}

.tp-timeline.expanded {
    height: 2rem;
    background: var(--hmi-background, #1a1a1a);
}

.tp-timeline-block {
    position: absolute;
    height: 100%;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tp-timeline-block.highlighted {
    box-shadow: 0 0 0 2px #fbbf24;
    filter: brightness(1.2);
    z-index: 10;
}

.tp-timeline-block .tp-block-label {
    color: white;
    font-size: 0.6rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Tooltip */
.tp-tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 0.4rem;
    padding: 0.4rem 0.6rem;
    background: var(--hmi-surface, #333333);
    color: var(--hmi-text, #ffffff);
    font-size: 0.7rem;
    border-radius: 0.25rem;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 100;
    border: 1px solid var(--hmi-border, #555555);
}

.tp-timeline-block:hover .tp-tooltip {
    display: block;
}

.tp-tooltip-mode {
    font-weight: 600;
}

.tp-tooltip-time {
    margin-top: 0.15rem;
    opacity: 0.8;
}

.tp-tooltip-arrow {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 0.25rem solid transparent;
    border-right: 0.25rem solid transparent;
    border-top: 0.25rem solid var(--hmi-surface, #333333);
}

.tp-timeline-hour-label {
    position: absolute;
    bottom: -1.25rem;
    transform: translateX(-0.4rem);
    font-size: 0.6rem;
    color: var(--hmi-text-secondary, #b0b0b0);
    font-weight: 500;
    pointer-events: none;
}

/* Mode Colors */
.tp-mode-normal {
    background: linear-gradient(to right, #22c55e, #16a34a);
}

.tp-mode-absenken {
    background: linear-gradient(to right, #3b82f6, #2563eb);
}

.tp-mode-aufheizen {
    background: linear-gradient(to right, #f97316, #ea580c);
}

.tp-mode-ein {
    background: linear-gradient(to right, #22c55e, #16a34a);
}

.tp-mode-aus {
    background: linear-gradient(to right, #64748b, #475569);
}

.tp-mode-default {
    background: linear-gradient(to right, #64748b, #475569);
}

/* Action Buttons */
.tp-action-buttons {
    margin-left: auto;
    display: flex;
    gap: 0.4rem;
}

.tp-action-btn {
    padding: 0.3rem 0.5rem;
    background: var(--hmi-surface-light, #424242);
    border: 1px solid var(--hmi-border, #555555);
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--hmi-text, #ffffff);
    font-size: 0.75rem;
    font-family: inherit;
}

.tp-action-btn:hover:not(:disabled) {
    background: var(--hmi-border, #555555);
}

.tp-action-btn:disabled,
.tp-action-btn.disabled {
    background: var(--hmi-surface, #333333);
    color: var(--hmi-text-secondary, #b0b0b0);
    cursor: not-allowed;
}

.tp-action-icon {
    width: 0.875rem;
    height: 0.875rem;
    flex-shrink: 0;
    stroke-width: 2;
}

.tp-action-text {
    display: none;
}

@media (min-width: 640px) {
    .tp-action-text {
        display: inline;
        white-space: nowrap;
    }
}

/* Expanded Content */
.tp-expanded-content {
    padding: 0.75rem;
    background: rgba(30, 30, 30, 0.5);
}

.tp-slot-editors {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.tp-slot-editor {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: rgba(50, 50, 50, 0.5);
    border-radius: 0.25rem;
    transition: all 0.2s;
    border: 1px solid rgba(255,255,255,0.08);
}

.tp-slot-editor.highlighted {
    background: rgba(251, 191, 36, 0.2);
    border-color: #fbbf24;
}

.tp-mode-select {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--hmi-border, #555555);
    border-radius: 0.25rem;
    font-size: 0.8rem;
    background: var(--hmi-surface-light, #424242);
    color: var(--hmi-text, #ffffff);
    cursor: pointer;
    min-width: 90px;
    flex-shrink: 0;
    font-family: inherit;
}

.tp-mode-select:focus {
    outline: none;
    border-color: var(--hmi-primary, #c00a26);
}

.tp-mode-select option {
    background: var(--hmi-surface, #333333);
    color: var(--hmi-text, #ffffff);
}

.tp-time-display {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex: 1;
    min-width: 0;
    flex-shrink: 1;
}

.tp-time-start {
    font-size: 0.8rem;
    color: var(--hmi-text-secondary, #b0b0b0);
    font-weight: 500;
    white-space: nowrap;
}

.tp-time-arrow {
    color: var(--hmi-text-secondary, #b0b0b0);
}

.tp-time-input {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--hmi-border, #555555);
    border-radius: 0.25rem;
    font-size: 0.8rem;
    background: var(--hmi-surface-light, #424242);
    color: var(--hmi-text, #ffffff);
    min-width: 0;
    font-family: inherit;
}

.tp-time-input:focus {
    outline: none;
    border-color: var(--hmi-primary, #c00a26);
}

.tp-time-input:disabled {
    background: var(--hmi-surface, #333333);
    cursor: not-allowed;
    opacity: 0.6;
    color: var(--hmi-text-secondary, #b0b0b0);
}

/* Time input color scheme for dark theme */
.tp-time-input::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

.tp-delete-btn {
    margin-left: auto;
    padding: 0.3rem;
    background: transparent;
    border: none;
    color: #ef4444;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tp-delete-btn:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.2);
}

.tp-delete-btn:disabled,
.tp-delete-btn.disabled {
    color: var(--hmi-text-secondary, #b0b0b0);
    cursor: not-allowed;
}

.tp-delete-icon {
    width: 1rem;
    height: 1rem;
    stroke-width: 2;
}

.tp-expanded-timeline-wrapper {
    padding: 0.75rem 0;
}

/* Button Row - shared with Heizkurve */
.zeitprogramm-page .button-row {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding-top: 16px;
    margin-top: 8px;
}

.zeitprogramm-page .btn {
    padding: 12px 32px;
    border-radius: 999px;
    font-size: calc(14px * var(--hmi-scale));
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.zeitprogramm-page .btn-primary {
    background: #c00a26;
    color: #fff;
    border-color: #c00a26;
}

.zeitprogramm-page .btn-primary:hover:not(:disabled) {
    background: #a00820;
    border-color: #a00820;
}

.zeitprogramm-page .btn-primary:active {
    transform: scale(0.97);
}

.zeitprogramm-page .btn-secondary {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-color: rgba(255,255,255,0.2);
}

.zeitprogramm-page .btn-secondary:hover:not(:disabled) {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.3);
}

.zeitprogramm-page .btn-secondary:active {
    transform: scale(0.97);
}

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

/* Legacy Button Row - kept for backwards compatibility */
.tp-button-row {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin: 1rem 0;
}

.tp-btn {
    padding: 0.5rem 1.25rem;
    border: 1px solid var(--hmi-border, #555555);
    background: var(--hmi-surface-light, #424242);
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    color: var(--hmi-text, #ffffff);
    font-family: inherit;
}

.tp-btn:hover:not(:disabled) {
    background: var(--hmi-border, #555555);
}

.tp-btn-primary {
    background: var(--hmi-primary, #c00a26);
    color: white;
    border-color: var(--hmi-primary, #c00a26);
}

.tp-btn-primary:hover:not(:disabled) {
    background: #a00820;
    border-color: #a00820;
}

.tp-btn-secondary {
    background: var(--hmi-surface-light, #424242);
    color: var(--hmi-text, #ffffff);
}

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

/* Hover Indicators */
.tp-hover-indicator {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--hmi-primary, #c00a26);
    pointer-events: none;
    box-shadow: 0 0 6px rgba(192, 10, 38, 0.6);
    z-index: 50;
}

.tp-hover-time {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    background: var(--hmi-primary, #c00a26);
    color: white;
    font-size: 0.65rem;
    padding: 0.15rem 0.35rem;
    border-radius: 0.2rem;
    pointer-events: none;
    font-weight: 600;
    z-index: 50;
    white-space: nowrap;
}

/* Responsive adjustments - Tablet */
@media (max-width: 768px) {
    .zeitprogramm-page {
        padding: 80px 10px 20px 10px;
    }

    .tp-container {
        width: 100%;
    }

    .tp-panel {
        padding: 10px;
        border-radius: 12px;
    }

    /* Circuit selector for zeitprogramm */
    .zeitprogramm-page .circuit-selector {
        margin-bottom: 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .zeitprogramm-page .circuit-buttons {
        gap: 10px;
        flex-wrap: nowrap;
        min-width: min-content;
    }

    .zeitprogramm-page .circuit-btn {
        gap: 6px;
        min-width: 60px;
    }

    .zeitprogramm-page .circuit-icon {
        width: 48px;
        height: 48px;
        border-width: 2px;
    }

    .zeitprogramm-page .circuit-icon .mode-svg-icon {
        width: 26px;
        height: 26px;
    }

    .zeitprogramm-page .circuit-label {
        font-size: calc(10px * var(--hmi-scale));
    }

    .zeitprogramm-page .circuit-icon .mischer-number {
        width: 16px;
        height: 16px;
        font-size: calc(10px * var(--hmi-scale));
    }

    .tp-day-header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .tp-day-title {
        width: auto;
        font-size: 0.85rem;
    }

    .tp-timeline-container {
        width: 100%;
    }

    .tp-action-buttons {
        width: 100%;
        justify-content: flex-end;
        margin-top: 4px;
    }

    .tp-slot-editors {
        gap: 8px;
    }

    .tp-slot-editor {
        flex-wrap: nowrap;
        gap: 8px;
        padding: 10px;
    }

    .tp-mode-select {
        min-width: 80px;
        flex-shrink: 0;
    }

    .tp-time-display {
        flex: 1;
        justify-content: flex-start;
        min-width: 0;
    }

    .tp-delete-btn {
        flex-shrink: 0;
    }

    /* Button row */
    .zeitprogramm-page .button-row {
        gap: 10px;
        padding-top: 10px;
    }

    .zeitprogramm-page .btn {
        padding: 10px 20px;
        font-size: calc(13px * var(--hmi-scale));
        flex: 1;
        min-width: 100px;
    }
}

/* Responsive adjustments - Mobile */
@media (max-width: 480px) {
    .zeitprogramm-page {
        padding: 75px 6px 15px 6px;
    }

    .tp-panel {
        padding: 8px;
        border-radius: 10px;
    }

    .zeitprogramm-page .circuit-icon {
        width: 42px;
        height: 42px;
    }

    .zeitprogramm-page .circuit-icon .mode-svg-icon {
        width: 24px;
        height: 24px;
    }

    .zeitprogramm-page .circuit-label {
        font-size: calc(9px * var(--hmi-scale));
    }

    .tp-day-header {
        padding: 0.5rem;
    }

    .tp-day-title {
        font-size: 0.8rem;
    }

    .tp-timeline {
        height: 1.25rem;
    }

    .tp-slot-editor {
        padding: 6px;
        gap: 6px;
        flex-wrap: nowrap;
    }

    .tp-mode-select {
        font-size: calc(12px * var(--hmi-scale));
        padding: 5px;
        min-width: 70px;
    }

    .tp-time-input {
        font-size: calc(12px * var(--hmi-scale));
        padding: 5px;
        width: 70px;
    }

    .tp-time-start {
        font-size: calc(12px * var(--hmi-scale));
    }

    .tp-time-arrow {
        font-size: calc(12px * var(--hmi-scale));
    }

    .tp-delete-btn {
        width: 28px;
        height: 28px;
    }
}

/* Extra small screens */
@media (max-width: 375px) {
    .zeitprogramm-page {
        padding: 70px 4px 10px 4px;
    }

    .zeitprogramm-page .circuit-icon {
        width: 38px;
        height: 38px;
    }

    .zeitprogramm-page .circuit-label {
        font-size: calc(8px * var(--hmi-scale));
    }

    .tp-slot-editor {
        padding: 5px;
        gap: 4px;
    }

    .tp-mode-select {
        font-size: calc(11px * var(--hmi-scale));
        padding: 4px;
        min-width: 60px;
    }

    .tp-time-input {
        font-size: calc(11px * var(--hmi-scale));
        padding: 4px;
        width: 60px;
    }

    .tp-time-start {
        font-size: calc(11px * var(--hmi-scale));
    }

    .tp-delete-btn {
        width: 26px;
        height: 26px;
    }

    .tp-day-title {
        font-size: 0.75rem;
    }
}


/* ==========================================================================
   Circuit Selector Component (shared by Heizkurve and Zeitprogramm)
   ========================================================================== */

.circuit-selector {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.circuit-buttons {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.circuit-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 0;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.2s ease;
}

.circuit-btn:hover {
    color: var(--hmi-text, #ffffff);
}

.circuit-btn:hover .circuit-icon {
    border-color: rgba(255, 255, 255, 0.8);
    background: radial-gradient(circle, rgba(100,100,100,0.5) 0%, rgba(70,70,70,0.8) 100%);
}

.circuit-btn.active {
    color: var(--hmi-text, #ffffff);
}

.circuit-btn.active .circuit-icon {
    border-color: #c00a26;
    box-shadow: 0 0 8px 2px rgba(192, 10, 38, 0.7);
}

.circuit-btn.hidden {
    display: none;
}

.circuit-icon {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle, rgba(80,80,80,0.4) 0%, rgba(60,60,60,0.7) 100%);
    border: 3px solid rgba(255,255,255,0.6);
    border-radius: 50%;
    transition: all 0.2s ease;
}

.circuit-icon .mode-svg-icon {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

/* Mischer number badge for circuit selector */
.circuit-icon .mischer-number {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    background: rgb(192, 10, 38);
    border-radius: 50%;
    font-size: calc(14px * var(--hmi-scale));
    font-weight: bold;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.circuit-label {
    font-size: calc(14px * var(--hmi-scale));
    font-weight: 500;
}

/* Responsive circuit selector */
@media (max-width: 700px) {
    .circuit-buttons {
        gap: 15px;
    }

    .circuit-icon {
        width: 60px;
        height: 60px;
    }

    .circuit-icon .mode-svg-icon {
        width: 32px;
        height: 32px;
    }
}

@media (max-width: 480px) {
    .circuit-buttons {
        gap: 10px;
    }

    .circuit-icon {
        width: 50px;
        height: 50px;
    }

    .circuit-icon .mode-svg-icon {
        width: 26px;
        height: 26px;
    }

    .circuit-icon .mischer-number {
        width: 18px;
        height: 18px;
        font-size: calc(11px * var(--hmi-scale));
        bottom: -2px;
        right: -2px;
    }

    .circuit-label {
        font-size: calc(12px * var(--hmi-scale));
    }
}
