:root {
    /* Paleta de colores principal */
    --color-gob-primary: #0D47A1;
    --color-gob-primary-dark: #0a3a8a;
    --color-gob-primary-light: #3d6bb8;

    /* Colores TRIAGE */
    --color-c1: #C62828;
    --color-c2: #EF6C00;
    --color-c3: #F9A825;
    --color-c4: #2E7D32;
    --color-c5: #1565C0;

    --color-critico: black;

    /* Escala de grises */
    --color-light: #F8F9FA;
    --color-dark: #212529;
    --color-gray: #6C757D;
    --color-gray-light: #E9ECEF;
    --color-gray-lighter: #F1F3F5;
}

/* Estilos para validación en tiempo real */
.input-group-with-alert {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-group-with-alert .input-group {
    flex: 1;
}

.input-alert-icon {
    background-color: #DC3545;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    cursor: help;
    animation: pulse-alert 0.6s ease-in-out infinite;
    z-index: 20;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    pointer-events: auto;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.input-alert-icon:hover {
    background-color: #C82333;
    transform: scale(1.15);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

@keyframes pulse-alert {
    0%, 100% {
        box-shadow: 0 2px 6px rgba(220, 53, 69, 0.5);
    }
    50% {
        box-shadow: 0 4px 12px rgba(220, 53, 69, 0.7);
    }
}

.input-critical {
    border-color: #DC3545 !important;
    background-color: #fff8f8 !important;
    box-shadow: inset 0 1px 1px rgba(220, 53, 69, 0.1) !important;
}

html,
body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overscroll-behavior: none;
    /* evita el efecto de "elastic scroll" */
    scroll-behavior: smooth;

}

/* Estructura base */
body {
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    color: var(--color-dark);
    background-color: var(--color-gray-lighter);
    line-height: 1.5;
    margin: 0;
    padding: 0;
}

/* Header */
header {
    background-color: #0D47A1;
    color: white;
    padding: 0.75rem 0;
    border-bottom: 2px solid #0a3a8a;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

footer {
    background-color: #0D47A1;
    color: white;
    padding: 0.75rem 0;
    border-top: 2px solid #0a3a8a;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.gov-logo {
    height: 40px;
}

/* Sidebar */
.sidebar {
    background-color: #0D47A1;
    padding: 1rem;
}

.nav-link {
    color: rgba(255, 255, 255, 0.9);
    padding: 0.5rem 1rem;
    margin-bottom: 0.25rem;
    border-left: 2px solid transparent;
    transition: all 0.2s;
    border-radius: 5px;
}

.nav-link:hover,
.nav-link.active {
    background-color: rgba(255, 255, 255, 0.1);
    border-left-color: white;
    color: var(--color-gray-light);
}

/* Contenido principal */
main {
    background-color: white;
    padding: 1.5rem;
    min-height: calc(100vh - 56px);
}

.section {
    margin-bottom: 2rem;
}

/* Componentes de tarjetas */
.card {
    border: 1px solid var(--color-gray-light);
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.card-header {
    background-color: #0D47A1;
    color: white;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.card-body {
    padding: 1.25rem;
}

/* Formularios */
.form-control,
.form-select {
    border: 1px solid var(--color-gray-light);
    padding: 0.5rem 0.75rem;
}

.form-control:focus,
.form-select:focus {
    border-color: #0D47A1;
    box-shadow: 0 0 0 0.2rem rgba(13, 71, 161, 0.1);
}

.form-label {
    font-weight: bold;
    margin-bottom: 0.25rem;
}

fieldset {
    border: 1px solid var(--color-gray-light) !important;
    padding: 1rem;
    margin-bottom: 1rem;
}

legend {
    font-size: 1.1rem;
    color: #0D47A1;
    font-weight: 600;
}

/* Botones */
.btn {
    padding: 0.5rem 1rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background-color: #0D47A1;
    border-color: #0D47A1;
}

.btn-primary:hover {
    background-color: #0a3a8a;
    border-color: #0a3a8a;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Tablas */
.table {
    font-size: 0.875rem;
}

.table th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: var(--color-gray);
    border-bottom: 2px solid var(--color-light);
}

/* Badges TRIAGE */
.badge-triage {
    display: inline-block;
    padding: 0.25em 0.5em;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    border-radius: 5px;
}

.badge-c1 {
    background-color: var(--color-c1);
    color: white;
}

.badge-c2 {
    background-color: var(--color-c2);
    color: white;
}

.badge-c3 {
    background-color: var(--color-c3);
    color: white;
}

.badge-c4 {
    background-color: var(--color-c4);
    color: white;
}

.badge-c5 {
    background-color: var(--color-c5);
    color: white;
}

/* Modal de TRIAGE mejorado */
#modal-triage .modal-content {
    border: none;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

#modal-triage .modal-header {
    background-color: var(--color-gob-primary);
    color: white;
    border-bottom: none;
    padding: 1.25rem;
}

#modal-triage .modal-body {
    padding: 0;
}

#modal-triage .modal-footer {
    background-color: var(--color-gray-lighter);
    border-top: none;
    padding: 1rem 1.5rem;
}

/* Contenedor principal del resultado */
#triage-alert {
    padding: 2rem;
    margin-bottom: 0;
    border-radius: 0;
    border-bottom: 1px solid var(--color-gray-light);
}

/* Badge de nivel TRIAGE */
.triage-level-badge {
    width: 80px;
    height: 80px;
    font-size: 2rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 4px solid white;
    border-radius: 50%;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Colores específicos para cada nivel */
.triage-level-badge.badge-c1 {
    background-color: var(--color-c1);
    color: white;
}

.triage-level-badge.badge-c2 {
    background-color: var(--color-c2);
    color: white;
}

.triage-level-badge.badge-c3 {
    background-color: var(--color-c3);
    color: white;
}

.triage-level-badge.badge-c4 {
    background-color: var(--color-c4);
    color: white;
}

.triage-level-badge.badge-c5 {
    background-color: var(--color-c5);
    color: white;
}

/* Título del resultado */
#triage-descripcion {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem;
}

/* Sección de tarjetas de información */
#modal-triage .card {
    border: none;
    box-shadow: none;
    margin-bottom: 0;
}

