/*
 Capa visual y adaptable del sistema. Se carga al final para no modificar general.css:
 si se quita su enlace en system/addons/add_js.php la interfaz vuelve a como estaba.
*/

:root{
    --app-acento: #1E3A8A;
    --app-tinta: #1E293B;
    --app-tenue: #64748B;
    --app-borde: #E2E8F0;
    --app-fondo: #F5F7FA;
    --app-superficie: #ffffff;
    --app-radio: 14px;
    --app-sombra: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
    --app-sombra-alta: 0 20px 48px rgba(15, 23, 42, .22);
    --app-barra-inferior: 62px;
    --seguro-arriba: env(safe-area-inset-top, 0px);
    --seguro-abajo: env(safe-area-inset-bottom, 0px);

    --topbar-height: calc(60px + var(--seguro-arriba));
    --sidebar-width: 256px;
    --sidebar-bg: #1E293B;
    --sidebar-active: rgba(255, 255, 255, .1);
    --topbar-bg: var(--app-superficie);
    --page-bg: var(--app-fondo);
    --text-color: var(--app-tinta);

    --bs-body-font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --bs-body-color: var(--app-tinta);
    --bs-border-color: var(--app-borde);
    --bs-border-radius: 9px;
    --bs-border-radius-sm: 7px;
    --bs-border-radius-lg: 12px;
}

html, body{
    height: 100dvh;
    -webkit-tap-highlight-color: transparent;
}

body{
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

#__dashboardMain__{
    height: 100dvh;
}

/* ===== Estructura ===== */

.app-topbar{
    padding-top: var(--seguro-arriba);
    border-bottom-color: var(--app-borde);
    box-shadow: none;
}

.brand-logo{
    width: 34px;
    height: 34px;
    border-radius: 9px;
}

.brand-name{
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .06em;
}

.user-area .imagen{
    width: 32px;
    height: 32px;
    object-fit: cover;
}

.app-sidebar{
    padding: 16px 12px;
}

.app-sidebar .nav-link,
.mobile-sidebar .nav-link,
.app-sidebar .menu-toggle,
.mobile-sidebar .menu-toggle{
    position: relative;
    margin-bottom: 2px;
    padding: 10px 12px;
    color: #CBD5E1;
    font-size: 13.5px;
    border-radius: 10px;
}

.app-sidebar .nav-link.active::after,
.mobile-sidebar .nav-link.active::after{
    content: "";
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 3px;
    background: var(--app-acento);
}

.app-sidebar .submenu .nav-link,
.mobile-sidebar .submenu .nav-link{
    padding: 8px 10px 8px 42px;
    font-size: 13px;
    color: #a3adb9;
}

.app-main{
    padding: 24px;
    overflow-x: hidden;
}

/* ===== Superficies ===== */

.bloque2,
.dashboard-card{
    background: var(--app-superficie);
    border: 1px solid var(--app-borde);
    border-radius: var(--app-radio);
    box-shadow: var(--app-sombra);
}

.dashboard-card{
    transition: box-shadow .18s ease, transform .18s ease;
}

@media (hover: hover) {
    .dashboard-card:hover{
        box-shadow: 0 6px 18px rgba(15, 23, 42, .08);
    }
}

.page-title,
.titulo{
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -.01em;
}

.lbltxt,
.page-subtitle,
.dashboard-card p{
    color: var(--app-tenue);
}

.bloque3{
    border-bottom-color: var(--app-borde);
}

.bloque3-seleccion{
    border-radius: 8px;
    transition: background .12s ease;
}

.bloque3-seleccion:hover{
    background: #F8FAFC;
}

.bloque_titulo{
    border-bottom: 1px solid var(--app-borde);
    font-size: 16px;
    font-weight: 600;
    color: var(--app-tinta);
}

/* ===== Controles ===== */

.btn{
    --bs-btn-font-weight: 500;
    transition: background-color .12s ease, border-color .12s ease, color .12s ease, box-shadow .12s ease;
}

.btn-dark{
    --bs-btn-bg: #1E293B;
    --bs-btn-border-color: #1E293B;
    --bs-btn-hover-bg: #334155;
    --bs-btn-hover-border-color: #334155;
    --bs-btn-active-bg: #000;
}

