/* =========================================
   MEDIC IQ ULTIMATE - SLEEK GLASSMORPHIC
   "APPLE STYLE" DARK DESIGN 
========================================= */

:root {
    /* --- DEIN NEUES FARBKONZEPT --- */
    --accent: #179299;         /* Ein sattes, professionelles Petrol */
    --accent-hover: #12757a;   /* Etwas dunkleres Petrol */
    
    --bg-anthrazit: #1e2327;   /* Dunkles Anthrazit für den Hintergrund */
    --glass-anthrazit: rgba(43, 50, 56, 0.7); /* Etwas helleres Anthrazit für Boxen */
    
    --text-lightgray: #e2e8f0; /* Weiches Hellgrau für den Text (blendet weniger als Weiß) */
    --text-muted: #94a3b8;     /* Dunkleres Hellgrau für Nebeninfos */

    /* BPR Farben (leicht angepasst, damit sie zum edlen Look passen) */
    --ekg-green: #2ecc71;
    --spo2-blue: #3498db;      
    --af-orange: #f39c12;
    --co2-purple: #9b59b6;
    --accent-red: #e74c3c;
    
    /* --- Glassmorphism Specs --- */
    --glass-bg: var(--glass-anthrazit);
    --glass-border: rgba(226, 232, 240, 0.15); /* Hellgrauer Glanz-Rand */
    --backdrop-blur: blur(20px);
    --panel-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    
    --text-main: var(--text-lightgray);
}

body, html {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; 
    /* Edler Anthrazit-Hintergrund */
    background-color: var(--bg-anthrazit); 
    /* Subtiler, weicher Petrol-Schimmer im Hintergrund */
    background-image: 
        radial-gradient(at 15% 15%, rgba(23, 146, 153, 0.15) 0px, transparent 45%),
        radial-gradient(at 85% 85%, rgba(23, 146, 153, 0.08) 0px, transparent 45%);
    color: var(--text-main);
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

#app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* =========================================
   2. SETUP AREA (Header)
========================================= */
/* =========================================
   STARTBILDSCHIRM & INFO-BOX
========================================= */
#setup-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; /* Zentriert alles perfekt in der Bildschirmmitte */
    height: 100vh;
    gap: 40px; /* Sauberer Abstand zwischen Menü und Info-Box */
    padding: 20px;
    box-sizing: border-box;
    z-index: 100;
}

.setup-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 15px; 
    width: 100%;
    max-width: 1100px;
}

.setup-info {
    background: rgba(30, 36, 42, 0.65);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    color: #e2e8f0;
    text-align: left;
    width: 100%;
    max-width: 900px;
    animation: fadeIn 0.6s ease-out;
}

.setup-info h3 {
    margin-top: 0;
    color: #fff;
    font-size: 1.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.sim-howto {
    font-size: 1.05rem;
    line-height: 1.6;
    margin-bottom: 30px;
    color: #cbd5e1;
}

.desc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.category-desc {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 0.9rem;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.category-desc:hover {
    background: rgba(23, 146, 153, 0.1);
    border-color: rgba(23, 146, 153, 0.4);
    transform: translateY(-4px);
}

.cat-icon {
    font-size: 2.2rem;
    margin-bottom: 12px;
}

.category-desc strong {
    color: #fff;
    font-size: 1.1rem;
    display: inline-block;
    margin-bottom: 8px;
}

select, .start-btn {
    padding: 12px 18px;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    font-size: 1rem;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 15px rgba(0, 168, 255, 0.3); }

.start-btn { 
    background: rgba(46, 204, 113, 0.15); 
    border-color: rgba(46, 204, 113, 0.4);
    color: var(--ekg-green);
    font-weight: 600; 
    cursor: pointer; 
}
.start-btn:hover { 
    background: var(--ekg-green); 
    color: #000;
    box-shadow: 0 0 20px rgba(46, 204, 113, 0.4); 
    transform: translateY(-1px);
}

/* =========================================
   3. MAIN INTERFACE (Die schwebenden Karten)
========================================= */
#sim-interface {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: calc(100% - 75px);
    overflow: hidden; 
    padding: 15px; /* Abstand zum Rand für den Glas-Effekt */
    gap: 15px; /* Lücken zwischen den Elementen */
}

#top-display {
    height: 45%; 
    display: flex;
    gap: 15px; /* Lücke zwischen Patient und Monitor */
    flex-shrink: 0; 
}

