/**
 * Philips IntelliVue Style Monitor CSS
 * Professional medical monitor interface
 */

/* Reset and base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* IntelliVue color scheme */
    --color-ecg: #00ff00;
    --color-spo2: #00ffff;
    --color-abp: #ff0000;
    --color-resp: #ffff00;
    --color-co2: #ffff00;
    --color-temp: #ffffff;

    /* Background colors */
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-channel: #050505;
    --border-color: #333333;

    /* Text colors */
    --text-primary: #ffffff;
    --text-secondary: #888888;
    --text-dim: #555555;

    /* Alarm colors */
    --alarm-critical: #ff0000;
    --alarm-high: #ffaa00;
    --alarm-medium: #ffff00;
}

html, body {
    height: 100%;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Segoe UI', 'Arial', sans-serif;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Color utility classes */
.color-ecg { color: var(--color-ecg); }
.color-spo2 { color: var(--color-spo2); }
.color-abp { color: var(--color-abp); }
.color-resp { color: var(--color-resp); }
.color-co2 { color: var(--color-co2); }
.color-temp { color: var(--color-temp); }

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #1a1a1a;
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.modal-content h2 {
    margin-bottom: 1rem;
    color: var(--color-spo2);
}

.modal-content p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.modal-content input {
    padding: 0.8rem 1rem;
    font-size: 1.5rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.3em;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 4px;
    width: 200px;
    margin-bottom: 1rem;
}

.modal-content input:focus {
    outline: none;
    border-color: var(--color-spo2);
}

.btn {
    padding: 0.8rem 2rem;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--color-spo2);
    color: #000;
}

.btn-primary:hover {
    background: #00dddd;
}

.btn-primary:disabled {
    background: var(--text-dim);
    cursor: not-allowed;
}

.error-text {
    color: var(--alarm-critical);
    font-size: 0.9rem;
    margin-top: 1rem;
}

/* Hidden class */
.hidden {
    display: none !important;
}

/* Monitor container - Fixed size for standard monitor */
#monitor-container {
    display: flex;
    flex-direction: column;
    width: 1920px;
    height: 1080px;
    max-width: 100vw;
    max-height: 100vh;
    background: var(--bg-primary);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

/* Status bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    height: 36px;
    flex-shrink: 0;
}

.status-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.connection-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--alarm-critical);
}

.connection-indicator.connected {
    background: var(--color-ecg);
}

#connection-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.status-center {
    flex: 1;
    text-align: center;
}

.alarm-message {
    font-size: 0.9rem;
    font-weight: bold;
    animation: alarm-blink 0.5s infinite;
}

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

.status-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#current-time {
    font-size: 0.9rem;
    font-family: monospace;
    color: var(--text-secondary);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.2rem;
}

.btn-icon:hover {
    color: var(--text-primary);
}

/* Main content area */
.monitor-main {
    display: flex;
    flex: 1;
  /*height: calc(100% - 36px); /* hauteur totale - barre du haut */
    overflow: hidden;
}

/* Waveforms section: MUST have full height */
.waveforms-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;    /* <-- CRUCIAL : permet aux enfants de recevoir une vraie hauteur */
}

/* Each waveform channel expands proportionally */
.waveform-channel {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    height: 150px;        /* 👈 CHANGE SEULEMENT CE NOMBRE */
    flex: 0 0 auto;       /* 👈 STOP flex-height */
}

/* Alignment with numeric boxes (6 unités en tout) */

.waveform-channel:nth-child(1) { flex: 1; } /* ECG */
.waveform-channel:nth-child(2) { flex: 1; } /* ABP */
.waveform-channel:nth-child(3) { flex: 1; } /* Pleth */
.waveform-channel:nth-child(4) { flex: 1; } /* Capno */
.waveform-channel:nth-child(5) { flex: 2; } /* Resp (EtCO2 + Temp) */

.waveform-channel:last-child {
    border-bottom: none;
}

