/* =======================
   BASE
======================= */
body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f3f4f6;
    color: #111827;
    padding-top: 60px; /* por header fixed */
}

.app-content {
    padding: 1rem;
}

/* =======================
   HEADER + NAV
======================= */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .5rem 1rem;
    background: #111827;
    color: #f9fafb;
    z-index: 999;
    min-height: 56px;      /* altura similar a navbar Bootstrap */
    flex-wrap: nowrap;
}

/* Lado izquierdo: logo + nav */
.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo-text {
    font-weight: 700;
    letter-spacing: .12em;
    font-size: 1rem;
    line-height: 1;
    display: inline-block;
}

/* User area (lado derecho) */
.user-area {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-left: auto;
    padding-left: 1rem;
    flex-wrap: nowrap;
}

.user-name {
    font-size: .9rem;
}

/* Botones genéricos */
.btn {
    border: none;
    border-radius: .375rem;
    padding: .4rem .8rem;
    cursor: pointer;
    font-size: .85rem;
}

/* Botón menú móvil (solo mobile, se activa en media query) */
.btn-menu-mobile {
    display: none;
    background: transparent;
    color: #f9fafb;
    font-size: 1.4rem;
}

/* =======================
   NAV DESKTOP
======================= */
.app-nav {
    background: transparent;
    color: #e5e7eb;
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 1.25rem;
    align-items: center;
}

.nav-list > li {
    position: relative;
}

/* Links raíz */
.nav-list > li > a {
    color: #e5e7eb;
    text-decoration: none;
    font-size: 0.95rem;
    padding: .25rem .75rem;
    display: block;
}

/* Grupo con submenú */
.nav-group {
    position: relative;
}

.nav-group-toggle {
    display: block;
    width: 100%;
    background: transparent;
    border: none;
    color: #e5e7eb;
    font-size: .9rem;
    cursor: pointer;
    padding: .25rem .75rem;
    text-align: left;
}

.nav-group-toggle::after {
    content: ' ▾';
    font-size: .6rem;
}

.nav-group:hover > .nav-group-toggle {
    background-color: rgba(255, 255, 255, 0.08);
}

/* Submenú FLOTANTE (PC) */
.nav-sublist {
    list-style: none;
    margin: 0;
    padding: .35rem 0;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 180px;
    background: #111827;
    border-radius: .35rem;
    box-shadow: 0 12px 25px rgba(15, 23, 42, .4);
    display: none;
    z-index: 100;
}

.nav-sublist li {
    padding: 0;
}

.nav-sublist a {
    display: block;
    padding: .4rem .75rem;
    color: #e5e7eb;
    text-decoration: none;
    font-size: .85rem;
    white-space: nowrap;
}

.nav-sublist a:hover {
    background: rgba(55, 65, 81, 0.9);
}

/* Mostrar submenú cuando el grupo está abierto */
.nav-group.open .nav-sublist {
    display: block;
}

/* =======================
   TABLAS
======================= */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.table th,
.table td {
    padding: .5rem .75rem;
    border-bottom: 1px solid #e5e7eb;
    font-size: .9rem;
}

/* =======================
   BOTÓN LOGOUT
======================= */
.logout-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .22rem;
    border-radius: 999px;
    background: transparent;
    border: none;
    text-decoration: none;
    transition: background .18s ease, transform .18s ease, box-shadow .18s ease;
}

.logout-chip:hover {
    background: rgba(15, 23, 42, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.6);
}

.logout-icon {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f9fafb;
    color: #ef4444;
    font-size: .85rem;
}

/* =======================
   RESPONSIVE MENÚ MÓVIL (<= 768px)
======================= */
@media (max-width: 991.98px) {
    .app-header {
        padding-inline: .75rem;
    }

    .header-left {
        gap: .75rem;
    }

    .btn-menu-mobile {
        display: inline-flex;
        position: fixed;
        top: .25rem;
        right: .6rem;
        z-index: 1200;
        font-size: 1.3rem;
        padding: .2rem .45rem;
        border-radius: .5rem;
        background: rgba(15, 23, 42, 0.5);
        border: none;
    }

    .btn-menu-mobile:hover {
        background: rgba(31, 41, 55, 0.9);
    }

    .btn-menu-mobile:focus-visible {
        outline: 2px solid #38bdf8;
        outline-offset: 2px;
    }

    .app-nav {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;
        width: 260px;
        max-width: 80%;
        background: #020617;
        color: #e5e7eb;
        transform: translateX(100%);
        transition: transform .25s ease-out;
        padding-top: 3.5rem;
        box-shadow: -8px 0 25px rgba(15, 23, 42, .6);
    }

    .app-nav.nav-open {
        transform: translateX(0);
    }

    .nav-list {
        flex-direction: column;
        align-items: flex-start;
        gap: .5rem;
        padding: 1rem 1.25rem;
    }

    .nav-list > li {
        width: 100%;
        position: static;
    }

    .nav-list > li > a,
    .nav-group-toggle {
        width: 100%;
        text-align: left;
        font-size: 1rem;
        padding: .7rem 0;
    }

    .nav-sublist {
        position: static;
        background: transparent;
        box-shadow: none;
        padding-left: 1.2rem;
        padding-top: .3rem;
        z-index: auto;
    }

    .nav-sublist a {
        font-size: .95rem;
        padding: .4rem 0;
    }

    .user-area .logout-chip {
        margin-right: 2.4rem;
    }

    .app-content {
        padding: .75rem;
    }

    /* Backdrop móvil */
    .nav-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.3);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s ease;
        z-index: 998;
    }

    .nav-backdrop.is-active {
        opacity: 1;
        visibility: visible;
    }
}

