/* ==============================
   MODAL DE NOTIFICACIONES
   ============================== */

@keyframes modalEntrada {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes modalSalida {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(0.85); }
}

#notif-main-panel {
    animation: modalEntrada 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

#notif-main-panel.cerrando {
    animation: modalSalida 0.2s ease-in both;
}

/* ── Layout de dos paneles ─────────────────────────────────────────── */
#notif-panels-wrapper {
    display: flex;
    flex-direction: row;
    gap: 16px;
    align-items: stretch;
    max-height: 90vh;
    transition: all 0.3s ease;
}

/* Panel PDF: oculto por defecto */
#notif-pdf-panel {
    display: none;
    width: 540px;
    flex-shrink: 0;
    max-height: 90vh;
    background: #fff;
    border-radius: 20px;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

/* Cuando el PDF está visible: wrapper ocupa todo el ancho disponible */
#notif-panels-wrapper.pdf-visible {
    width: 95vw;
    max-width: 1580px;
}

/* Notif panel se estrecha en ancho (no en alto) cuando el PDF aparece */
#notif-panels-wrapper.pdf-visible #notif-main-panel {
    flex: 1;
    min-width: 0;
    width: auto !important;
    max-width: none !important;
}

/* Panel PDF visible */
#notif-panels-wrapper.pdf-visible #notif-pdf-panel {
    display: flex;
}

/* Header del panel PDF */
#notif-pdf-header {
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

#notifDetailTitle {
    font-size: 13px;
    font-weight: 700;
    color: #020031;
    margin: 0;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

#notifDetailFecha {
    font-size: 11px;
    color: #94a3b8;
    margin: 4px 0 0;
}

#notifDetailBody {
    flex: 1;
    overflow: hidden;
    font-size: 13px;
    line-height: 1.7;
    color: #333;
}

/* Cabecera del Modal */
.header-notificaciones {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-right: 40px;
}