/* CANVAS MUST FILL THE CHANNEL */
.waveform-canvas {
    width: 100%;
    height: 100%;    /* <-- clé absolue */
    display: block;  /* <-- évite hauteur collapsée */
    background: black;
}


.channel-info {
    width: 50px;
    padding: 0.3rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    background: var(--bg-channel);
    border-right: 1px solid var(--border-color);
}

.channel-label {
    font-size: 0.9rem;
    font-weight: bold;
}

.channel-scale {
    font-size: 0.6rem;
    color: var(--text-dim);
    margin-top: 0.2rem;
}

.channel-ecg { color: var(--color-ecg); }
.channel-abp { color: var(--color-abp); }
.channel-spo2 { color: var(--color-spo2); }
.channel-co2 { color: var(--color-co2); }
.channel-resp { color: var(--color-resp); }

.waveform-canvas {
    flex: 1;
    background: var(--bg-primary);
    width: 100%;
    height: 100%;    /* <-- Le point clé */
    display: block;  /* <-- Évite les bugs de taille */
}

/* Numerics section */
.numerics-section {
    width: 260px;          /* 👈 taille visuelle idéale */
    flex-shrink: 0;        /* 👈 empêche l'étirement */
    display: flex;
    flex-direction: column;
    height: 100%;
}


.numeric-box {
    padding: 0.5rem 0.8rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

/* Align numeric boxes with their waveforms */
.numeric-box:nth-child(1) { flex: 1; } /* HR -> ECG */
.numeric-box:nth-child(2) { flex: 1; } /* SpO2 -> ABP */
.numeric-box:nth-child(3) { flex: 1; } /* BP -> Pleth */
.numeric-box:nth-child(4) { flex: 1; } /* Resp -> Capno */
.numeric-box:nth-child(5) { flex: 1; } /* EtCO2 -> Resp (part 1) */
.numeric-box:nth-child(6) { flex: 1; } /* Temp -> Resp (part 2) */

.numeric-box:last-child {
    border-bottom: none;
}

.numeric-box.alarm-active {
    animation: numeric-alarm 0.5s infinite;
}

@keyframes numeric-alarm {
    0%, 100% { background: var(--bg-primary); }
    50% { background: rgba(255, 0, 0, 0.3); }
}

.numeric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.1rem;
}

.numeric-label {
    font-size: 0.85rem;
    font-weight: bold;
}

.numeric-source {
    font-size: 0.65rem;
    color: var(--text-dim);
}

.numeric-value {
    font-size: 2.8rem;
    font-weight: bold;
    font-family: 'Segoe UI', Arial, sans-serif;
    line-height: 1;
}

.numeric-value span {
    font-variant-numeric: tabular-nums;
}

.numeric-mean {
    font-size: 1.2rem;
    margin-top: 0.1rem;
}

.numeric-unit {
    font-size: 0.7rem;
    color: var(--text-dim);
    position: absolute;
    bottom: 0.5rem;
    right: 0.8rem;
}

.numeric-secondary {
    font-size: 0.8rem;
    margin-top: 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.pr-label, .fi-label {
    color: var(--text-dim);
    font-size: 0.7rem;
}

/* Alarm bar */
.alarm-bar {
    padding: 0.5rem 1rem;
    background: var(--alarm-critical);
    color: #fff;
    font-weight: bold;
    text-align: center;
    animation: alarm-flash 0.5s infinite;
}

@keyframes alarm-flash {
    0%, 100% { background: var(--alarm-critical); }
    50% { background: #aa0000; }
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .numerics-section {
        width: 240px;
    }

    .numeric-value {
        font-size: 2.2rem;
    }
}

@media (max-width: 900px) {
    .numerics-section {
        width: 200px;
    }

    .numeric-value {
        font-size: 1.8rem;
    }

    .channel-info {
        width: 40px;
    }
}

/* Fullscreen mode */
:fullscreen {
    background: var(--bg-primary);
}

:fullscreen #monitor-container {
    height: 100vh;
}