#modal-triage .card-header {
    background-color: transparent;
    color: var(--color-dark);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-gray-light);
    font-weight: 600;
}

#modal-triage .card-body {
    padding: 1.5rem;
}

/* Tiempo de espera */
#tiempo-espera {
    font-size: 1.75rem;
    font-weight: 700;
    color: white;
}

/* Sistema de estado */
.system-status {
    background-color: rgba(0, 0, 0, 0.15);
    padding: 1rem;
    margin-top: 1rem;
    color: var(--color-light);
    border-radius: 5px;
}

/* Estado del sistema - Indicadores */
.status-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.5rem;
    transition: background-color 0.3s ease;
}

.status-indicator.bg-success {
    background-color: #2E7D32; /* Verde para online */
    box-shadow: 0 0 5px rgba(46, 125, 50, 0.5);
}

.status-indicator.bg-danger {
    background-color: #C62828; /* Rojo para offline */
    box-shadow: 0 0 5px rgba(198, 40, 40, 0.5);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(198, 40, 40, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(198, 40, 40, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(198, 40, 40, 0);
    }
}

/* Estilos para alertas en la ficha de detalle */
#modal-detalle-paciente .detalle-alert-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background-color: var(--color-c1);
    color: #fff;
    border-radius: 50%;
    font-size: 0.95rem;
    margin-left: 0.4rem;
    vertical-align: middle;
    box-shadow: 0 0 0 0 rgba(198,40,40,0.35);
    transition: transform 0.12s ease, box-shadow 0.18s ease;
}

#modal-detalle-paciente .detalle-alert-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(198,40,40,0.18);
}

#detalle-razones {
    margin-top: 0.35rem;
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

#detalle-razones .badge-reason {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.55rem;
    background-color: rgba(198,40,40,0.06);
    color: var(--color-c1);
    border: 1px solid rgba(198,40,40,0.15);
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.85rem;
}

#detalle-razones .badge-reason::before {
    content: "!";
    display: inline-flex;
    width: 16px;
    height: 16px;
    align-items: center;
    justify-content: center;
    background-color: var(--color-c1);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
}

