/* ======================== ESTILOS DEL WIDGET DE NOTIFICACIONES AUTOMATICAS ======================== */

/* Contenedor principal del widget de notificaciones (en el header) */
.notificaciones-widget-container {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    z-index: 997;
}

/* Botón de notificaciones en el header (a la par del botón de búsqueda) */
.notificaciones-floating-button {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
}

/* Estilo coherente con btn-tertiary btn-circular-icon del header */
.notificaciones-floating-button:hover {
    background: var(--Gray-10, #F2F2F2);
    border-color: transparent;
}

.notificaciones-floating-button:active {
    transform: scale(0.98);
}

.notificaciones-floating-button svg {
    width: 24px;
    height: 24px;
    stroke: var(--Primary-50);
    stroke-width: 2;
    fill: none;
}

/* Badge de conteo de notificaciones (número en rojo) */
.notificaciones-floating-button {
    position: relative;
}

.notificaciones-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background-color: #DC2626;
    color: #FFFFFF;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}


/* Panel flotante de notificaciones (AC: borde 2px Primary-50, padding 16px) */
.notificaciones-widget {
    position: fixed;
    top: 0;
    right: 0;
    bottom: auto;
    left: auto;
    z-index: 1002;
    background-color: #FFFFFF;
    border-radius: 24px;
    border: 2px solid var(--Primary-50, #086378);
    width: 415px;
    max-width: calc(100vw - 90px);
    max-width: min(415px, calc(100vw - 90px));
    /* AC: al desplegar mostrar 1ª tarjeta completa + ~1/3 de la 2ª (altura limitada, no todo el viewport) */
    max-height: min(580px, 58vh);
    min-height: 240px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    overflow-x: hidden;
    opacity: 0;
    visibility: hidden;
    display: flex;
    flex-direction: column;
    padding: 16px;
    padding-bottom: 16px;
    gap: 0;
    box-sizing: border-box;
}


.notificaciones-widget.show {
    opacity: 1;
    visibility: visible;
}

/* Header (AC: título "Notificaciones" Title 2 Énfasis, Gray/85; botón cerrar icono x-close tamaño S) */
.notificaciones-widget-header {
    background: transparent;
    color: var(--Gray-85, #1B1D1F);
    padding: 0 0 12px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    flex-shrink: 0;
}

.notificaciones-widget-title {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.notificaciones-widget-title h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--Gray-85, #1B1D1F);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notificaciones-widget-controls {
    display: flex;
    gap: 8px;
}

.notificaciones-widget-btn {
    background: var(--Primary-50, #086378);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    transition: all 0.2s ease;
}

.notificaciones-widget-btn:hover {
    background: var(--Primary-100, #064350);
}

.notificaciones-widget-btn:active {
    transform: scale(0.98);
}

/* AC: icono x-close tamaño S */
.notificaciones-widget-btn svg {
    width: 14px;
    height: 14px;
    stroke: #FFFFFF;
    stroke-width: 2;
    fill: none;
}

/* Body: scroll vertical único para toda la lista (AC) */
.notificaciones-widget-body {
    flex: 1;
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 120px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    /* Altura para mostrar ~1 tarjeta + 1/3 de la siguiente */
    max-height: min(420px, 48vh);
    box-sizing: border-box;
}

/* Caja resumen "X notificaciones sin leer" (Figma: fondo azul claro, borde redondeado) */
.notificaciones-resumen {
    background: #E8F6FA;
    border: 1px solid rgba(8, 99, 120, 0.2);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.notificaciones-resumen-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    color: var(--Primary-50, #086378);
}

.notificaciones-resumen svg {
    width: 24px;
    height: 24px;
    stroke: var(--Primary-50, #086378);
    fill: var(--Primary-50, #086378);
}

.notificaciones-resumen-texto {
    font-size: 14px;
    color: var(--Gray-70, #5D5D5D);
    margin: 0;
}

/* Contenedor de la lista: crece con el contenido; el scroll es solo en .notificaciones-widget-body */
.notificaciones-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: visible;
    box-sizing: border-box;
}

/* Tarjeta de notificación (AC: padding 16px, border-radius 24px, responsive, max-width 415px) */
.notificacion-item {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    align-items: stretch;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-shrink: 0;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: visible;
    background: #FFFFFF;
    border: 2px solid var(--Primary-50, #086378);
    border-radius: 24px;
}

/* Línea separadora entre tarjetas (solo entre ítems, no antes de la primera) */
.notificacion-hr {
    margin: 0 0 4px 0;
    border: 0;
    border-top: 1px solid var(--Gray-30, #E7EBED);
    width: 100%;
}

/* Categoría (título en negrita) */
.notificacion-categoria {
    font-weight: bold;
    font-size: 14px;
    color: var(--Gray-70, #6B7280);
    text-transform: uppercase;
    margin-bottom: 4px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Imagen de notificación (AC: relación de aspecto 500x362, adaptada al ancho) */
.notificacion-imagen {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 500 / 362;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
}

.notificacion-imagen img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

/* Contenedor de título, descripción y botón */
.notificacion-contenido-texto {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
    overflow: visible;
    box-sizing: border-box;
}

/* Título principal */
.notificacion-titulo {
    margin-bottom: 0;
    width: 100%;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    box-sizing: border-box;
}

.notificacion-titulo h4 {
    font-size: 18px;
    font-weight: bold;
    color: var(--Gray-90, #1B1D1F);
    margin: 0;
    line-height: 1.3;
    overflow-wrap: break-word;
    word-wrap: break-word;
    max-width: 100%;
}

/* Descripción */
.notificacion-descripcion {
    margin-bottom: 0;
    width: 100%;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    box-sizing: border-box;
}

.notificacion-descripcion p {
    font-size: 14px;
    color: var(--Gray-70, #6B7280);
    margin: 0;
    line-height: 1.5;
    overflow-wrap: break-word;
    word-wrap: break-word;
    max-width: 100%;
}

/* Botón de acción: usa btn-secondary (transición/hover como en Figma) */
.notificacion-boton {
    margin-top: 0;
    margin-bottom: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* CTA tipo Figma: fondo blanco, texto y borde Primary-50, pill-shaped */
.notificacion-boton .btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 40px;
    padding: 10px 20px;
    text-align: center;
    text-decoration: none;
    background: #FFFFFF !important;
    color: var(--Primary-50, #086378) !important;
    border: 2px solid var(--Primary-50, #086378) !important;
    border-radius: 999px;
}

.notificacion-boton .btn-secondary:hover {
    background: var(--Primary-2, #E4EDEF) !important;
    color: var(--Primary-100, #064350) !important;
    border-color: var(--Primary-50, #086378) !important;
}

/* Paginador */
.notificacion-paginador {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 0;
    margin-top: auto;
    border-top: 1px solid var(--Gray-30, #E7EBED);
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.paginador-btn {
    background: var(--Gray-00, #FCFCFC);
    border: 1px solid var(--Gray-55, #ACB0B2);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
}

.paginador-btn:hover {
    background: var(--Primary-100, #064350);
    border-color: var(--Primary-100, #064350);
    transform: scale(1.1);
}

.paginador-btn:hover svg {
    stroke: var(--Gray-00, #FCFCFC);
}

.paginador-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.paginador-btn svg {
    width: 16px;
    height: 16px;
    stroke: var(--Primary-100, #064350);
    stroke-width: 2;
    fill: none;
}

.paginador-indicador {
    font-size: 14px;
    color: var(--Gray-70, #6B7280);
    font-weight: 500;
    min-width: 60px;
    text-align: center;
}

/* Estado vacío */
.notificaciones-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--Gray-70, #6B7280);
}

.notificaciones-empty p {
    margin: 0;
    font-size: 14px;
}

/* ======================== RESPONSIVE ======================== */

/* Responsive para dispositivos móviles (768px y menos) - ancho del panel; posición la controla JS */
/* AC: en móvil margen mínimo 16px entre panel y viewport */
@media (max-width: 768px) {
    .notificaciones-widget {
        width: auto;
        max-width: calc(100vw - 32px);
        max-height: min(520px, 56vh);
        min-width: 0;
        min-height: 280px;
        border-radius: 20px;
    }
    
    .notificacion-imagen {
        aspect-ratio: 500 / 362;
    }
    
    .notificacion-imagen img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    .notificaciones-widget-body {
        max-height: min(360px, 44vh);
    }
    
    .notificaciones-floating-button {
        width: 40px;
        height: 40px;
    }
    
    .notificaciones-floating-button svg {
        width: 24px;
        height: 24px;
    }

    .notificaciones-widget-header {
        padding: 0 0 12px 0;
    }

    .notificaciones-widget-title h3 {
        font-size: 16px;
    }

    .notificaciones-widget-btn {
        width: 28px;
        height: 28px;
    }

    .notificaciones-widget-btn svg {
        width: 14px;
        height: 14px;
    }
}

/* Responsive para móviles pequeños (480px y menos) */
@media (max-width: 480px) {
    .notificaciones-widget {
        width: auto;
        max-width: calc(100vw - 32px);
        max-height: min(500px, 54vh);
        min-width: 0;
        min-height: 260px;
        border-radius: 16px;
    }
    
    .notificaciones-floating-button {
        width: 36px;
        height: 36px;
    }
    
    .notificaciones-floating-button svg {
        width: 20px;
        height: 20px;
    }

    .notificaciones-widget-header {
        padding: 0 0 10px 0;
    }

    .notificaciones-widget-title h3 {
        font-size: 14px;
    }

    .notificaciones-widget-btn {
        width: 24px;
        height: 24px;
    }

    .notificaciones-widget-btn svg {
        width: 12px;
        height: 12px;
    }
}

/* Responsive para móviles muy pequeños (360px y menos) */
@media (max-width: 360px) {
    .notificaciones-widget {
        width: auto;
        max-width: calc(100vw - 32px);
        max-height: min(480px, 52vh);
        min-width: 0;
        min-height: 240px;
        border-radius: 12px;
    }
    
    .notificacion-imagen {
        aspect-ratio: 500 / 362;
    }
    
    .notificaciones-widget-body {
        max-height: min(320px, 42vh);
    }
    
    .notificaciones-floating-button {
        width: 32px;
        height: 32px;
    }
    
    .notificaciones-floating-button svg {
        width: 18px;
        height: 18px;
    }

    .notificaciones-widget-header {
        padding: 0 0 8px 0;
    }

    .notificaciones-widget-title h3 {
        font-size: 13px;
    }

    .notificaciones-widget-btn {
        width: 22px;
        height: 22px;
    }

    .notificaciones-widget-btn svg {
        width: 10px;
        height: 10px;
    }
}

/* Manejo de orientación landscape en móviles */
@media (max-width: 768px) and (orientation: landscape) {
    .notificaciones-widget {
        max-height: min(400px, 70vh);
    }

    .notificaciones-widget-header {
        padding: 0 0 8px 0;
        font-size: 14px;
    }

    .notificaciones-widget-body {
        max-height: min(280px, 50vh);
    }
}