/* --- PATIENT VIEW --- */
#patient-view {
    flex: 1.2;
    position: relative;
    background: rgba(0,0,0,0.3);
    backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--panel-shadow);
    overflow: hidden;
}

#patient-view img, .layer {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%); 
    width: 100%; height: 100%;
    object-fit: contain;
    pointer-events: none;
}
.layer { top: 0; left: 0; transform: none; }

/* --- MONITOR VIEW --- */
#monitor-view {
    flex: 0.8;
    background: var(--glass-bg);
    backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--panel-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#ekgCanvas { flex: 1; width: 100%; background: transparent; }

/* Progress Bar & Vitalwerte */
#progress-container {
    width: 94%; margin: 10px auto; height: 18px;
    background: rgba(0,0,0,0.4);
    border-radius: 10px; border: 1px solid rgba(255,255,255,0.05);
    position: relative; overflow: hidden;
    flex-shrink: 0; transition: opacity 0.3s;
}
#progress-container.hidden { display: block !important; opacity: 0; pointer-events: none; }
#progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.1s linear; box-shadow: 0 0 10px var(--accent); }
#progress-text { position: absolute; inset: 0; text-align: center; font-size: 0.75rem; line-height: 18px; font-weight: 600; color: white; }

.vital-values {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    background: transparent; padding: 10px 15px; flex-shrink: 0;
}

.v-box {
    padding: 8px 15px;
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    display: flex; flex-direction: column; font-size: 0.85rem; color: var(--text-muted);
}
.v-box span { font-size: 1.8rem; font-weight: 700; }
.v-box.green span { color: var(--ekg-green); text-shadow: 0 0 10px rgba(46,204,113,0.3); }
.v-box.blue span { color: var(--spo2-blue); text-shadow: 0 0 10px rgba(0,210,255,0.3); }
.v-box.orange span { color: var(--af-orange); }
.v-box.purple span { color: var(--co2-purple); }
.v-box.white span { color: #fff; }

/* =========================================
   4. BOTTOM CONSOLE (Aktionen & Befunde)
========================================= */
#action-console {
    display: grid;
    grid-template-columns: 350px 1fr; 
    gap: 15px; /* Lücke zwischen Befunden und Aktionen */
    flex: 1;
    overflow: hidden; 
}

/* --- BEFUNDE (Links) --- */
#findings-summary {
    background: var(--glass-bg);
    backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--panel-shadow);
    display: flex; flex-direction: column; overflow: hidden; 
}

.summary-header {
    padding: 15px;
    background: rgba(0,0,0,0.2);
    font-weight: 600;
    border-bottom: 1px solid var(--glass-border);
    color: var(--accent);
    font-size: 1.05rem;
    flex-shrink: 0; 
}

#summary-content { padding: 12px; overflow-y: auto; flex: 1; font-size: 0.9rem; }

#summary-content p {
    margin: 6px 0; padding: 10px 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--glass-border);
    border-left: 3px solid var(--accent);
    border-radius: 8px; line-height: 1.4;
}
.empty-hint { color: var(--text-muted) !important; font-style: italic; border: none !important; background: transparent !important; text-align: center; margin-top: 20px !important; }

/* --- KONTROLLBEREICH (Rechts) --- */
#control-area {
    background: var(--glass-bg);
    backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--panel-shadow);
    display: flex; flex-direction: column; overflow: hidden; 
}