/* Badges TRIAGE en la tabla - Versión corregida */
#tabla-pacientes .badge-triage {
    border-radius: 12px;
    padding: 0.35em 0.65em;
    font-size: 0.75em;
    font-weight: 700;
    letter-spacing: 0.5px;
    min-width: 40px;
    text-align: center;
    display: inline-block;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    line-height: 1.5;
    /* Asegura buena altura */
}

/* Ocultar paginación cuando no hay datos */
#tabla-pacientes:empty ~ .card-footer #pagination-controls {
    display: none !important;
}

/* Estilo para el mensaje cuando no hay registros */
.table-empty + .card-footer #contador-pacientes {
    font-style: italic;
}

/* Asegurar que los badges hereden correctamente los estilos */
#tabla-pacientes .badge-c1,
#tabla-pacientes .badge-c2,
#tabla-pacientes .badge-c3,
#tabla-pacientes .badge-c4,
#tabla-pacientes .badge-c5 {
    color: white !important;
    /* Forzar texto blanco */
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
    /* Mejorar legibilidad */
}

/* Estilos para los badges de riesgo */
#tabla-pacientes .badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.5em 0.75em;
    border-radius: 12px;
    min-width: 80px;
    text-align: center;
    display: inline-block;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-transform: uppercase;
}

/* Colores específicos para los niveles de riesgo */
#tabla-pacientes .badge.bg-success {
    background-color: var(--color-c4) !important; /* Verde */
}

#tabla-pacientes .badge.bg-warning {
    background-color: var(--color-c3) !important; /* Amarillo */
}

#tabla-pacientes .badge.bg-danger {
    background-color: var(--color-c1) !important; /* Naranja */
}

#tabla-pacientes .badge.bg-dark {
    background-color: var(--color-critico) !important; /* Rojo */
}

/* Asegurar que el texto sea legible */
#tabla-pacientes .badge span {
    color: inherit;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

/* Estilos para el modal de detalles */
#modal-detalle-paciente .modal-body {
    padding: 1.5rem;
}

#modal-detalle-paciente .card {
    margin-bottom: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: none;
}

#modal-detalle-paciente .card-header {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
}

#modal-detalle-paciente .card-body {
    padding: 1rem;
}

#modal-detalle-paciente dl {
    margin-bottom: 0;
}

#modal-detalle-paciente dt {
    font-weight: 500;
    color: var(--color-gray);
    font-size: 0.85rem;
}

#modal-detalle-paciente dd {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

#modal-detalle-paciente .badge-triage {
    font-size: 0.9rem;
    padding: 0.35em 0.65em;
}

/* Estilos para el modal de detalles */
.gov-modal-header {
    background-color: var(--color-gob-primary);
    border-bottom: none;
    padding: 1.25rem;
}

/* Header mejorado */
.gov-top-bar {
    background-color: var(--color-gob-primary);
    border-bottom: 2px solid var(--color-gob-primary-dark);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Sidebar mejorado */
.gov-sidebar {
    background: linear-gradient(180deg, var(--color-gob-primary) 0%, var(--color-gob-primary-dark) 100%);
}

.sidebar-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
}

.gov-leyenda-triage {
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.gov-leyenda-triage .badge-triage {
    /* compact square badges for legend */
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
}
.gov-leyenda-triage .badge-triage i {
    font-size: 0.9rem;
    line-height: 1;
}
.gov-leyenda-triage li > span.fw-bold {
    min-width: 0;
    flex: 0 0 auto; /* don't allow the label to shrink to one char */
    white-space: nowrap;
    overflow: visible;
}
.gov-leyenda-triage li > small {
    flex: 1 1 auto; /* allow description to take remaining space and wrap */
    display: block;
    white-space: normal;
    overflow-wrap: break-word;
    margin: 0;
}

/* Styling for the inline count badges inside legend items */
.gov-leyenda-triage .count-badge {
    background: rgba(255,255,255,0.95);
    color: var(--color-dark);
    font-weight: 700;
    padding: 0.18rem 0.4rem;
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    font-size: 0.8rem;
    min-width: 30px;
    text-align: center;
}

/* Separate counts container (compact, aligned) */
.gov-leyenda-counts {
    background-color: rgba(0,0,0,0.08);
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.06);
}

.gov-leyenda-counts .count-badge {
    background: rgba(255,255,255,0.98);
    color: var(--color-dark);
    font-weight: 800;
    padding: 0.18rem 0.4rem;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    font-size: 0.85rem;
    min-width: 34px;
    text-align: center;
}

