/* ==========================================================================
   NEOCARE - ESTILOS GLOBALES Y TIPOGRAFÍA
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #f8fafc;
    color: #0f172a;
    line-height: 1.5;
    padding-bottom: 2.5rem;
}

/* ==========================================================================
   NAVBAR Y ESTADOS
   ========================================================================== */
.navbar {
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.nav-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0.8rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.brand h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: #0369a1;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.baby-icon {
    font-size: 1.6rem;
}

.badge-live {
    background-color: #0284c7;
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    letter-spacing: 0.05em;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.time-display {
    font-size: 0.9rem;
    font-weight: 600;
    color: #64748b;
    font-variant-numeric: tabular-nums;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: #f1f5f9;
    padding: 0.4rem 0.88rem;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.status-dot.connected {
    background-color: #10b981;
    box-shadow: 0 0 8px #10b981;
}

.status-dot.disconnected {
    background-color: #cbd5e1;
}

.status-text {
    font-size: 0.8rem;
    font-weight: 500;
    color: #475569;
}

/* ==========================================================================
   LAYOUT PRINCIPAL
   ========================================================================== */
.dashboard {
    max-width: 1440px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: 330px 1fr;
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   TARJETAS Y FORMULARIOS
   ========================================================================== */
.card {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px -1px rgba(0, 0, 0, 0.01);
}

.sidebar h2 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.divider {
    border: 0;
    height: 1px;
    background-color: #e2e8f0;
    margin: 1.5rem 0;
}

.form-group {
    margin-bottom: 1rem;
}

.form-row {
    display: flex;
    gap: 0.8rem;
}

.form-group.col {
    flex: 1;
}

label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="date"],
select {
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-family: inherit;
    font-size: 0.85rem;
    color: #0f172a;
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    transition: all 0.2s ease;
}

input:focus,
select:focus {
    outline: none;
    border-color: #0284c7;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.btn {
    width: 100%;
    padding: 0.7rem 1rem;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: #0369a1;
    color: #ffffff;
}

.btn-primary:hover {
    background-color: #0284c7;
}

.btn-success {
    background-color: #059669;
    color: #ffffff;
}

.btn-success:hover {
    background-color: #10b981;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 1rem;
}

/* ==========================================================================
   BANNER DE ESTADO GLOBAL E ÍNDICE DE ESTABILIDAD
   ========================================================================== */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.status-banner {
    padding: 1.2rem 1.5rem;
    background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%);
    border-left: 6px solid #10b981;
}

.status-global-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
}

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

.status-badge-icon {
    font-size: 2.2rem;
}

.status-badge-info .status-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-badge-info h2 {
    font-size: 1.4rem;
    font-weight: 800;
    color: #059669;
}

.stability-index-box {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    background-color: #ffffff;
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.stability-info {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.stability-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #1e293b;
}

.stability-subtitle {
    font-size: 0.7rem;
    color: #64748b;
}

.stability-score {
    font-size: 2rem;
    font-weight: 800;
    color: #0284c7;
}

/* ==========================================================================
   METRIC CARDS
   ========================================================================== */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1.2rem;
}

.metric-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 135px;
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.metric-header h3 {
    font-size: 0.78rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.metric-icon {
    font-size: 1.2rem;
}

.metric-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0.2rem 0;
}

.metric-value .unit {
    font-size: 0.95rem;
    font-weight: 600;
    color: #94a3b8;
}

.metric-value-text {
    font-size: 1.4rem;
    font-weight: 800;
    color: #059669;
    margin: 0.4rem 0;
}

.metric-footer {
    font-size: 0.75rem;
    font-weight: 600;
}

