/* ==========================================================================
   SISTEMA DE MODALES PREMIUM ISOMÓRFICOS (ESTÁNDAR CORMEN 4TH ED.)
   ========================================================================== */

/* Contenedor del desenfoque de cristal (Backdrop) */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(18, 27, 37, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 9999; /* Por encima de cualquier navbar dinámico */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 24px;
}

.custom-modal-overlay.is-active {
    opacity: 1;
    pointer-events: auto;
}

/* Caja Contenedora con Isomorfismo Dimensional Estricto */
.custom-modal-box.modal-lg-custom {
    background: #ffffff;
    width: 100%;
    max-width: 750px;
    
    /* ALTURA FIJA RIGUROSA: No más saltos de tamaño entre modales */
    height: 600px; 
    
    border-radius: 16px;
    position: relative;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column; /* Divide el Header fijo del Body scrolleable */
    overflow: hidden; 
    transform: scale(0.95) translateY(15px);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.custom-modal-overlay.is-active .custom-modal-box {
    transform: scale(1) translateY(0);
}

/* Cabecera Fija del Modal (Fondo Azul Premium Unificado) */
.modal-premium-header {
    background-color: #121b25;
    padding: 28px 32px;
    border-bottom: 3px solid #c5a059;
    color: #ffffff;
    flex-shrink: 0; /* Impide que el header se deforme o encoja */
}

.modal-premium-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 4px 0;
}

.modal-premium-subtitle {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    color: #c5a059; /* Dorado corporativo */
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Cuerpo con Control Absoluto de Scroll y Bloqueo de Chaining */
.modal-premium-body {
    padding: 32px;
    overflow-y: auto;
    flex-grow: 1; /* Absorbe matemáticamente el espacio restante de los 600px */
    
    /* DETERMINISMO DE SCROLL: Rompe la propagación del scroll hacia el body de la página */
    overscroll-behavior: contain; 
}

/* Botón X de Cierre Estilizado */
.close-icon-btn {
    position: absolute;
    top: 24px;
    right: 28px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    z-index: 1010;
    transition: color 0.2s ease, transform 0.2s ease;
}

.close-icon-btn:hover {
    color: #c5a059;
    transform: scale(1.1);
}

/* Cajas Internas de Servicios */
.servicio-item-box {
    padding: 18px;
    background-color: #f8f9fa;
    border-left: 4px solid #121b25;
    border-radius: 4px 12px 12px 4px;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.servicio-item-box:hover {
    border-left-color: #c5a059;
    background-color: #f1f3f5;
}


/* Elimina la flecha del dropdown de la tuerca */
.dropdown-toggle.no-arrow::after {
    display: none !important;
}

/* Transición suave para los iconos de control derecho */
#btn-notificaciones-nav:hover i,
#dropdownConfigUsuario:hover i {
    color: #121b25 !important; /* Cambia al azul corporativo al pasar el mouse */
    transform: scale(1.05);
    transition: all 0.2s ease;
}

/* ==========================================================================
   HOMOLOGACIÓN TIPOGRÁFICA DEL NAVBAR PRIVADO
   ========================================================================== */
#navbarNavBackend .nav-link {
    font-family: 'Montserrat', sans-serif !important;
    color: #666666 !important; 
    font-size: 0.95rem !important;
    font-weight: 400 !important; /* Mismo grosor estilizado y fino */
    text-align: center;
    display: inline-block;
    min-width: 95px;
    padding: 8px 0;
    margin: 0 5px;
    transition: color 0.2s ease, font-weight 0.2s ease;
}

/* Efecto Hover idéntico: Pasa a Azul Corporativo en grosor 600 */
#navbarNavBackend .nav-link:hover,
#navbarNavBackend .nav-link.active {
    color: #121b25 !important; 
    font-weight: 600 !important;
}

#navbarNavBackend .badge-novedades-nav {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: 6px;
    border-radius: 50%;
    background-color: #dc3545;
    vertical-align: 1px;
    box-shadow: 0 0 0 2px #ffffff;
}

#navbarNavBackend .badge-novedades-nav[hidden] {
    display: none !important;
}

/* ==========================================================================
   CAMPANA DE NOTIFICACIONES DE AGENDA (DETALLE COMPLETO)
   ========================================================================== */
.lista-notificaciones-dropdown {
    min-width: min(420px, calc(100vw - 24px));
    max-width: min(440px, calc(100vw - 24px));
    max-height: min(72vh, 640px);
    overflow-y: auto;
    border-radius: 12px;
}

@media (max-width: 768px) {
    .dropdown:has(#dropdownNotificaciones) .dropdown-menu-end,
    #lista-notificaciones-dropdown,
    #panelNotificacionesMenu {
        right: 0 !important;
        left: auto !important;
        max-width: 90vw !important;
        min-width: min(320px, 90vw) !important;
        transform: translate3d(-10px, 40px, 0px) !important;
        overflow-x: hidden;
    }
}