/* Apple-Style Segmented Control (Tabs) */
#nav-tabs {
    display: flex; gap: 5px; padding: 10px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0; 
}
#nav-tabs button {
    flex: 1; border: 1px solid transparent; background: transparent;
    color: var(--text-muted); font-weight: 600; font-size: 0.9rem;
    border-radius: 10px; cursor: pointer; transition: all 0.2s;
}
#nav-tabs button:hover { background: rgba(255,255,255,0.05); color: #fff; }
#nav-tabs button.active { 
    background: rgba(0, 229, 255, 0.1); 
    color: var(--accent); 
    border-bottom: 2px solid var(--accent);
}
#nav-tabs button.handover-tab { color: var(--ekg-green); }
#nav-tabs button.handover-tab.active { background: rgba(46, 204, 113, 0.2); border-color: rgba(46, 204, 113, 0.4); }

#tab-content { 
    /* NEU: Zwingt den Button-Bereich, KLEINER zu sein! */
    flex: 0 0 38%; 
    padding: 12px 15px; 
    overflow-y: auto; 
    background: transparent; 
}

/* --- Aktives Tab Menü --- */
#nav-tabs button.active { 
    background: rgba(23, 146, 153, 0.15); /* Petrol transparent */
    color: var(--accent); 
    border-bottom: 2px solid var(--accent);
}

/* --- Button Grid & Verhalten --- */
.action-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); 
    grid-auto-rows: minmax(60px, auto); 
    gap: 10px; 
}

.action-btn {
    width: 100%;
    height: auto !important; 
    min-height: 100%; 
    background: rgba(226, 232, 240, 0.04); /* Sehr dezentes Hellgrau */
    color: var(--text-lightgray); 
    line-height: 1.35;
    border-radius: 10px; 
    padding: 12px 8px; 
    border: 1px solid var(--glass-border);
    font-size: 0.85rem; 
    cursor: pointer; 
    transition: all 0.2s;
    
    /* Textumbruch-Garantie */
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
    hyphens: auto;
    
    display: flex;
    flex-direction: column; 
    justify-content: center;
    align-items: center;
    text-align: center;
}

.action-btn:hover { 
    background: rgba(23, 146, 153, 0.2); /* Elegantes Petrol beim Hover */
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(23, 146, 153, 0.25);
    transform: translateY(-2px); 
    color: #fff; /* Text wird beim Hovern noch strahlender */
}

/* --- LOG-BEREICH --- */
#action-log {
    flex: 1; 
    padding: 15px 20px;
    overflow-y: auto; 
    background: rgba(22, 26, 30, 0.6); /* Dunkles Anthrazit für mehr Tiefe */
    border-top: 1px solid var(--glass-border);
    color: var(--text-lightgray); 
    font-size: 0.95rem; 
    line-height: 1.5;
    display: flex; 
    flex-direction: column-reverse; 
}
.log-entry { margin-bottom: 6px; padding: 8px 12px; background: rgba(255,255,255,0.02); border-left: 3px solid rgba(255,255,255,0.2); border-radius: 0 8px 8px 0; }
.critical { color: var(--accent-red); font-weight: 600; }
.warn { color: var(--af-orange); }
.hidden { display: none !important; }

/* =========================================
   5. MODALS (Die Apple-Unschärfe Overlays)
========================================= */
#material-modal, #o2-modal, #eval-modal {
    position: fixed; inset: 0; z-index: 10000;
    display: flex; justify-content: center; align-items: center;
}
.modal-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.6); 
    backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
}
.modal-inner, .eval-content {
    position: relative; width: 90%; max-width: 500px;
    background: rgba(25, 30, 45, 0.7);
    backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    border-radius: 24px; padding: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6); color: white;
}

#modal-title { margin-top: 0; color: #fff; font-weight: 700; letter-spacing: -0.5px; }
.modal-hint { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 20px; }