/* =======================
   LOGIN
======================= */

body.login-body {
    min-height: 100vh;      /* ocupa todo el alto visible */
    overflow: hidden;       /* sin scroll en la página de login */
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top, #1f2937 0, #020617 55%, #020617 100%);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.login-container {
    width: 100%;
    max-width: 360px;
    padding: 1.5rem;
    box-sizing: border-box;
}

.login-card {
    width: 100%;
    padding: 1.8rem 2rem;
    background: rgba(15, 23, 42, 0.98);
    border-radius: 0.9rem;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
    color: #e5e7eb;
    box-sizing: border-box;
}

.login-title {
    margin: 0 0 1.4rem;
    font-size: 1.3rem;
    text-align: center;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.login-form {
    margin: 0;
}

.login-card .form-group {
    margin-bottom: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.login-card .form-group label {
    font-size: 0.9rem;
    color: #9ca3af;
}

.login-card .form-group input {
    width: 100%;
    padding: 0.65rem 0.85rem;
    font-size: 0.95rem;
    border-radius: 0.5rem;
    border: 1px solid #4b5563;
    background: #020617;
    color: #f9fafb;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.login-card .form-group input:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.65);
}

.login-card .btn.btn-primary.btn-block {
    width: 100%;
    margin-top: 0.3rem;
    padding: 0.8rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #f9fafb;
    box-shadow: 0 12px 28px rgba(22, 163, 74, 0.45);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.login-card .btn.btn-primary.btn-block:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 38px rgba(21, 128, 61, 0.6);
    background: linear-gradient(135deg, #16a34a, #15803d);
}

.login-card .btn.btn-primary.btn-block:active {
    transform: translateY(0);
    box-shadow: 0 8px 20px rgba(22, 163, 74, 0.7);
}

.login-card .alert.alert-danger {
    margin-bottom: 1rem;
    padding: 0.6rem 0.8rem;
    border-radius: 0.6rem;
    font-size: 0.9rem;
}

@media (max-width: 640px) {
    .login-container {
        max-width: 100%;
        padding: 2.5rem 1.75rem;
    }

    .login-card {
        padding: 2rem 1.8rem;
        border-radius: 0.85rem;
    }

    .login-title {
        font-size: 1.35rem;
        margin-bottom: 1.7rem;
    }

    .login-card .form-group input {
        padding: 0.9rem 1rem;
        font-size: 1.02rem;
    }

    .login-card .btn.btn-primary.btn-block {
        padding: 0.95rem 1.1rem;
        font-size: 1.02rem;
    }
}

/* =======================
   MODALES BOOTSTRAP (z-index)
======================= */
.modal {
    z-index: 1055 !important;
}

.modal-backdrop {
    z-index: 1050 !important;
    opacity: 0.5;
}

body.debug-modal .modal-backdrop {
    display: none !important;
}

/* =======================
   VARIOS
======================= */
.per-page-select {
    max-width: 140px;
}

#filtro-usuarios-group {
    max-width: 360px;
}

.table-compact td,
.table-compact th {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    font-size: 0.85rem;
}

/* En móviles: aún más compacta + tabla usuarios mejor legible */
@media (max-width: 576px) {
    .table-compact td,
    .table-compact th {
        padding-top: 0.15rem;
        padding-bottom: 0.15rem;
        font-size: 0.78rem;
    }

    #tabla-usuarios td .btn.btn-sm {
        padding: 0.15rem 0.3rem;
        font-size: 0.7rem;
    }

    #tabla-usuarios {
        width: 100%;
        border-collapse: collapse;
        table-layout: auto;
        font-size: 0.9rem;
    }

    #tabla-usuarios th,
    #tabla-usuarios td {
        white-space: normal;
        word-break: normal;
        padding-top: 0.4rem;
        padding-bottom: 0.4rem;
    }
}

/* Aumentar tamaño base en móviles */
@media (max-width: 576px) {
    body {
        font-size: 0.95rem;
    }
}

.table-header-soft th {
    background-color: #4682b4;
    color: #ffffff;
}

@media (min-width: 768px) {
    #grupo-buscar-usuarios {
        max-width: 360px;
    }
}

.modal-content .modal-body {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.modal-content .modal-header,
.modal-content .modal-footer {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.btn-toggle-password i {
    font-size: 0.95rem;
}

.btn-toggle-password:hover {
    color: #e5e7eb;
}
/* Wrapper para campo de contraseña con icono */
.password-wrapper {
    position: relative;
}

/* Input dentro del wrapper: deja espacio para el icono a la derecha */
.password-wrapper input[type="password"],
.password-wrapper input[type="text"] {
    width: 100%;
    padding-right: 2.2rem; /* espacio para el ojo */
    box-sizing: border-box;
}

/* Botón mostrar/ocultar contraseña */
.btn-toggle-password {
    position: absolute;
    top: 50%;
    right: 0.6rem;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
}
html, body.login-body {
    height: 100%;
    margin: 0;
    padding: 0;
}

.resolver-opcion.active {
    box-shadow: 0 0 0 0.15rem rgba(0,0,0,0.15);
    opacity: 1;
}
.resolver-opcion {
    opacity: 0.8;
}