/* Make sure counts list looks compact on small screens */
@media (max-width: 768px) {
    .gov-leyenda-counts ul li {
        gap: 0.5rem;
        align-items: center;
    }

    .gov-leyenda-counts .count-badge {
        min-width: 30px;
        font-size: 0.8rem;
        padding: 0.14rem 0.32rem;
    }
}

/* Allow legend items to wrap and make count badge move below label on narrow widths (tablets) */
.gov-leyenda-triage ul.list-unstyled li {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap; /* allow children to move to next line when space is tight */
    margin-bottom: 0.4rem;
    padding: 0.12rem 0;
}

/* Make sure the descriptive small text can wrap and take full width when needed */
.gov-leyenda-triage ul.list-unstyled li small {
    flex: 1 1 auto;
    min-width: 0;
}

@media (max-width: 768px) {
    .gov-leyenda-triage .badge-triage {
        /* slightly smaller on tablets */
        flex: 0 0 26px;
        width: 26px;
        height: 26px;
        font-size: 0.7rem;
    }

    /* Put the count badge on its own line and align it to the right */
    .gov-leyenda-triage .count-badge {
        flex: 0 0 100%; /* full width row */
        margin-top: 6px;
        margin-left: 0;
        justify-self: end;
        text-align: right;
        align-self: flex-end;
        min-width: 0;
        font-size: 0.75rem;
        padding: 0.12rem 0.28rem;
    }

    /* Ensure the small description sits under the label if necessary */
    .gov-leyenda-triage ul.list-unstyled li > .fw-bold {
        flex: 0 0 auto;
    }
}

/* Footer mejorado */
.gov-footer {
    background-color: var(--color-gob-primary-dark);
    border-top: 2px solid var(--color-gob-primary);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

/* Efectos hover para elementos interactivos */
.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.15) !important;
    transform: translateX(3px);
    transition: all 0.2s ease;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .gov-sidebar {
        position: fixed;
        z-index: 1000;
        height: 100vh;
        transition: all 0.3s;
    }
    
    .gov-top-bar {
        position: sticky;
        top: 0;
        z-index: 1020;
    }
    
    .gov-footer {
        position: sticky;
        bottom: 0;
        z-index: 1010;
    }
}

/* Badge de notificaciones */
.badge-notification {
    font-size: 0.6rem;
    padding: 0.2em 0.4em;
    top: -5px;
    right: -5px;
}

/* Texto con opacidad */
.text-white-80 {
    opacity: 0.8;
}

/* Transiciones suaves */
.nav-item, .dropdown-item {
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background-color: var(--color-gob-primary-light);
    color: white;
}

.triage-level-badge-lg {
    /* Forzar tamaño fijo y evitar que el contenedor flex lo deforme */
    width: 60px;
    height: 60px;
    min-width: 60px;
    min-height: 60px;
    box-sizing: border-box;
    flex: 0 0 auto;
    font-size: 1.5rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    border-radius: 50% !important;
    color: white;
    /* Mantener estilo similar al badge grande: borde y sombra */
    border: 4px solid white;
    box-shadow: 0 4px 8px rgba(0,0,0,0.08);
    vertical-align: middle;
    overflow: hidden;
}

.gov-detail-card {
    border: 1px solid var(--color-gray-light);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.gov-detail-card-header {
    background-color: var(--color-gob-primary-light);
    color: white;
    padding: 0.75rem 1rem;
    margin: 0;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
}

.gov-detail-card-body {
    padding: 1rem;
    background-color: white;
}

.gov-detail-card-body dt {
    font-weight: 500;
    color: var(--color-gray);
    font-size: 0.85rem;
}

.gov-detail-card-body dd {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

#modal-detalle-paciente .modal-content {
    border: none;
    border-radius: 10px;
    overflow: hidden;
}

#modal-detalle-paciente .modal-body {
    padding: 0;
}

#modal-detalle-paciente .modal-footer {
    border-top: 1px solid var(--color-gray-light);
    padding: 0.75rem 1.25rem;
}

/* Estilos para el modal de confirmación de eliminación */
#modal-confirmar-eliminar .modal-content {
    border: none;
    border-radius: 10px;
    overflow: hidden;
}

