/*************************************************
 * AmpGuard Zentinel – SYSTEM DESIGN STYLESHEET
 * Version: 19.9.9 (Enterprise Master-Ledger-Core)
 * Slogan: Safety starts with precision
 *************************************************/

html, body { 
    margin: 0; 
    padding: 0; 
}

*, *::before, *::after { 
    box-sizing: border-box; 
}

/* ============================================================================
 * 🎨 SYSTEM-VARIABLEN & FARBRÄUME (DESIGN TOKENS)
 * ============================================================================ */
:root {
    /* Base Layout Colors */
    --bg: #f4f7f9;
    --card: #fff;
    --muted: #718096;
    --line: #e2e8f0;
    
    /* Brand & Interaction Tokens */
    --primary: #0ea5b5;
    --primary-dark: #0c8f9e;
    --whatsapp: #25d366;
    --text-dark: #1a202c;
    --text: var(--text-dark);
    --btn: var(--primary);
    --warn: #d9534f;
    
    /* Status & Severity Tokens */
    --success: #28a745;
    --warning: #e0a800;
    --danger: #ef4444;
    --neutral-gray: rgba(0, 0, 0, 0.25);
    
    --header-bg-base: #263041;
    --header-dark: #1f2937;
    
    /* Semantische Audit- & Tracking-Farbräume für lückenlose Analytics */
    --audit-qr-color: #0284c7;
    --audit-cal-color: #d97706;
    --audit-share-color: #7c3aed;
    --audit-view-color: #0891b2;
    
    /* NEW: Darkmode-adaptive Card-Backgrounds */
    --card-hover-bg: rgba(0, 0, 0, 0.02);
    --stat-card-bg: rgba(0, 0, 0, 0.02);

    /* Global Structural Design Tokens */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-round: 999px;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 10px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.3);
    --shadow-pro: 0 6px 20px rgba(14,165,181,0.35);
    --shadow-badge: 0 0 12px rgba(34,197,94,0.6);
    
    --transition-fast: transform 0.1s ease, box-shadow 0.15s ease;
    --transition-md: opacity 0.25s ease-in-out, transform 0.25s ease-in-out, background 0.15s ease;
}

body.dark {
    --bg: #0f1419;
    --card: #141a21;
    --text: #e8eef6;
    --muted: #8899a6;
    --line: #2f3336;
    --text-dark: #e8eef6;
    --neutral-gray: rgba(255, 255, 255, 0.15);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 10px rgba(0,0,0,0.4);
    --header-bg-base: #141a21;
    --card-hover-bg: rgba(255, 255, 255, 0.03);
    --stat-card-bg: rgba(255, 255, 255, 0.03);
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding-bottom: 40px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

/* ============================================================================
 * 🔝 HEADER-KOMPONENTE (LIVE-AMPEL & PLAKETTEN-STEUERUNG)
 * ============================================================================ */

.header-card {
    background-color: var(--header-bg-base); /* Definiert ein solides Fundament */
    color: #fff;
    padding: 40px 20px;
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
}

.header-card.status-neutral {
    background: var(--header-bg-base);
}

.header-card.pro { 
    background: linear-gradient(135deg, var(--header-dark), var(--primary)); 
    box-shadow: var(--shadow-pro); 
}

.header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
    position: relative;
    gap: 10px;
}

.status-pill {
    padding: 6px 14px;
    font-size: 0.85em;
    font-weight: 700;
    letter-spacing: 0.05em;
    border-radius: var(--radius-round);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    color: #fff;
}

.status-pill.ok { background: var(--success); }
.status-pill.warn { background: var(--warning); }
.status-pill.fail { background: var(--danger); }
.status-pill.neutral { background: var(--neutral-gray); }

.device-name { 
    font-size: 1.8em; 
    font-weight: 800; 
    margin: 0; 
    line-height: 1.1; 
}