/* Una sola accion principal en todo el sistema, antes convivian azul y negro */
.btn-primary{
    --bs-btn-bg: #1E293B;
    --bs-btn-border-color: #1E293B;
    --bs-btn-hover-bg: #334155;
    --bs-btn-hover-border-color: #334155;
    --bs-btn-active-bg: #000;
    --bs-btn-active-border-color: #000;
    --bs-btn-disabled-bg: #64748B;
    --bs-btn-disabled-border-color: #64748B;
}

.pagination{
    --bs-pagination-color: #334155;
    --bs-pagination-hover-color: #1E293B;
    --bs-pagination-focus-color: #1E293B;
    --bs-pagination-active-bg: #1E293B;
    --bs-pagination-active-border-color: #1E293B;
    --bs-pagination-border-color: var(--app-borde);
}

/* Encabezados de tabla claros en lugar del bloque negro */
.table > thead.table-dark,
.table-dark > thead{
    --bs-table-bg: #F1F5F9;
    --bs-table-color: #334155;
    --bs-table-border-color: var(--app-borde);
    --bs-table-striped-bg: #F1F5F9;
    --bs-table-hover-bg: #F1F5F9;
    --bs-table-hover-color: #334155;
}

.btn-outline-secondary,
.btn-outline-dark{
    --bs-btn-color: #334155;
    --bs-btn-border-color: #CBD5E1;
    --bs-btn-hover-bg: #F1F5F9;
    --bs-btn-hover-color: #1E293B;
    --bs-btn-hover-border-color: #CBD5E1;
    --bs-btn-active-bg: #E2E8F0;
    --bs-btn-active-color: #1E293B;
    --bs-btn-active-border-color: #CBD5E1;
}

.form-control,
.form-select{
    border-color: #CBD5E1;
}

.form-control:focus,
.form-select:focus{
    border-color: #64748B;
    box-shadow: 0 0 0 3px rgba(102, 112, 133, .16);
}

.dropdown-menu{
    border-color: var(--app-borde);
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .12);
}

/* ===== Tablas ===== */

.table{
    --bs-table-hover-bg: #F8FAFC;
    --bs-table-border-color: var(--app-borde);
}

.td_cabecera{
    background: #F1F5F9;
    color: #334155;
    border-color: var(--app-borde);
    font-weight: 600;
}

.td_cuerpo{
    border-color: var(--app-borde);
    color: var(--app-tinta);
}