.notif-item {
    list-style: none;
    padding: 0 4px 8px;
}

.notif-card {
    background: #f8f9fb;
    border: 1px solid rgba(18, 27, 37, 0.08);
    border-left: 4px solid #121b25;
    border-radius: 10px;
    padding: 12px;
}

.notif-card--nueva { border-left-color: #198754; }
.notif-card--edicion { border-left-color: #c5a059; }
.notif-card--baja { border-left-color: #dc3545; }
.notif-card--traspaso { border-left-color: #0d6efd; }

.notif-header {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 10px;
}

.notif-icono {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: #121b25;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    flex-shrink: 0;
}

.notif-card--nueva .notif-icono { background: #198754; }
.notif-card--edicion .notif-icono { background: #c5a059; }
.notif-card--baja .notif-icono { background: #dc3545; }
.notif-card--traspaso .notif-icono { background: #0d6efd; }

.notif-titulo {
    font-size: 0.82rem;
    font-weight: 700;
    color: #121b25;
    line-height: 1.25;
}

.notif-subtitulo {
    font-size: 0.72rem;
    color: #5c6570;
    margin-top: 2px;
    line-height: 1.4;
}

.notif-bloque {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #fff;
    border-radius: 8px;
    padding: 8px 10px;
}

.notif-fila {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 8px;
    align-items: start;
    font-size: 0.73rem;
}

.notif-label {
    color: #8a93a0;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 0.62rem;
    padding-top: 2px;
}

.notif-valor {
    color: #121b25;
    word-break: break-word;
}

.notif-fila-cambio .notif-valor {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.notif-antes {
    color: #8a93a0;
    text-decoration: line-through;
}

.notif-despues {
    color: #8a6a1f;
    font-weight: 700;
    background: #f8efd8;
    border-radius: 4px;
    padding: 1px 6px;
}

.notif-flecha {
    font-size: 0.58rem;
    color: #c5a059;
}

.notif-hint {
    font-size: 0.7rem;
    color: #5c6570;
    margin: 8px 0 6px;
}

.notif-motivo {
    margin-top: 8px;
    background: #fff5f5;
    border-radius: 8px;
    padding: 8px 10px;
}

.notif-motivo-texto {
    font-size: 0.76rem;
    color: #121b25;
    margin-top: 4px;
}

.notif-acciones {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 10px;
}

.notif-acciones .btn {
    font-size: 0.7rem;
    padding: 0.22rem 0.55rem;
}

/* ==========================================================================
   INDICADOR DE RED — solo #indicador-red-navbar (navbar-rp)
   ========================================================================== */
#indicador-red-navbar {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

#indicador-red-navbar .indicador-red__btn {
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    padding: 0.28rem 0.65rem;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1;
    white-space: nowrap;
    box-shadow: none;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

#indicador-red-navbar .indicador-red__btn:focus {
    outline: none;
    box-shadow: none;
}

#indicador-red-navbar .indicador-red__btn:focus-visible {
    outline: 2px solid #c5a059;
    outline-offset: 2px;
}

#indicador-red-navbar .indicador-red__punto,
#indicador-red-navbar .indicador-red__icono-offline,
#indicador-red-navbar .indicador-red__icono-ok,
#indicador-red-navbar .indicador-red__texto {
    display: none;
}

#indicador-red-navbar.indicador-red--online .indicador-red__btn {
    padding: 6px;
    border-color: transparent;
    background: transparent;
    cursor: default;
}

#indicador-red-navbar.indicador-red--online .indicador-red__punto {
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #1f9d55;
    box-shadow: 0 0 0 3px rgba(31, 157, 85, 0.18);
}

#indicador-red-navbar.indicador-red--offline .indicador-red__btn {
    background: #fff4d6;
    color: #8a5b00;
    border-color: #e6c36a;
}

#indicador-red-navbar.indicador-red--offline .indicador-red__icono-offline,
#indicador-red-navbar.indicador-red--offline .indicador-red__texto {
    display: inline;
}

#indicador-red-navbar.indicador-red--restaurada .indicador-red__btn {
    background: #e8f6ee;
    color: #0f6b3c;
    border-color: #b7e0c6;
    cursor: default;
}

#indicador-red-navbar.indicador-red--restaurada .indicador-red__icono-ok,
#indicador-red-navbar.indicador-red--restaurada .indicador-red__texto {
    display: inline;
}

#indicador-red-navbar .indicador-red__tooltip {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 1080;
    width: min(280px, calc(100vw - 24px));
    margin: 0;
    padding: 0.7rem 0.8rem;
    border-radius: 10px;
    background: #121b25;
    color: #ffffff;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.45;
    text-align: left;
    white-space: normal;
    box-shadow: 0 10px 24px rgba(18, 27, 37, 0.18);
}

#indicador-red-navbar .indicador-red__tooltip[hidden] {
    display: none !important;
}