.device-meta { 
    opacity: 0.9; 
    font-size: 0.95em; 
    margin-top: 4px; 
}

.prog-container { 
    background: rgba(255,255,255,0.25); 
    height: 8px; 
    border-radius: 4px; 
    margin-top: 15px; 
    position: relative; 
    overflow: hidden; 
}

.prog-fill { 
    height: 100%; 
    border-radius: 4px; 
    transition: width 0.6s ease; 
}

.pro .prog-fill { 
    animation: smoothGlow 2s ease-in-out infinite; 
}

@keyframes smoothGlow { 
    0% { opacity: 0.8; } 
    50% { opacity: 1; } 
    100% { opacity: 0.8; } 
}

@keyframes proGlow { 
    0% { box-shadow: 0 0 0 rgba(34,197,94,0.6); } 
    50% { box-shadow: var(--shadow-badge); } 
    100% { box-shadow: 0 0 0 rgba(34,197,94,0.6); } 
}

.sticker { 
    width: 50px; 
    height: 50px; 
    border-radius: 50%; 
    color: #fff; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-weight: bold; 
    border: 3px solid #fff; 
    box-shadow: 0 3px 6px rgba(0,0,0,0.2); 
    position: absolute; 
    top: 20px; 
    right: 20px; 
}
.sticker span { position: absolute; top: 4px; font-size: 8px; } 
.sticker b { font-size: 16px; margin-top: 2px; }

.pro-badge { 
    position: absolute; 
    top: 20px; 
    right: 80px; 
    background: linear-gradient(135deg, #22c55e, #4ade80); 
    color: #fff; 
    font-size: 0.75em; 
    font-weight: 800; 
    padding: 6px 12px; 
    border-radius: var(--radius-round); 
    box-shadow: var(--shadow-badge); 
    z-index: 5; 
    animation: proGlow 2.5s infinite; 
}

#themeToggle { 
    position: absolute; 
    top: 20px; 
    left: 20px; 
    background: none; 
    border: none; 
    color: #fff; 
    font-size: 1.2em; 
    cursor: pointer; 
    z-index: 100; 
}

/* ============================================================================
 * 🧱 LAYOUT BINDINGS, CARDS & COMPONENT ARCHITECTURE
 * ============================================================================ */
.wrap { 
    width: 100%; 
    max-width: 800px; 
    margin: 25px auto 0; 
    padding: 0 16px; 
    position: relative; 
    z-index: 2; 
}

.card { 
    background: var(--card); 
    border-radius: var(--radius-xl); 
    padding: 20px; 
    box-shadow: var(--shadow-md); 
    border: 1px solid rgba(0,0,0,0.04); 
    margin-bottom: 16px; 
    width: 100%; 
    overflow: hidden; 
}

.card.pro { 
    border: 1px solid rgba(14,165,181,0.25); 
    box-shadow: 0 6px 14px rgba(0,0,0,0.08); 
}