.titulo-notificaciones {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

#notif-cliente-nombre {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.acciones-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

.acciones-header .btn {
    width: auto !important;
    padding-left: 24px !important;
    padding-right: 24px !important;
}

.acciones-header-notif {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.acciones-header-notif .btn {
    width: auto !important;
}

/* 4 Tarjetas de Estadísticas */
.stats-notificaciones {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-card {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    background: white;
    transition: transform 0.2s ease;
    min-width: 180px;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card.active {
    outline: 2px solid currentColor;
    outline-offset: 2px;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card .icono-stat {
    width: 42px;
    height: 42px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.stat-card .text-stat {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}

.stat-card .etiqueta {
    text-transform: uppercase;
    color: #888;
    letter-spacing: 0.5px;
}

/* Colores de las Cards */
.stat-total {
    background-color: #f8f9fa;
}

.stat-total .icono-stat {
    background-color: #e9ecef;
    color: var(--color-secundario);
}

.stat-total .valor,
.stat-total .etiqueta {
    color: var(--color-secundario);
}

/* (duplicado eliminado — ya definido arriba en .stat-card .text-stat) */

.stat-sunat-notif {
    background-color: #fff5f5;
    border-color: #ffe3e3;
}

.stat-sunat-notif .icono-stat {
    background-color: #ffc9c9;
    color: var(--color-alerta);
}

.stat-sunat-notif .valor,
.stat-sunat-notif .etiqueta {
    color: var(--color-alerta);
}

.stat-sunat-msj {
    background-color: #f0f7ff;
    border-color: #d0ebff;
}

.stat-sunat-msj .icono-stat {
    background-color: #d0ebff;
    color: var(--color-primario);
}

.stat-sunat-msj .valor,
.stat-sunat-msj .etiqueta {
    color: var(--color-primario);
}

.stat-sunafil {
    background-color: #ebfbee;
    border-color: #d3f9d8;
}

.stat-sunafil .icono-stat {
    background-color: #d3f9d8;
    color: var(--color-exito);
}

.stat-sunafil .valor,
.stat-sunafil .etiqueta {
    color: var(--color-exito);
}


/* Barra de Filtros y Búsqueda */
.filtros-notificaciones {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 16px;
    background: white;
    border-radius: 24px;
}

.busqueda-notif {
    flex: 1;
}

.filtros-notificaciones .search-box {
    width: 100% !important;
    position: relative;
}

/* Make inner select seamless */

.divisor-vertical {
    width: 1px;
    height: 24px;
    background-color: rgba(0, 0, 0, 0.08);
}

.estado-filtro select {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    min-width: 150px;
    padding: 8px !important;
    cursor: pointer;
    font-size: 13px;
    color: #333;
}

.btn-limpiar {
    background: transparent;
    border: none;
    color: var(--color-primario);
    font-weight: 700;
    font-size: var(--medida-13px, 13px);
    cursor: pointer;
    padding: 8px 16px;
    text-transform: uppercase;
}

.btn-limpiar:hover {
    text-decoration: underline;
}

/* Highlight de fila al navegar desde el panel global */
@keyframes notifGotoFlash {
    0%   { background: var(--color-primario-opacidad); box-shadow: 0 0 0 2px var(--color-primario); }
    70%  { background: var(--color-primario-opacidad); box-shadow: 0 0 0 2px var(--color-primario); }
    100% { background: transparent; box-shadow: none; }
}
.tabla-row.notif-goto-highlight {
    animation: notifGotoFlash 2s ease forwards;
    border-radius: 16px;
}
.tabla-row.notif-row-active {
    background: var(--color-primario-opacidad);
    border-radius: 16px;
}

/* Reemplazando `table` por el grid global de contenedor.css */
.tabla-notif .tabla-header,
.tabla-notif .tabla-row {
    grid-template-columns: .2fr 2.8fr 110px 110px 0fr 148px 115px 110px;
    gap: 12px;
    transition: grid-template-columns 0.4s ease;
}

/* Columna extra SUNAFIL: colapsada por defecto, se expande con animación */
.tabla-notif .col-tipo-req {
    display: flex;
    align-items: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.tabla-notif.sunafil-activo .tabla-header,
.tabla-notif.sunafil-activo .tabla-row {
    grid-template-columns: .3fr 2.5fr 110px 110px 1.5fr 148px 115px 100px;
}

.tabla-notif.sunafil-activo .col-tipo-req {
    opacity: 1;
    transition: opacity 0.3s ease 0.25s;
}

/* Evitar que las celdas desborden su columna en el grid */
.tabla-notif .col {
    min-width: 0;
    overflow: hidden;
}

.tabla-notif .col-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.tabla-notif .col-status {
    justify-content: center;
}

.notif-asunto {
    overflow: hidden;
    text-overflow: ellipsis;
}

.notif-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.notif-id {
    font-size: 11px;
    opacity: 0.6;
    flex-shrink: 0;
}

/* Estado Badge */
.badge-estado {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid;
}

.badge-estado.pendiente {
    color: #f59f00;
    border-color: #ffe8cc;
    background-color: #fff9db;
}

/* Chip de estado — acción clickeable */
.chip-estado {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    border: 1.5px solid;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.chip-estado--pendiente {
    color: #f59f00;
    background: #fff9db;
    border-color: #ffe8cc;
}

.chip-estado--pendiente:hover {
    background: #f59f00;
    color: #fff;
    border-color: #f59f00;
}

.chip-estado--revisado {
    color: var(--color-exito);
    background: var(--color-exito-opacidad);
    border-color: var(--color-exito-opacidad);
}

.chip-estado--revisado:hover {
    background: #fff9db;
    color: #f59f00;
    border-color: #ffe8cc;
}

/* Acciones ROW */
.acciones-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.acciones-row button {
    background: transparent;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
}

.acciones-row button:hover {
    background: #f0f0f0;
    color: #1a1a1a;
    border-color: #ccc;
}

/* Botón destacar / estrella */
.btn-destacar {
    color: #ccc !important;
    border-color: #e8e8e8 !important;
    transition: color 0.2s, background 0.2s, border-color 0.2s !important;
}

.btn-destacar:hover {
    color: #f59f00 !important;
    border-color: #ffe8cc !important;
    background: #fff9db !important;
}

.btn-destacar.activo {
    color: #f59f00 !important;
    border-color: #ffd43b !important;
    background: #fff9db !important;
}

/* Footer / Paginacion */
.footer-notificaciones {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
}

.paginacion-notif {
    display: flex;
    gap: 8px;
}

.paginacion-notif button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #333;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.paginacion-notif button:hover {
    background: #f0f0f0;
}

.paginacion-notif button.active {
    background: var(--color-primario);
    color: white;
}

/* ── DETALLE DE NOTIFICACIÓN (Segundo Nivel) ── */
.modal-overlay-detalle {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    /* Por encima del modal de lista */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay-detalle.open {
    opacity: 1;
    pointer-events: all;
}

.modal-detalle {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 16px;
    width: min(900px, 95vw);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    transform: translateY(12px);
    transition: transform 0.25s;
    color: #e6edf3;
}

.modal-overlay-detalle.open .modal-detalle {
    transform: translateY(0);
}

.modal-detalle-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid #30363d;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.modal-detalle-header .modal-icon {
    width: 40px;
    height: 40px;
    background: #2d1200;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.modal-detalle-header .modal-meta {
    flex: 1;
    min-width: 0;
}

.modal-detalle-header .modal-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 6px;
}

.modal-detalle-header .modal-fecha {
    font-size: 12px;
    color: #8b949e;
    display: flex;
    align-items: center;
    gap: 6px;
}

.modal-detalle-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #30363d;
    background: transparent;
    color: #8b949e;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.modal-detalle-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

/* PDF ya en caché — botón de descarga con punto verde */
button.pdf-cached {
    position: relative;
}
button.pdf-cached::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #40c057;
    border: 1px solid #fff;
}

/* ── Contenido HTML de SUNAT dentro del modal detalle ── */
#notifDetailBody table {
    width: 100% !important;
    border-collapse: collapse;
    font-size: 12.5px;
}
#notifDetailBody td, #notifDetailBody th {
    vertical-align: top;
    padding: 4px 6px;
}
#notifDetailBody img { max-width: 100%; height: auto; }
#notifDetailBody a   { color: var(--color-primario); word-break: break-all; }
#notifDetailBody p   { margin: 6px 0; }

.modal-detalle-tabs {
    display: flex;
    padding: 0 24px;
    border-bottom: 1px solid #30363d;
}

.modal-detalle-tab {
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #8b949e;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    transition: all 0.15s;
}

.modal-detalle-tab.active {
    color: var(--color-primario);
    border-bottom-color: var(--color-primario);
}

.modal-detalle-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.sunat-content-render {
    background: white;
    color: #222;
    border-radius: 8px;
    padding: 24px;
    font-size: 13px;
    line-height: 1.6;
}

.sunat-content-render table {
    width: 100% !important;
}

.sunat-text-render {
    white-space: pre-wrap;
    font-size: 13px;
    line-height: 1.8;
    color: #cbd5e1;
    font-family: inherit;
}

.tab-panel-detalle {
    display: none;
}

.tab-panel-detalle.active {
    display: block;
}

.modal-detalle-footer {
    padding: 16px 24px;
    border-top: 1px solid #30363d;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}


/* ==========================================================
   PANEL DE ALERTAS GLOBAL (dropdown del header)
   ========================================================== */

.panel-alertas-wrap {
    position: fixed;
    z-index: 600;
    animation: AparicionSuave 0.2s ease-out forwards;
}

.panel-alertas {
    width: 308px;
    background: var(--color-blanco);
    border-radius: 36px;
    box-shadow: var(--shadow-xl), 0 0 0 1px var(--color-silver);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.panel-alertas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-bottom: var(--border);
    gap: 12px;
}

.panel-alertas-titulo {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.panel-alertas-textos {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.panel-alertas-sub {
    color: rgb(from var(--color-secundario) r g b / 0.4);
}

.btn-panel-accion {
    width: auto !important;
    padding: 6px 12px !important;
    border-radius: 10px !important;
    font-size: var(--medida-12px) !important;
    flex-shrink: 0;
}

/* Cuerpo */
.panel-alertas-cuerpo {
    max-height: 420px;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.panel-alertas-cuerpo::-webkit-scrollbar { width: 4px; }
.panel-alertas-cuerpo::-webkit-scrollbar-track { background: transparent; }
.panel-alertas-cuerpo::-webkit-scrollbar-thumb { background: var(--color-silver); border-radius: 4px; }

/* Estado vacío */
.panel-alertas-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: rgb(from var(--color-secundario) r g b / 0.4);
    text-align: center;
}

/* ── Grupo por fecha (Hoy / Ayer / DD Mes) ── */
.alerta-fecha-grupo {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ── Cabecera de fecha (Hoy / Ayer / Lunes - 05 Abr) ── */
.alerta-fecha-grupo h5 {
    color: rgb(from var(--color-secundario) r g b / 0.35) !important;
    margin-bottom: 4px;
}

/* Grupo por cliente */
.alerta-grupo {
    padding: 0;
}

.alerta-cliente-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.12s;
    margin-bottom: 2px;
}

.alerta-cliente-header:hover {
    background: var(--color-fondo2);
}

.alerta-cliente-info {
    flex: 1;
    min-width: 0;
}

.alerta-cliente-nombre {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.alerta-cliente-sub {
    color: rgb(from var(--color-secundario) r g b / 0.4);
    margin-top: 1px;
}

.alerta-accordion-arrow {
    font-size: 10px;
    color: rgb(from var(--color-secundario) r g b / 0.3);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

/* Lista de items (gap entre notificaciones) */
.alerta-items-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Item individual */
@keyframes itemEntrada {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.alerta-item {
    border-radius: 24px;
    padding: 12px;
    cursor: default;
    background: var(--color-fondo2);
    border: 1.5px solid transparent;
    overflow: hidden;
    animation: itemEntrada 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    transition: border-radius 0.2s ease;
}

.alerta-item:nth-child(1) { animation-delay:   0ms; }
.alerta-item:nth-child(2) { animation-delay:  50ms; }
.alerta-item:nth-child(3) { animation-delay: 100ms; }
.alerta-item:nth-child(4) { animation-delay: 150ms; }
.alerta-item:nth-child(5) { animation-delay: 200ms; }
.alerta-item:nth-child(n+6) { animation-delay: 250ms; }

.alerta-item:hover {
    border-radius: 32px;
}

.alerta-item-main {
    display: flex;
    align-items: center;
    gap: 8px;
}

.alerta-item-icon {
    flex-shrink: 0;
    margin-top: 1px;
}

.alerta-texto {
    flex: 1;
    min-width: 0;
}

.alerta-asunto {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
}

.alerta-time {
    color: rgb(from var(--color-secundario) r g b / 0.4);
}

.alerta-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    flex-wrap: wrap;
}

/* Botones de acción — slide-down suave en hover */
.alerta-item-acciones {
    display: flex;
    gap: 8px;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-top: 0;
    transform: translateY(-6px);
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity    0.25s ease,
                margin-top 0.3s ease,
                transform  0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.alerta-item:hover .alerta-item-acciones {
    max-height: 60px;
    opacity: 1;
    margin-top: 10px;
    transform: translateY(0);
}

.btn-alerta-eliminar,
.btn-alerta-ver {
    flex: 1;
    font-size: 12px !important;
    padding: 10px 8px !important;
    border-radius: 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    font-weight: 600 !important;
    cursor: pointer;
    white-space: nowrap;
}

/* Pill pequeña para el panel */
.pill-sm {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
    font-size: 10px;
    font-weight: 600;
}

.pill-sm.alerta    { background: var(--color-alerta-opacidad);      color: var(--color-alerta); }
.pill-sm.primario  { background: var(--color-primario-opacidad);    color: var(--color-primario); }
.pill-sm.exito     { background: var(--color-exito-opacidad);       color: var(--color-exito); }
.pill-sm.pendiente { background: var(--color-advertencia-opacidad); color: var(--color-advertencia); }
.pill-sm.leido     { background: var(--color-fondo2); color: rgb(from var(--color-secundario) r g b / 0.4); }

.alerta-fecha {
    color: rgb(from var(--color-secundario) r g b / 0.4);
}

/* Footer */
.panel-alertas-footer {
    display: flex;
    gap: 8px;
    padding: 24px;
    border-top: var(--border);
}

.btn-panel-footer {
    flex: 1;
    justify-content: center !important;
}