#material-list label, .m-check-label {
    display: block; background: rgba(0,0,0,0.3); padding: 14px; margin: 8px 0;
    border: 1px solid var(--glass-border); border-radius: 12px; cursor: pointer; transition: 0.2s; font-size: 1rem;
}
#material-list label:hover, .m-check-label:hover { background: rgba(255,255,255,0.05); }

.confirm-btn {
    width: 100%; padding: 15px; margin-top: 20px;
    background: var(--accent); color: #fff; font-weight: 600; font-size: 1.1rem;
    border: none; border-radius: 12px; cursor: pointer; transition: 0.2s;
}
.confirm-btn:hover { background: #00d2ff; transform: translateY(-1px); box-shadow: 0 5px 20px rgba(0,168,255,0.4); }
.cancel-btn {
    width: 100%; padding: 12px; margin-top: 10px;
    background: transparent; color: var(--text-muted); border: 1px solid var(--glass-border);
    border-radius: 12px; cursor: pointer; transition: 0.2s;
}
.cancel-btn:hover { background: rgba(255,255,255,0.05); color: white; }

/* REA HUD */
#arrest-hud {
    position: absolute; inset: 0; background: rgba(139, 0, 0, 0.6);
    backdrop-filter: blur(10px); z-index: 8000; display: flex; justify-content: center; align-items: center;
}
.arrest-content {
    background: rgba(20,0,0,0.8); backdrop-filter: blur(20px); padding: 40px; 
    border: 1px solid rgba(231,76,60,0.5); border-radius: 24px; text-align: center; box-shadow: 0 0 50px rgba(231,76,60,0.4);
}
.cpr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin: 20px 0; }
.cpr-grid button {
    padding: 20px; font-size: 1.1rem; font-weight: bold; cursor: pointer;
    border-radius: 14px; border: 1px solid var(--glass-border); background: rgba(255,255,255,0.05); color: white; transition: 0.2s;
}
#btn-hdm.active-task, #btn-vent.active-task { background: rgba(46,204,113,0.3); border-color: var(--ekg-green); animation: pulse 1s infinite; }
#btn-shock { background: rgba(241,196,15,0.2); border-color: #f1c40f; color: #f1c40f; grid-column: span 2; }

/* End Auswertung */
.score-circle {
    font-size: 4.5rem; font-weight: 800; color: #fff;
    margin: 20px auto; width: 150px; height: 150px; display: flex; justify-content: center; align-items: center;
    background: rgba(0,0,0,0.3); border: 8px solid rgba(255,255,255,0.1); border-radius: 50%;
}
.restart-btn {
    background: var(--ekg-green); color: #000; border: none; font-size: 1.1rem;
    padding: 15px 30px; font-weight: 600; border-radius: 12px; cursor: pointer;
    margin-top: 20px; transition: 0.2s; width: 100%;
}
.restart-btn:hover { box-shadow: 0 8px 25px rgba(46,204,113,0.4); transform: translateY(-2px); }

/* =========================================
   6. ANIMATIONEN & SPEZIAL-TOOLS
========================================= */
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.03); } 100% { transform: scale(1); } }
@keyframes pulse-red { 0% { background: rgba(231,76,60,0.2); } 50% { background: rgba(231,76,60,0.6); } 100% { background: rgba(231,76,60,0.2); } }
#tab-rea { animation: pulse-red 1.5s infinite; color: white !important; border-color: var(--accent-red) !important; }