#modal-confirmar-eliminar .modal-header {
    background-color: var(--color-gob-primary);
    border-bottom: none;
    padding: 1.25rem;
}

#modal-confirmar-eliminar .modal-body {
    padding: 1.5rem;
}

#modal-confirmar-eliminar .modal-footer {
    border-top: 1px solid var(--color-gray-light);
    padding: 0.75rem 1.25rem;
}

#modal-confirmar-eliminar .bi-trash-fill {
    font-size: 3rem;
}

#modal-confirmar-eliminar .alert-warning {
    background-color: rgba(239, 108, 0, 0.1);
    border-color: rgba(239, 108, 0, 0.2);
    color: var(--color-dark);
}

/* Estilos para el modal de ayuda */
#modal-ayuda .modal-content {
    border: none;
    border-radius: 10px;
    overflow: hidden;
}

#modal-ayuda .modal-header {
    background-color: var(--color-gob-primary);
    border-bottom: none;
    padding: 1.25rem;
}

#modal-ayuda .modal-body {
    padding: 1.5rem;
}

#modal-ayuda .accordion-button {
    font-weight: 500;
    background-color: var(--color-gray-lighter);
    border-radius: 5px !important;
    margin-bottom: 0.5rem;
}

#modal-ayuda .accordion-button:not(.collapsed) {
    background-color: var(--color-gob-primary-light);
    color: white;
}

#modal-ayuda .accordion-body {
    padding: 1rem;
    background-color: white;
    border-radius: 0 0 5px 5px;
}

#modal-ayuda .modal-footer {
    border-top: 1px solid var(--color-gray-light);
    padding: 0.75rem 1.25rem;
}

/* Estilo para el contenedor de comorbilidades */
.comorbilidades-container {
    max-height: 300px;
    /* Misma altura máxima que el overlay */
    overflow-y: auto;
    /* Scroll vertical si es necesario */
    padding: 0.5rem;
}

/* Asegurar que el overlay no se desborde en pantallas pequeñas */
@media (max-width: 576px) {
    .comorbilidades-overlay {
        width: calc(100vw - 30px);
        /* Ancho completo del viewport menos padding */
        left: 15px;
    }
}

.comorbilidades-container .form-check {
    padding: 0.5rem 2rem;
    margin: 0;
    border-bottom: 1px solid #eee;
}

.comorbilidades-container .form-check:hover {
    background-color: #e9ecef;
}

.comorbilidades-container .form-check-input {
    margin-top: 0.3em;
}

.comorbilidades-container .form-check-label {
    cursor: pointer;
    width: 100%;
    padding-left: 0.5rem;
}

.comorbilidades-overlay {
    position: absolute;
    z-index: 1050;
    background-color: white;
    border: 1px solid var(--color-gray-light);
    border-radius: 15px;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    width: 46%;
    /* Ancho relativo al contenedor padre */
    max-height: 300px;
    /* Altura máxima */
    overflow: hidden;
    /* Para bordes redondeados */
}

/* Estilo para el placeholder cuando no hay selecciones */
#comorb-placeholder {
    color: #595c5f;
}

/* Estilo para el placeholder */
.comorb-placeholder {
    color: #595c5f;
    display: block;
    width: 100%;
}

.selected-comorb-container .badge {
    margin: 1px;
}

.selected-comorb-container:has(.badge) .comorb-placeholder {
    display: none;
}

/* Ocultar placeholder cuando hay contenido (badges) */
.selected-comorb-container:not(:empty) .comorb-placeholder {
    display: none;
}

/* Asegurar que el contenedor mantenga su altura mínima */
.selected-comorb-container {
    position: relative;
    background-color: white !important;
}

/* Posicionar el placeholder en el centro vertical */
.selected-comorb-container .comorb-placeholder {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

/* Mostrar placeholder solo cuando no hay selecciones */
.selected-comorb-container:not(:empty) #comorb-placeholder {
    display: none;
}

/* Estilo para el contenedor de seleccionados */
/* Mejorar la apariencia del contenedor clickeable */
.selected-comorb-container {
    background-color: var(--color-gray-lighter);
    transition: all 0.2s;
}

.selected-comorb-container:hover {
    background-color: var(--color-gray-light);
    border-color: var(--color-gob-primary-light) !important;
}