.card-header { padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.card-body { padding: 4px 0; }
.card-footer { padding-top: 12px; border-top: 1px solid var(--line); margin-top: 12px; }

@media(min-width:768px) {
    .card:hover {
        transform: translateY(-2px);
        transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
        box-shadow: 0 8px 16px rgba(0,0,0,0.08);
    }
}

.basic-lock { 
    opacity: 0.65; 
    position: relative; 
    cursor: not-allowed; 
}

.basic-lock::after { 
    content: "🔒 PRO Feature"; 
    position: absolute; 
    top: 10px; 
    right: 10px; 
    background: var(--text-dark); 
    color: #fff; 
    font-size: 0.7em; 
    padding: 4px 8px; 
    border-radius: var(--radius-sm); 
    font-weight: bold; 
    z-index: 10; 
}

.grid-2x2 { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 16px; 
    margin-bottom: 16px; 
}

@media(max-width:768px) { 
    .grid-2x2 { grid-template-columns: 1fr; } 
}

/* ============================================================================
 * 🔳 INTERACTIVE BUTTONS, ACCESSIBILITY & STATE CONTROLS
 * ============================================================================ */
.btn, .card .btn, .card img { 
    width: 100%; 
    max-width: 100%; 
    display: block; 
}

.btn { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px; 
    padding: 14px; 
    border-radius: var(--radius-lg); 
    text-decoration: none; 
    font-weight: bold; 
    margin-top: 10px; 
    border: none; 
    cursor: pointer; 
    font-size: 1em; 
    transition: var(--transition-fast); 
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #e2e8f0; color: var(--text-dark); }

.btn-variant-whatsapp { background: var(--whatsapp); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn.pulse { background: var(--warn); animation: pulseGlow 2s infinite; }

.btn:active { 
    transform: scale(0.97); 
}

.btn:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* 💣 CRITICAL FIX 1: Nativer, unumgehbarer UI-Lockout-State für asynchrone API-Hintergrundprozesse */
.btn.is-disabled, .btn:disabled, .btn.is-loading {
    background: var(--line) !important;
    color: var(--muted) !important;
    cursor: wait !important;
    transform: none !important;
    pointer-events: none !important;
    opacity: 0.5 !important;
}

@keyframes pulseGlow { 
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(217,83,79,0.7); } 
    70% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(217,83,79,0); } 
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(217,83,79,0); } 
}

.contact-card { padding: 0; margin-bottom: 10px; display: flex; align-items: center; gap: 15px; margin-top: 10px; } 
.avatar { width: 50px; height: 50px; background: #f1f3f5; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; overflow: hidden; box-shadow: 0 2px 4px rgba(0,0,0,0.06); flex-shrink: 0; } 
.avatar img { width: 100%; height: 100%; object-fit: contain; }

/* ============================================================================
 * 🖼️ MULTIMEDIA-GALERIE & LIGHTBOX
 * ============================================================================ */
.main-image img { width: 100%; border-radius: var(--radius-lg); margin-bottom: 10px; cursor: zoom-in; border: 1px solid var(--line); display: block; }
.media-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.gallery-img { width: 100%; height: 110px; object-fit: cover; border-radius: var(--radius-md); border: 1px solid var(--line); cursor: zoom-in; }

.ir-container { position: relative; border-radius: var(--radius-md); overflow: hidden; border: 2px solid var(--danger); box-shadow: 0 0 12px rgba(239,68,68,0.4); } 
.ir-badge { position: absolute; bottom: 0; left: 0; width: 100%; background: rgba(239,68,68,0.9); color: #fff; font-size: 0.7em; font-weight: bold; padding: 5px; text-align: center; }

.lb-arrow { background: rgba(255,255,255,0.2); backdrop-filter: blur(6px); border-radius: var(--radius-xl); padding: 10px; font-size: 18px; }
.lightbox-content { position: fixed; inset: 0; width: 100vw; height: 100vh; background: #000; display: flex; align-items: center; justify-content: center; z-index: 10000; }

#lightbox { 
    position: fixed; inset: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.95); 
    z-index: 99999; display: none; opacity: 0; transition: opacity 0.25s ease-in-out; 
}
#lightbox.active { 
    display: flex; opacity: 1; 
}

/* ============================================================================
 * 📅 SYSTEM-INTERNER PRÜFKALENDER (ACCORDION GRID)
 * ============================================================================ */
.calendar-panel { background: rgba(0,0,0,0.03); border: 1px solid var(--line); border-radius: var(--radius-xl); padding: 12px; margin-top: 15px; }
.acc-btn { background: var(--line); color: var(--text); border: none; padding: 12px; border-radius: var(--radius-md); width: 100%; text-align: left; font-weight: bold; cursor: pointer; display: flex; justify-content: space-between; align-items: center; } 
.acc-content { display: none; margin-top: 10px; }
.acc-content.open { display: block; }