.text-success { color: #059669; }
.text-warning { color: #d97706; }
.text-danger { color: #dc2626; }

.alert-pulse-card {
    animation: pulseBorderRed 1.5s infinite;
    background-color: #fff1f2 !important;
}

/* ==========================================================================
   MONITOR OSCILOSCOPIO PPG
   ========================================================================== */
.monitor-card {
    flex: 1;
    display: flex;
    flex-direction: column;
}

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

.monitor-header h2 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #334155;
}

.legend {
    display: flex;
    gap: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.ppg-color { background-color: #0284c7; }

.canvas-container {
    position: relative;
    width: 100%;
    height: 260px;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.sensor-alert-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.92);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.sensor-alert-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.alert-box {
    text-align: center;
    padding: 1.5rem;
    max-width: 420px;
}

.alert-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.4rem;
}

.alert-box h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: #991b1b;
    margin-bottom: 0.3rem;
}

.alert-box p {
    font-size: 0.82rem;
    color: #475569;
}

/* ==========================================================================
   TABLA DE EVENTOS CLÍNICOS
   ========================================================================== */
.events-card {
    display: flex;
    flex-direction: column;
}

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

.events-header h2 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #334155;
}

.events-count {
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    background-color: #f1f5f9;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.events-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.82rem;
}

.events-table th {
    background-color: #f8fafc;
    color: #64748b;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    padding: 0.65rem 0.8rem;
    border-bottom: 1px solid #e2e8f0;
}

.events-table td {
    padding: 0.65rem 0.8rem;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}

.events-table tr.empty-row td {
    text-align: center;
    color: #94a3b8;
    padding: 1.5rem;
}

.badge-event {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
}

.badge-event.danger { background-color: #fee2e2; color: #991b1b; }
.badge-event.warning { background-color: #fef3c7; color: #92400e; }
.badge-event.info { background-color: #e0f2fe; color: #075985; }

/* ==========================================================================
   ALERTA FLOTANTE
   ========================================================================== */
.system-alert {
    position: fixed;
    bottom: 1.8rem;
    right: 1.8rem;
    background-color: #b91c1c;
    color: #ffffff;
    padding: 0.9rem 1.4rem;
    border-radius: 8px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.25);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.system-alert.hidden {
    transform: translateY(100px);
    opacity: 0;
    pointer-events: none;
}

.sys-alert-content {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.sys-alert-icon {
    font-size: 1.5rem;
    animation: bounce 1s infinite alternate;
}

.sys-alert-text {
    display: flex;
    flex-direction: column;
}

.sys-alert-text strong {
    font-size: 0.88rem;
    font-weight: 700;
}

.sys-alert-text span {
    font-size: 0.78rem;
    opacity: 0.92;
}

@keyframes pulseBorderRed {
    0%, 100% {
        border-color: #e2e8f0;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
    }
    50% {
        border-color: #ef4444;
        box-shadow: 0 0 10px rgba(239, 68, 68, 0.25);
    }
}

@keyframes bounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-4px); }
}

/* ==========================================================================
   VIDEO-MONITOREO DE INCUBADORA
   ========================================================================== */
.video-monitor-box {
    margin-top: 1rem;
    text-align: left;
}

.video-monitor-box h2 {
    font-size: 0.85rem;
    font-weight: 700;
    color: #475569;
    margin-bottom: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.video-wrapper {
    position: relative;
    width: 100%;
    height: 170px;
    background-color: #0f172a;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #cbd5e1;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

#webcamFeed {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-lens-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: rgba(239, 68, 68, 0.85); /* Rojo vivo */
    color: #ffffff;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    letter-spacing: 0.05em;
    animation: blinkCamera 1.5s infinite;
}

@keyframes blinkCamera {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* NUEVA CAMARA LARGE DE VISTA CENTRAL */
.camera-large-card {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.5rem;
}

.camera-controls-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.camera-large-wrapper {
    position: relative;
    width: 100%;
    height: 480px; /* Tamaño grande clínico */
    background-color: #0b0f19;
    border-radius: 8px;
    overflow: hidden;
    border: 3px solid #0284c7;
    box-shadow: 0 10px 25px -5px rgba(2, 132, 199, 0.15), inset 0 0 20px rgba(0,0,0,0.8);
}

.camera-lens-overlay-large {
    position: absolute;
    top: 15px;
    right: 15px;
    background-color: rgba(14, 165, 233, 0.85); /* Azul clínico parpadeante */
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.3rem 0.7rem;
    border-radius: 6px;
    letter-spacing: 0.06em;
    animation: blinkCamera 1.5s infinite;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

/* Ocultar elementos */
.hidden {
    display: none !important;
}