@keyframes breathe {
    0%   { transform: translate(-50%, -50%) scale(1, 1); }
    40%  { transform: translate(-50%, -50%) scale(1.015, 1.02); filter: brightness(1.02); }
    100% { transform: translate(-50%, -50%) scale(1, 1); }
}
/* --- Spezielle Puls-Animation für die Lunge im AF-Modal --- */
@keyframes ui-breathe {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.25); filter: brightness(1.2); }
    100% { transform: scale(1); }
}
/* Pupillen & Mund behalten ihre Struktur, aber passen sich farblich an */
#eyes-container {
    position: relative; background: rgba(0,0,0,0.4); display: flex; gap: 60px; justify-content: center;
    padding: 80px 40px; border-radius: 12px; cursor: none; overflow: hidden; border: 1px solid var(--glass-border);
}
.eye-socket { width: 160px; height: 70px; background: #fdfdfd; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 0 15px rgba(0,0,0,0.6); overflow: hidden; }
.iris { width: 65px; height: 65px; background: radial-gradient(circle, #3498db 40%, #2980b9 80%, #1c2833 100%); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.pupil { width: var(--pupil-size, 25px); height: var(--pupil-size, 25px); background: #000; border-radius: 50%; transition: width 0.15s ease-out, height 0.15s ease-out; box-shadow: 0 0 3px rgba(0,0,0,0.8); }
#flashlight { position: absolute; width: 250px; height: 250px; background: radial-gradient(circle, rgba(255,255,255,0.85) 0%, rgba(255,255,255,0.3) 40%, rgba(255,255,255,0) 70%); border-radius: 50%; pointer-events: none; transform: translate(-50%, -50%); opacity: 0; transition: opacity 0.2s; z-index: 10; }

@keyframes blink-eyes { 0%, 96% { opacity: 0; } 98% { opacity: 1; } 100% { opacity: 0; } }

#mouth-container {
    position: relative; background: #2a0808; width: 100%; height: 200px; border-radius: 12px; overflow: hidden;
    display: flex; align-items: center; justify-content: center; cursor: none; box-shadow: inset 0 0 30px #000; border: 1px solid var(--glass-border);
}
#mouth-content { font-size: 3.5rem; text-align: center; line-height: 1.3; text-shadow: 0 0 15px rgba(0,0,0,0.9); z-index: 2; }
#mouth-darkness { position: absolute; inset: 0; background: radial-gradient(circle at var(--light-x, 50%) var(--light-y, 50%), transparent 10%, rgba(0,0,0,0.98) 40%); z-index: 10; pointer-events: none; }

/* SAMPLER CHAT */
.chat-msg { padding: 10px 14px; border-radius: 14px; max-width: 80%; font-size: 0.95rem; line-height: 1.4; animation: fadeIn 0.3s ease-in-out; border: 1px solid var(--glass-border); }
.msg-sys { background: transparent; color: var(--text-muted); font-style: italic; text-align: center; margin: 0 auto; border: none; }
.msg-user { background: rgba(0, 168, 255, 0.2); color: white; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg-patient { background: rgba(46, 204, 113, 0.2); color: white; align-self: flex-start; border-bottom-left-radius: 4px; }
.msg-bystander { background: rgba(155, 89, 182, 0.2); color: white; align-self: flex-start; border-bottom-left-radius: 4px; }

.sampler-btn {
    background: rgba(255,255,255,0.05); color: #fff; border: 1px solid var(--glass-border);
    padding: 12px; border-radius: 12px; cursor: pointer; font-size: 0.9rem; transition: 0.2s; text-align: left;
}
.sampler-btn:hover { background: rgba(0, 168, 255, 0.2); border-color: var(--accent); }
.sampler-btn:disabled { opacity: 0.4; cursor: not-allowed; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* Elegante Apple-Scrollbars */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }
@media (max-width: 1100px) {
    /* Verkleinert die gesamte UI leicht, damit sie aufs iPad passt */
    #app-container {
        transform: scale(0.9);
        transform-origin: top center;
        width: 110% !important; /* Gleicht das Scaling aus */
        margin-left: -5% !important;
    }
    
    /* Falls die Button-Leiste zu breit ist: */
    .action-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1-fr)) !important;
        gap: 5px !important;
    }

    /* Monitor-Werte etwas verkleinern */
    .vitals-grid {
        gap: 8px !important;
    }
}