.calendar-wrapper { margin-top: 15px; background: rgba(0,0,0,0.02); border: 1px solid var(--line); border-radius: var(--radius-xl); padding: 15px; text-align: center; } 
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: bold; }
.calendar-btn { background: var(--line); color: var(--text); border: none; padding: 4px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.9em; } 
.calendar-table { width: 100%; border-collapse: collapse; font-size: 0.85em; text-align: center; }
.calendar-table th { color: var(--muted); padding: 5px 2px; font-size: 0.8em; text-transform: uppercase; }
.calendar-table td { padding: 6px 2px; border-radius: var(--radius-sm); position: relative; width: 12.5%; }
.calendar-table .kw-col { color: var(--primary); font-weight: bold; font-size: 0.8em; background: rgba(14, 165, 181, 0.05); border-radius: 4px; }
.calendar-table .today { background: var(--primary); color: #fff; font-weight: bold; border-radius: var(--radius-sm); }
.calendar-table .deadline-day { border: 2px dashed var(--warn); font-weight: bold; color: var(--warn); }
.calendar-table .holiday { color: var(--danger); font-weight: bold;
/* ================= KALENDER STYLING ================= */

.calendar-table td.today {
    background: #0ea5b5;
    color: #fff;
    border-radius: 6px;
}

.calendar-table td.deadline-day {
    background: #ef4444;
    color: #fff;
    border-radius: 6px;
}

.calendar-table td.holiday {
    color: #f59e0b;
    font-weight: bold;
}
@media (max-width: 600px) {
    .wrap {
        max-width: 100% !important;
        padding: 0 10px;
    }

}
@media (min-width: 601px) and (max-width: 1024px) {
    .wrap {
        max-width: 90%;
    }
}
.wrap {
    max-width: 800px;
}
@media (min-width: 1600px) {
    .wrap {
        max-width: 1100px;
    }
}
@media (max-width: 768px) {
    .grid-2x2 {
        grid-template-columns: 1fr;
    }
}

.status-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.status-badge {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 8px;
    background: rgba(255,255,255,0.2);
}

.status-badge.pro {
    background: #16a34a;
    color: #fff;
}

.status-badge.audit {
    background: #0ea5b5;
    color: #fff;
}
/* ==== HEADER FIX ==== */


/* ============================================================================
 * 🔥 AMPEL FARBEN (DYNAMISCHE HEADER-GRADIENTS)
 * ============================================================================ */

/* GRÜN: Wenn der Status 'ok' ist (Bestanden) */
.header-card.ok {
    background: linear-gradient(135deg, #16a34a, #065f46) !important;
}

/* ORANGE: Wenn der Status 'warn' ist (Prüffrist naht) */
.header-card.warn {
    background: linear-gradient(135deg, #f59e0b, #92400e) !important;
}

/* ROT: Wenn der Status 'fail' ist (Handlungsbedarf) */
.header-card.fail {
    background: linear-gradient(135deg, #ef4444, #7f1d1d) !important;
}

/* GRAU: Fallback, falls kein Status matcht */
.header-card.neutral {
    background: var(--header-bg-base) !important;
}

/* Inhalt */

.header-content {
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
}

.header-top {
    margin-bottom: 12px;
}

.status-pill {
    background: rgba(255,255,255,0.25);
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 14px;
}

/* Geräte Name */

.device-name {
    font-size: 1.8em;
    font-weight: 800;
    margin: 10px 0;
}

.device-meta {
    font-size: 0.85em;
    opacity: 0.9;
}

/* Status-Bar unten */

.status-bar {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.status-badge {
    background: rgba(255,255,255,0.2);
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 12px;
}

.status-badge.pro {
    background: #16a34a;
}

.status-badge.audit {
    background: #0ea5b5;
}

.header-card.status-ok {
    background: linear-gradient(135deg, #16a34a, #065f46) !important;
}