.tabla-desplazable{
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* El buscador de DataTables se ajusta al ancho disponible */
div.dataTables_wrapper{
    max-width: 100%;
}

div.dataTables_wrapper .dt-row > [class*="col-"]{
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

div.dataTables_wrapper div.dataTables_filter label{
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 320px;
    margin-left: auto;
}

div.dataTables_wrapper div.dataTables_filter input{
    flex: 1;
    width: auto;
    min-width: 0;
    margin-left: 0;
}

/* ===== Modales ===== */

.modalSplashWin{
    background: rgba(15, 23, 42, .5);
    opacity: 1;
    animation: aparecer .15s ease;
}

.modalWin{
    max-width: calc(100vw - 32px) !important;
    min-width: min(400px, calc(100vw - 32px)) !important;
    max-height: calc(100dvh - 32px);
    background: var(--app-superficie);
    border-radius: 16px;
    box-shadow: var(--app-sombra-alta);
    overflow: hidden;
    animation: subir .18s ease;
}

.modalWinTitle{
    position: absolute;
    inset: 0 0 auto 0;
    height: 44px;
    background: var(--app-superficie) !important;
}

.modalWinContent{
    top: 44px;
    border-radius: 0;
    background: var(--app-superficie) !important;
}

.modalWinCloseBtn{
    position: absolute;
    top: 7px;
    right: 10px;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    color: #334155;
    font-size: 13px;
    background: #F1F5F9;
    border-radius: 50%;
}

.modalWinCloseBtn:hover{
    background: #E2E8F0;
}

.box_confirm{
    width: min(360px, calc(100vw - 32px));
    height: auto;
    min-height: 200px;
    padding: 20px 20px 68px;
    border-radius: 16px;
    box-shadow: 0 0 0 100vmax rgba(15, 23, 42, .5), var(--app-sombra-alta);
}

@keyframes aparecer {
    from { opacity: 0; }
}

@keyframes subir {
    from { opacity: 0; transform: translateY(10px); }
}

@media (prefers-reduced-motion: reduce) {
    *{ animation: none !important; transition: none !important; }
}

/* ===== Login ===== */

.login-panel{
    min-height: 100dvh;
    display: flex;
    align-items: center;
    background: var(--app-superficie);
}

.login-panel > div{
    width: 100%;
}

.login-logo{
    width: 6.5em;
    max-width: 40%;
    border-radius: 16px;
}

.login-imagen{
    height: 100dvh;
    width: 100%;
    background-size: cover;
    background-position: bottom;
}

/* ===== Campana de notificaciones ===== */

.boton-notif{
    position: relative;
    width: 38px;
    height: 38px;
    padding: 0;
    font-size: 18px;
    border-radius: 50%;
}

.notif-badge{
    position: absolute;
    top: 1px;
    right: 0;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    line-height: 17px;
    background: var(--app-acento);
    border-radius: 9px;
    box-shadow: 0 0 0 2px var(--app-superficie);
}

.menu-notif{
    width: min(340px, calc(100vw - 20px));
    padding: 0;
    overflow: hidden;
}

.notif-cabecera{
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    font-weight: 600;
    border-bottom: 1px solid var(--app-borde);
}

.notif-total{
    color: var(--app-tenue);
    font-size: 12px;
    font-weight: 400;
}

#notifLista{
    max-height: min(320px, 50dvh);
    overflow-y: auto;
}

.notif-item{
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    white-space: normal;
    border-bottom: 1px solid #F1F5F9;
}

.notif-nombre{
    font-size: 13px;
}

.notif-hora{
    flex-shrink: 0;
    color: var(--app-tenue);
    font-size: 12px;
}

.notif-vacio{
    padding: 24px 14px;
    color: var(--app-tenue);
    text-align: center;
}

.notif-todos{
    padding: 11px 14px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    border-top: 1px solid var(--app-borde);
}

/* ===== Menu lateral mini: solo iconos en pantallas medianas ===== */

.app-sidebar{
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .2) transparent;
}

.app-sidebar .nav-link,
.app-sidebar .menu-toggle{
    white-space: nowrap;
}

@media (min-width: 768px) and (max-width: 1199.98px) {
    :root{
        --sidebar-width: 68px;
    }

    .app-sidebar{
        padding: 12px 10px;
        transition: width .16s ease, box-shadow .16s ease;
    }

    /* Se expande encima del contenido, sin moverlo */
    .app-sidebar.abierto,
    .app-sidebar:has(:focus-visible){
        width: 256px;
        box-shadow: 8px 0 28px rgba(15, 23, 42, .28);
    }

    .app-sidebar:not(.abierto):not(:has(:focus-visible)) .nav-link > span,
    .app-sidebar:not(.abierto):not(:has(:focus-visible)) .menu-toggle > span,
    .app-sidebar:not(.abierto):not(:has(:focus-visible)) .menu-arrow,
    .app-sidebar:not(.abierto):not(:has(:focus-visible)) .sidebar-heading,
    .app-sidebar:not(.abierto):not(:has(:focus-visible)) .collapse{
        display: none;
    }

    .app-sidebar:not(.abierto):not(:has(:focus-visible)) .nav-link,
    .app-sidebar:not(.abierto):not(:has(:focus-visible)) .menu-toggle{
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }

    @media (hover: hover) {
        .app-sidebar:hover{
            width: 256px;
            box-shadow: 8px 0 28px rgba(15, 23, 42, .28);
        }

        .app-sidebar:hover .nav-link > span,
        .app-sidebar:hover .menu-toggle > span,
        .app-sidebar:hover .menu-arrow{
            display: inline !important;
        }

        .app-sidebar:hover .sidebar-heading{
            display: block !important;
        }

        .app-sidebar:hover .collapse.show,
        .app-sidebar:hover .collapsing{
            display: block !important;
        }

        .app-sidebar:hover .nav-link,
        .app-sidebar:hover .menu-toggle{
            justify-content: flex-start !important;
            padding-left: 12px !important;
            padding-right: 12px !important;
        }

        .app-sidebar:hover .submenu .nav-link{
            padding-left: 42px !important;
        }
    }
}

/* ===== Barra inferior tipo app ===== */

.app-bottombar{
    display: none;
}

