/* Estilos propios de Solusa */

body {
    background-color: #f4f6f9;
}

.navbar-brand i {
    margin-right: 6px;
}

.stat-card {
    color: #fff;
    border-radius: 10px;
    border: none;
}

.kpi-clickable {
    cursor: pointer;
    transition: transform .12s ease-in-out, box-shadow .12s ease-in-out;
}
.kpi-clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 .5rem 1rem rgba(0,0,0,.15);
}

.card {
    border-radius: 10px;
    border: 1px solid #e6e9ee;
}

.table thead th {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #6c757d;
    border-bottom-width: 1px;
}

.sidebar {
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    background: #1a2540;
    /* Nunca debe encogerse: sin esto, si el contenido principal es más
       ancho que la pantalla, el contenedor flex comprime el sidebar en
       vez de generar scroll horizontal dentro del contenido principal. */
    flex: 0 0 250px;
    /* Scrollbar propio, discreto, dentro del sidebar */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.35) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255,255,255,.35);
    border-radius: 4px;
}


.sidebar .nav-link {
    color: rgba(255,255,255,.75);
    font-size: .92rem;
}

.sidebar .nav-link.active,
.sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,.08);
    border-radius: 6px;
}

/* El contenido principal nunca debe forzar el ancho del contenedor flex
   general; cualquier desborde (tablas anchas, etc.) debe generar su propio
   scroll horizontal interno, nunca empujar o comprimir el sidebar. */
main.flex-fill {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
}

/* Botón hamburguesa: solo visible en pantallas pequeñas */
.btn-sidebar-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.4rem;
    color: #1a2540;
    padding: 0;
    margin-right: .75rem;
    line-height: 1;
}

/* Respeta el notch / barra de estado dentro de apps móviles */
.navbar {
    padding-top: calc(.5rem + env(safe-area-inset-top));
}

/* ---------------------------------------------------------------
   Responsive: sidebar tipo offcanvas en pantallas pequeñas
   --------------------------------------------------------------- */
@media (max-width: 768px) {
    .btn-sidebar-toggle {
        display: inline-block;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform .25s ease-in-out;
        box-shadow: 2px 0 12px rgba(0,0,0,.3);
        padding-top: calc(1rem + env(safe-area-inset-top)) !important;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    #sidebarOverlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.45);
        z-index: 1040;
    }

    body.sidebar-open #sidebarOverlay {
        display: block;
    }

    main.flex-fill {
        width: 100%;
    }
}


/* Barra de herramientas (exportar / imprimir) */
.toolbar-actions .btn {
    font-size: .8rem;
}

/* ---------------------------------------------------------------
   Módulo Bandeja de entrada (IMAP)
   --------------------------------------------------------------- */
.bandeja-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: #eef2ff;
    color: #3b5bdb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.bandeja-body {
    min-height: 60vh;
}

.bandeja-list-col {
    border-right: 1px solid #e6e9ee;
    display: flex;
    flex-direction: column;
}

.bandeja-list {
    flex: 1 1 auto;
    overflow-y: auto;
    max-height: 65vh;
}

.btn-filtro {
    border: 1px solid #dee2e6;
    background: #fff;
    color: #495057;
    font-size: .78rem;
}
.btn-filtro.active {
    background: #e8f0fe;
    color: #1a2540;
    border-color: #d2e3fc;
    font-weight: 600;
}

#bandejaBuscar {
    box-shadow: none;
}
#bandejaBuscar:focus {
    box-shadow: none;
    border-color: #dee2e6;
}
.input-group:focus-within {
    box-shadow: 0 0 0 2px rgba(59,91,219,.15);
    border-radius: .375rem;
}

.bandeja-item {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    padding: .7rem .9rem;
    border-bottom: 1px solid #f1f3f5;
    border-left: 3px solid transparent;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition: background-color .12s ease, border-color .12s ease;
    position: relative;
}
.bandeja-item:hover {
    background: #f4f6fb;
}
.bandeja-item:active {
    background: #e9ecf5;
}
.bandeja-item.active {
    background: #e8f0fe;
    border-left-color: #3b5bdb;
}
.bandeja-item.unread::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 1.15rem;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #3b5bdb;
}
.bandeja-item.unread {
    padding-left: 1.5rem;
}

.bandeja-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .78rem;
    flex-shrink: 0;
    margin-top: .1rem;
}

.bandeja-item-body {
    flex: 1 1 auto;
    min-width: 0;
}

.bandeja-item-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .5rem;
}
.bandeja-item-from {
    font-size: .85rem;
    color: #495057;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bandeja-item.unread .bandeja-item-from,
.bandeja-item.unread .bandeja-item-subject {
    color: #1a2540;
    font-weight: 600;
}
.bandeja-item-fecha {
    font-size: .72rem;
    color: #adb5bd;
    white-space: nowrap;
    flex-shrink: 0;
}
.bandeja-item-subject {
    font-size: .83rem;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: .1rem;
}
.bandeja-item-preview {
    font-size: .78rem;
    color: #adb5bd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: .1rem;
    display: flex;
    align-items: center;
    gap: .3rem;
}

.bandeja-detail-col {
    display: flex;
    flex-direction: column;
}

.bandeja-cuerpo {
    overflow-y: auto;
    font-size: .9rem;
    padding: 0 !important;
}
.bandeja-cuerpo iframe {
    display: block;
}

@media (max-width: 768px) {
    .bandeja-list-col {
        border-right: none;
        border-bottom: 1px solid #e6e9ee;
    }
    .bandeja-list {
        max-height: 40vh;
    }
}

.bandeja-detail-col {
    position: relative;
}

/* Overlay de procesamiento con IA: se muestra a pantalla completa (fixed)
   para que sea imposible pasarlo por alto, sin importar el scroll de la
   columna del correo. */
.bandeja-overlay-ia {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 18, 28, 0.92) !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    z-index: 2000 !important;
    color: #fff;
}

.bandeja-overlay-ia.d-none {
    display: none !important;
}

.bandeja-overlay-ia .bandeja-overlay-card {
    max-width: 380px;
    padding: 2rem 2.25rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff !important;
}

.bandeja-overlay-ia .bandeja-overlay-card * {
    color: #fff;
}

.bandeja-overlay-ia .bandeja-overlay-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(59, 91, 219, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.75rem;
    color: #8fb3ff;
    animation: bandeja-pulse 1.4s ease-in-out infinite;
}

@keyframes bandeja-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(143, 179, 255, 0.35); }
    50% { transform: scale(1.08); box-shadow: 0 0 0 10px rgba(143, 179, 255, 0); }
}

/* Impresión: solo se muestra el contenido principal (tablas) */
@media print {
    .no-print {
        display: none !important;
    }
    .sidebar,
    .navbar {
        display: none !important;
    }
    main {
        margin: 0 !important;
    }
    .card {
        border: none !important;
    }
    a {
        text-decoration: none !important;
        color: inherit !important;
    }
}
