/* Estilos institucionales sobre Bootstrap 5 */
:root {
    --app-primary: #12355b;
    --app-primary-dark: #0b2440;
    --app-accent: #c8102e;
    --app-sidebar-width: 250px;
    --bs-primary: #1d4f8c;
    --bs-primary-rgb: 29, 79, 140;
    --bs-link-color: #1d4f8c;
    --bs-link-color-rgb: 29, 79, 140;
    --bs-link-hover-color: #12355b;
}

body { background-color: #f3f5f8; }

.btn-primary {
    --bs-btn-bg: #1d4f8c; --bs-btn-border-color: #1d4f8c;
    --bs-btn-hover-bg: #12355b; --bs-btn-hover-border-color: #12355b;
    --bs-btn-active-bg: #0b2440; --bs-btn-active-border-color: #0b2440;
    --bs-btn-disabled-bg: #1d4f8c; --bs-btn-disabled-border-color: #1d4f8c;
}
.btn-outline-primary {
    --bs-btn-color: #1d4f8c; --bs-btn-border-color: #1d4f8c;
    --bs-btn-hover-bg: #1d4f8c; --bs-btn-hover-border-color: #1d4f8c;
    --bs-btn-active-bg: #12355b; --bs-btn-active-border-color: #12355b;
}
.text-bg-primary { background-color: #1d4f8c !important; }
.text-primary { color: #1d4f8c !important; }

.skip-link { position: absolute; top: .5rem; left: .5rem; z-index: 2000; background: #fff; padding: .5rem 1rem; border-radius: .375rem; }

:focus-visible { outline: 3px solid #f2b705; outline-offset: 2px; }

/* --- Autenticación --- */
.auth-body {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--app-primary-dark) 0%, var(--app-primary) 55%, #1d4f8c 100%);
}
.auth-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem 1rem; }
.auth-card { width: 100%; max-width: 440px; border-radius: 1rem; }
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 56px; height: 56px; border-radius: 50%;
    background: rgba(29, 79, 140, .1); color: #1d4f8c; font-size: 1.6rem;
}
.otp-input { font-size: 2rem; letter-spacing: .6rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* --- Panel --- */
.app-topbar { background-color: var(--app-primary); border-bottom: 3px solid var(--app-accent); min-height: 56px; }
.app-shell { display: flex; min-height: calc(100vh - 56px); }
.app-content { flex: 1 1 auto; min-width: 0; }
.app-content:focus { outline: none; }

@media (min-width: 992px) {
    .app-sidebar {
        width: var(--app-sidebar-width); flex-shrink: 0; background: #fff;
        border-right: 1px solid #e3e7ed; position: sticky; top: 56px; height: calc(100vh - 56px);
    }
}
.app-nav-link {
    display: flex; align-items: center; gap: .75rem;
    color: #3b4656; padding: .65rem 1.25rem; border-left: 3px solid transparent;
}
.app-nav-link:hover { background: #f1f4f9; color: var(--app-primary); }
.app-nav-link.active { background: #e8eef7; color: var(--app-primary); border-left-color: var(--app-accent); font-weight: 600; }
.app-nav-link .bi { font-size: 1.1rem; }

.stat-card .bi { opacity: .9; }
.info-list dt { font-weight: 600; color: #5b6676; }
.info-list dd { margin-bottom: .5rem; }
.app-table th { white-space: nowrap; font-size: .85rem; text-transform: uppercase; letter-spacing: .02em; color: #5b6676; }
.ua-cell { max-width: 260px; }

.btn[data-loading].is-loading { pointer-events: none; opacity: .75; }

/* --- Menú lateral: grupos y modo contraído --- */
.app-nav-group { width: 100%; background: none; border-top: 0; border-right: 0; border-bottom: 0; text-align: start; }
.app-nav-group.has-active { color: var(--app-primary); font-weight: 600; }
.app-nav-caret { font-size: .8rem !important; transition: transform .2s ease; }
.app-nav-group:not(.collapsed) .app-nav-caret { transform: rotate(180deg); }
.app-nav-sub { padding-bottom: .25rem; }
.app-nav-sublink { padding-left: 2.75rem; font-size: .95rem; }
.app-nav-label { white-space: nowrap; }

@media (min-width: 992px) {
    .app-sidebar { transition: width .2s ease; overflow-x: hidden; }
    .sidebar-collapsed .app-sidebar { width: 72px; }
    .sidebar-collapsed .app-sidebar .app-nav-label,
    .sidebar-collapsed .app-sidebar .app-nav-caret,
    .sidebar-collapsed .app-sidebar .app-nav-sub { display: none; }
    .sidebar-collapsed .app-sidebar .app-nav-link { justify-content: center; padding-left: 0; padding-right: 0; }
    .sidebar-collapsed .app-sidebar .app-nav-link .bi { font-size: 1.25rem; }
    .sidebar-collapsed .app-sidebar .app-sidebar-footer { padding-left: .75rem !important; padding-right: .75rem !important; }
}
@media (prefers-reduced-motion: reduce) {
    .app-sidebar, .app-nav-caret { transition: none; }
}

/* --- Formulario de roles: Apartado > Módulo > Permisos --- */
.role-picker { background: #fff; }
.role-picker-col + .role-picker-col { border-top: 1px solid var(--bs-border-color); }
@media (min-width: 768px) {
    .role-picker-col + .role-picker-col { border-top: 0; border-left: 1px solid var(--bs-border-color); }
    .role-picker-col { min-height: 18rem; max-height: 28rem; overflow-y: auto; }
}
.role-picker-head {
    position: sticky; top: 0; z-index: 1;
    background: #f1f4f9; border-bottom: 1px solid var(--bs-border-color);
    padding: .5rem 1rem; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: #3b4656;
}
.role-picker-item { border-left: 3px solid transparent; }
.role-picker .list-group-item.active { background: #e8eef7; color: var(--app-primary); border-color: var(--bs-border-color); border-left-color: var(--app-accent); font-weight: 600; }
.role-picker .active-row { background: #e8eef7; border-left-color: var(--app-accent); }
.role-picker-fallback { padding: .5rem 1rem 0; font-size: .8rem; font-weight: 600; color: #5b6676; }
.role-picker.is-interactive .role-picker-fallback { display: none; }
.icon-preview { width: 3rem; height: calc(1.5em + .75rem + 2px); font-size: 1.25rem !important; }