/* ===== Celular y pantallas angostas ===== */

@media (max-width: 767.98px) {
    :root{
        --topbar-height: calc(56px + var(--seguro-arriba));
    }

    .app-topbar{
        padding-left: 10px;
        padding-right: 10px;
    }

    .app-main{
        padding: 14px 12px calc(var(--app-barra-inferior) + var(--seguro-abajo) + 14px);
    }

    /* Correos y claves largas se parten en lugar de salirse; las tablas conservan sus palabras y se desplazan */
    .app-main{
        overflow-wrap: anywhere;
    }

    .app-main table,
    .modalWinContent table{
        overflow-wrap: normal;
    }

    .app-main table th,
    .modalWinContent table th{
        white-space: nowrap;
    }

    div.dataTables_wrapper div.dataTables_paginate{
        overflow-x: auto;
    }

    div.dataTables_wrapper div.dataTables_paginate ul.pagination{
        flex-wrap: wrap;
        justify-content: center;
        row-gap: 4px;
    }

    div.dataTables_wrapper div.dataTables_info,
    div.dataTables_wrapper div.dataTables_length{
        text-align: center;
        white-space: normal;
    }

    .app-main > .bloque2,
    .app-main .bloque2.m-3{
        margin: 0 0 12px !important;
    }

    .app-main .col-md-4.text-end{
        margin-top: 8px;
    }

    .app-bottombar{
        position: fixed;
        inset: auto 0 0 0;
        z-index: 1035;
        display: flex;
        height: calc(var(--app-barra-inferior) + var(--seguro-abajo));
        padding-bottom: var(--seguro-abajo);
        background: rgba(255, 255, 255, .94);
        border-top: 1px solid var(--app-borde);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
    }

    .app-bottombar button{
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        color: #475467;
        font-size: 11px;
        font-weight: 500;
        background: none;
        border: 0;
    }

    .app-bottombar button i{
        font-size: 21px;
        line-height: 1;
    }

    .app-bottombar button:active{
        color: var(--app-acento);
    }

    .mobile-sidebar{
        width: min(86vw, 320px) !important;
        overflow-y: auto;
        padding: calc(14px + var(--seguro-arriba)) 12px calc(14px + var(--seguro-abajo));
    }

    /* Los modales ocupan toda la pantalla, como una vista de app */
    .modalWin{
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        max-height: 100% !important;
        margin: 0 !important;
        border-radius: 0;
    }

    .modalWinTitle{
        height: calc(48px + var(--seguro-arriba));
    }

    .modalWinContent{
        top: calc(48px + var(--seguro-arriba));
        width: 100%;
        padding-bottom: var(--seguro-abajo);
        border-radius: 0;
    }

    .modalWinCloseBtn{
        top: calc(8px + var(--seguro-arriba));
        width: 36px;
        height: 36px;
    }

    .modalcortina{
        left: 0;
        right: 0;
        width: 100%;
    }

    /* Evita el zoom automatico de iOS al enfocar un campo */
    input.form-control,
    select.form-select,
    textarea.form-control{
        font-size: 16px;
    }

    .btn-sm{
        min-height: 36px;
    }

    .nav_center{
        width: calc(100% - 16px);
    }

    .mapalayer{
        height: calc(100dvh - var(--topbar-height) - var(--app-barra-inferior) - var(--seguro-abajo));
    }

    .login-panel{
        min-height: 100dvh;
        align-items: flex-start;
    }

    .login-panel .p-5{
        padding: 40px 24px !important;
    }
}

/* Avisos de notify: en celular se cortaban por salir de la pantalla */
@media (max-width: 767.98px) {
    .notifyjs-corner{
        left: 8px !important;
        right: 8px !important;
        margin: 0 !important;
        transform: none !important;
    }

    .notifyjs-wrapper,
    .notifyjs-container{
        margin: 0 !important;
        width: 100%;
    }

    .notifyjs-bootstrap-base{
        white-space: normal !important;
        max-width: 100%;
        box-sizing: border-box;
    }
}


/* Pestana activa: por ahora la pantalla visible siempre es Inicio */


@keyframes p4-entrada {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}


/* Viaje a pantalla completa: mapa de fondo y panel inferior */


/* Linea vertical que une los pasos */


/* Texto simple sobre el mapa, sin cuadro ni sombra */