/* Estilo para los tags de comorbilidades seleccionadas */
.selected-comorb-container .badge {
    font-size: 0.875rem;
    padding: 0.35em 0.65em;
}

/* Estilo para el botón de cerrar en los tags */
.selected-comorb-container .btn-close {
    font-size: 0.6rem;
    padding: 0.25em;
}

/* Mejora el hover en los checkboxes */
.comorbilidades-container .form-check:hover {
    background-color: rgba(13, 110, 253, 0.1);
}

/* Estilo para checkboxes seleccionados */
.comorbilidades-container .form-check-input:checked~.form-check-label {
    color: var(--color-gob-primary);
    font-weight: 500;
}

/* Contenedor principal */
.has-validation {
    position: relative;
}

/* Dropdown con espaciado adecuado */
#motivo-dropdown {
    position: absolute;
    z-index: 1000;
    width: calc(100% - 42px);
    /* Ajuste para el botón CIE-10 */
    margin-top: 0.25rem;
    /* Espacio entre input y dropdown */
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
    border-radius: 0.5rem;
    border: 1px solid #dee2e6;
    overflow: hidden;
    /* Para bordes redondeados */
}

/* Lista de opciones */
#motivo-dropdown .list-group {
    max-height: 250px;
    overflow-y: auto;
}

/* Items individuales - ¡Aquí está el ajuste clave! */
#motivo-dropdown .list-group-item {
    padding: 0.75rem 1.25rem;
    /* Más espaciado vertical */
    border: none;
    border-bottom: 1px solid #f1f1f1;
    /* Separador sutil */
    transition: all 0.2s;
    font-size: 0.95rem;
}

/* Efecto hover */
#motivo-dropdown .list-group-item:hover {
    background-color: rgba(13, 110, 253, 0.1);
}

/* Último item sin borde */
#motivo-dropdown .list-group-item:last-child {
    border-bottom: none;
}

/* Scrollbar personalizado (opcional) */
#motivo-dropdown .list-group::-webkit-scrollbar {
    width: 8px;
}

#motivo-dropdown .list-group::-webkit-scrollbar-thumb {
    background-color: #adb5bd;
    border-radius: 4px;
}

/* Asegura que el dropdown no exceda el ancho del contenedor padre */
.dropdown-menu {
    max-width: 100%;
}

/* ===== ESTILOS MEJORADOS PARA DROPDOWN DE USUARIO ===== */
.user-dropdown-menu {
    min-width: 320px;
    max-width: 360px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
}

/* Header del perfil con gradiente sutil */
.user-dropdown-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 2px solid #dee2e6;
}

/* Contenedor del avatar */
.user-avatar-container {
    position: relative;
    flex-shrink: 0;
}

/* Indicador de estado en línea */
.user-status-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background-color: #28a745;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.3);
}

/* Nombre del usuario */
#dropdown-user-name {
    font-size: 1rem;
    font-weight: 700;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* Email del usuario */
#dropdown-user-email {
    font-size: 0.8rem;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    line-height: 1.3;
}

/* Badge de rol */
.user-role-badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

/* Sección de estadísticas */
.user-stats-section {
    background-color: #fff;
    border-bottom: 1px solid #e9ecef;
}

.user-stat-card {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 0.75rem 0.5rem;
    transition: all 0.2s;
}

.user-stat-card:hover {
    background-color: #e9ecef;
    transform: translateY(-2px);
}

.user-stat-card i {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.user-stat-card small {
    font-size: 0.7rem;
    line-height: 1.2;
}

.user-stat-card strong {
    font-size: 0.85rem;
    color: #495057;
}

/* Items del menú */
.user-dropdown-menu .dropdown-item {
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.user-dropdown-menu .dropdown-item:hover {
    background-color: #f8f9fa;
    padding-left: 1.5rem;
}

.user-dropdown-menu .dropdown-item i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.user-dropdown-menu .dropdown-item span {
    flex: 1;
}

/* Botón de cerrar sesión destacado */
#logout-btn {
    font-weight: 600;
}

#logout-btn:hover {
    background-color: #fff5f5 !important;
}

/* Divisores sutiles */
.user-dropdown-menu .dropdown-divider {
    margin: 0;
    opacity: 0.5;
}

/* Animación de entrada */
@keyframes dropdownSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-dropdown-menu.show {
    animation: dropdownSlideIn 0.2s ease-out;
}

/* Responsive */
@media (max-width: 576px) {
    .user-dropdown-menu {
        min-width: 280px;
        max-width: 95vw;
    }
    
    #dropdown-user-name,
    #dropdown-user-email {
        max-width: 180px;
    }
}

/* Responsive */
@media (max-width: 768px) {
    #modal-detalle-paciente .col-md-6 {
        border-right: none !important;
        border-bottom: 1px solid var(--color-gray-light);
    }

    .triage-level-badge-lg {
        width: 50px;
        height: 50px;
        aspect-ratio: 1 / 1;
        box-sizing: border-box;
        font-size: 1.25rem;
        padding: 0;
        line-height: 1;
        border: 3px solid white;
        vertical-align: middle;
        overflow: hidden;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: static;
        padding: 1rem 0;
    }

    main {
        padding: 1rem;
    }

    .card-body {
        padding: 1rem;
    }
}

/* Utilidades */
.text-white-80 {
    opacity: 0.8;
}

.cursor-pointer {
    cursor: pointer;
}

/* Paginación */
.pagination .page-link {
    color: #0D47A1;
    border: 1px solid #0D47A1;
}

.pagination .page-item.active .page-link {
    background-color: #0D47A1;
    border-color: #0D47A1;
    color: white;
}

/* Color de fondo al hacer hover en los items del dropdown */
.dropdown-menu .dropdown-item:hover {
    background-color: var(--color-gob-primary); /* Azul claro del gobierno */
    color: white; /* Color azul para el texto */
}

/* Estilo específico para el botón de cerrar sesión */
#logout-btn:hover {
    background-color: var(--color-c1) !important; /* Rojo claro para destacar */
    color: white !important;
}

/* Estilo para el header del dropdown (perfil) */
#user-profile-section:hover {
    background-color: transparent !important; /* Sin cambio de fondo */
}

/* Estilos para el modal de perfil */
#modalPerfil .modal-content {
    border-radius: 10px;
}

#perfil-avatar {
    border: 3px solid #e9ecef;
    object-fit: cover;
}

#formPerfil label {
    font-weight: 500;
    margin-bottom: 0.3rem;
}

#formPerfil .form-control, #formPerfil .form-select {
    border-radius: 5px;
    padding: 0.5rem 0.75rem;
}

#btn-guardar-perfil {
    padding: 0.5rem 1.5rem;
    border-radius: 5px;
    font-weight: 500;
}

/* Estilos para el logo en el sidebar */
#sidebar-logo {
    transition: all 0.3s ease;
    max-width: 80%;
    margin: 0 auto;
}

#sidebar-logo:hover {
    transform: scale(1.05);
}

/* Estilos para la previsualización del logo */
#logo-preview-container {
    padding: 1rem;
    background-color: var(--color-gray-lighter);
    border-radius: 8px;
    border: 1px dashed var(--color-gray-light);
}

#logo-preview {
    max-height: 80px;
    margin: 0 auto;
    display: block;
}

/* Estilos para el botón de eliminar logo */
#btn-eliminar-logo {
    width: 100%;
}

/* Hacer que los encabezados de los modales de Login y Registro coincidan con el estilo
   de configuración (fondo azul del gobierno) */
#modalLogin .modal-header,
#modalRegistro .modal-header {
    background-color: var(--color-gob-primary);
    color: white;
    border-bottom: none;
    padding: 1.25rem;
}

/* ============================================
   ESTILOS MEJORADOS PARA MODAL DE TRIAGE
   ============================================ */

.triage-actions-section {
    padding: 1.5rem;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.triage-actions-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #212529;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action-card {
    background: white;
    border: 1px solid #e3f2fd;
    border-left: 4px solid #1976d2;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.action-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-left-color: #1565c0;
}

.action-card.c1 {
    border-left-color: #c62828;
    background-color: #ffebee;
}

.action-card.c2 {
    border-left-color: #ef6c00;
    background-color: #fff3e0;
}

.action-card.c3 {
    border-left-color: #f9a825;
    background-color: #fffde7;
}

.action-card.c4 {
    border-left-color: #2e7d32;
    background-color: #f1f8e9;
}

.action-card.c5 {
    border-left-color: #1565c0;
    background-color: #e3f2fd;
}

.action-icon {
    font-size: 1.5rem;
    margin-right: 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    background-color: rgba(25, 118, 210, 0.1);
    border-radius: 50%;
}

.action-card.c1 .action-icon {
    background-color: rgba(198, 40, 40, 0.1);
    color: #c62828;
}

.action-card.c2 .action-icon {
    background-color: rgba(239, 108, 0, 0.1);
    color: #ef6c00;
}

.action-card.c3 .action-icon {
    background-color: rgba(249, 168, 37, 0.1);
    color: #f9a825;
}

.action-card.c4 .action-icon {
    background-color: rgba(46, 125, 50, 0.1);
    color: #2e7d32;
}

.action-card.c5 .action-icon {
    background-color: rgba(21, 101, 192, 0.1);
    color: #1565c0;
}

.action-header {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: #212529;
}

.action-content {
    margin-left: 3.5rem;
    padding-left: 0;
}

.action-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0 0;
}

.action-list li {
    padding: 0.4rem 0;
    padding-left: 1.5rem;
    position: relative;
    font-size: 0.95rem;
    line-height: 1.4;
}

.action-list li:before {
    content: "✓";
    position: absolute;
    left: 0;
    font-weight: bold;
    color: #1976d2;
}

.action-card.c1 .action-list li:before {
    color: #c62828;
}

.action-card.c2 .action-list li:before {
    color: #ef6c00;
}

.action-card.c3 .action-list li:before {
    color: #f9a825;
}

.action-card.c4 .action-list li:before {
    color: #2e7d32;
}

.action-card.c5 .action-list li:before {
    color: #1565c0;
}

/* Sección de Observaciones Clínicas */
.clinical-observations {
    padding: 1rem;
    background-color: #f5f5f5;
    border-radius: 6px;
    margin-top: 1rem;
}

.observation-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
}

.observation-item:last-child {
    margin-bottom: 0;
}

.observation-icon {
    margin-right: 0.75rem;
    margin-top: 0.1rem;
    font-size: 1.2rem;
    min-width: 1.5rem;
    text-align: center;
}

.observation-text {
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Tiempo de espera mejorado */
.wait-time-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 1rem;
}

.wait-time-badge.c1 {
    background-color: #c62828;
    color: white;
}

.wait-time-badge.c2 {
    background-color: #ef6c00;
    color: white;
}

.wait-time-badge.c3 {
    background-color: #f9a825;
    color: white;
}

.wait-time-badge.c4 {
    background-color: #2e7d32;
    color: white;
}

.wait-time-badge.c5 {
    background-color: #1565c0;
    color: white;
}

/* Sección de contexto médico */
.medical-context {
    padding: 1.5rem;
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border-radius: 8px;
    margin-top: 1rem;
}

.medical-context h6 {
    color: #1565c0;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.medical-context p {
    font-size: 0.95rem;
    color: #424242;
    margin: 0;
    line-height: 1.5;
}

/* Alerta de procedimientos urgentes */
.urgent-procedures-alert {
    padding: 1rem;
    margin-top: 1rem;
    border-left: 4px solid #c62828;
    background-color: #ffebee;
    border-radius: 4px;
}

.urgent-procedures-alert h6 {
    color: #c62828;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
}

.urgent-procedures-alert ul {
    padding-left: 1.5rem;
    margin: 0;
}

.urgent-procedures-alert li {
    font-size: 0.9rem;
    color: #c62828;
    margin-bottom: 0.3rem;
}

/* Alertas por nivel de TRIAGE */
.alert-c1 {
    background-color: #ffcdd2;
    border-color: #c62828;
    color: #b71c1c;
}

.alert-c2 {
    background-color: #ffe0b2;
    border-color: #ef6c00;
    color: #e65100;
}

.alert-c3 {
    background-color: #fff9c4;
    border-color: #f9a825;
    color: #f57f17;
}

.alert-c4 {
    background-color: #c8e6c9;
    border-color: #2e7d32;
    color: #1b5e20;
}

.alert-c5 {
    background-color: #bbdefb;
    border-color: #1565c0;
    color: #0d47a1;
}