/* =============================================
   PAP — Rediseño Sidebar + Header
   ============================================= */

/* ---- Variables locales ---- */
:root {
    --pap-sidebar-bg:       #16202e;
    --pap-sidebar-border:   rgba(255,255,255,0.07);
    --pap-sidebar-hover:    rgba(255,255,255,0.06);
    --pap-sidebar-active:   rgba(59,130,246,0.18);
    --pap-sidebar-active-text: #93c5fd;
    --pap-sidebar-text:     #94a3b8;
    --pap-sidebar-muted:    #475569;
    --pap-sidebar-label:    #3d5166;
    --pap-accent:           #3b82f6;
    --pap-header-h:         52px;
}

/* =============================================
   SIDEBAR — estructura base
   ============================================= */
.pap-sidebar.app-sidebar {
    background: var(--pap-sidebar-bg) !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-top: 0 !important;
}

.pap-sidebar .app-sidebar-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ---- Brand — altura fija 60px para alinear con el header ---- */
.pap-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    height: 60px;
    border-bottom: 1px solid var(--pap-sidebar-border);
    flex-shrink: 0;
}

.pap-brand-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    overflow: hidden;
}

/* Logo institucional — filtro a blanco para fondo oscuro */
.pap-brand-img {
    max-height: 34px;
    max-width: 85%;
    width: auto;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.pap-brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--pap-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}

.pap-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
    overflow: hidden;
}

.pap-brand-name {
    font-size: 13px;
    font-weight: 500;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pap-brand-sub {
    font-size: 10px;
    color: var(--pap-sidebar-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ocultar brand cuando sidebar está minificado */
.app-sidebar-minified .pap-brand-text { display: none; }
.app-sidebar-minified .pap-brand-img { max-height: 28px; }
.app-sidebar-minified .pap-sidebar-brand { justify-content: center; padding: 0 6px; }

/* ---- Búsqueda ---- */
.pap-sidebar-search {
    padding: 10px 10px 6px;
    flex-shrink: 0;
}

.pap-search-inner {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 8px;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 7px;
    transition: border-color 0.15s;
}

.pap-search-inner:focus-within {
    border-color: rgba(59,130,246,0.4);
}

.pap-search-inner i {
    font-size: 13px;
    color: var(--pap-sidebar-muted);
    flex-shrink: 0;
}

.pap-search-inner input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--pap-sidebar-text);
    font-size: 12px;
    width: 100%;
    padding: 0;
}

.pap-search-inner input::placeholder {
    color: var(--pap-sidebar-muted);
}

/* Ocultar búsqueda en sidebar minificado */
.app-sidebar-minified .pap-sidebar-search { display: none; }

/* ---- Menú interno ---- */
.pap-sidebar .menu {
    padding: 4px 8px;
}

.pap-sidebar .menu-header {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--pap-sidebar-label);
    padding: 10px 8px 4px;
    text-transform: uppercase;
}

.pap-sidebar .menu-item > .menu-link {
    border-radius: 8px;
    padding: 7px 10px;
    margin-bottom: 1px;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.pap-sidebar .menu-item > .menu-link:hover {
    background: var(--pap-sidebar-hover) !important;
    text-decoration: none;
}

.pap-sidebar .menu-item.active > .menu-link,
.pap-sidebar .menu-item > .menu-link:active {
    background: var(--pap-sidebar-active) !important;
}

.pap-sidebar .menu-item.active > .menu-link .menu-text {
    color: #e2e8f0 !important;
    font-weight: 500;
}

.pap-sidebar .menu-item.active > .menu-link .menu-icon i {
    color: var(--pap-sidebar-active-text) !important;
}

.pap-sidebar .menu-icon {
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pap-sidebar .menu-icon i {
    font-size: 15px;
    color: var(--pap-sidebar-text);
}

.pap-sidebar .menu-text {
    font-size: 13px;
    color: var(--pap-sidebar-text);
    flex: 1;
    line-height: 1.2;
    text-transform: lowercase;
}

.pap-sidebar .menu-text::first-letter {
    text-transform: uppercase;
}

.pap-sidebar .menu-caret {
    color: var(--pap-sidebar-muted);
    font-size: 11px;
    opacity: 0.7;
}

.pap-sidebar .menu-badge {
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    line-height: 1.4;
}

/* Submenu */
.pap-sidebar .menu-submenu {
    padding-left: 18px;
    padding-right: 4px;
}

.pap-sidebar .menu-submenu .menu-item > .menu-link {
    padding: 6px 10px 6px 30px !important;
}

/* Bullet del submenu — separarlo del borde izquierdo del resaltado */
.pap-sidebar .menu-submenu .menu-item::after {
    left: 13px !important;
}

.pap-sidebar .menu-submenu .menu-text {
    font-size: 12.5px;
}

/* Botón minify — mantener al fondo del menú */
.pap-sidebar .menu-item.d-flex {
    margin-top: 4px;
    padding: 0 4px;
}

.pap-sidebar .app-sidebar-minify-btn {
    color: var(--pap-sidebar-muted) !important;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.pap-sidebar .app-sidebar-minify-btn:hover {
    background: var(--pap-sidebar-hover);
    color: var(--pap-sidebar-text) !important;
}

/* ---- Usuario al pie ---- */
.pap-sidebar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--pap-sidebar-border);
    flex-shrink: 0;
}

.pap-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pap-user-avatar i {
    font-size: 13px;
    color: var(--pap-sidebar-text);
}

.pap-user-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.pap-user-name {
    font-size: 12px;
    font-weight: 500;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.pap-user-role {
    font-size: 10px;
    color: var(--pap-sidebar-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.pap-user-logout {
    color: var(--pap-sidebar-muted);
    padding: 4px 6px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.pap-user-logout:hover {
    color: #ef4444 !important;
    background: rgba(239,68,68,0.1);
}

.pap-user-logout i {
    font-size: 14px;
}

/* Ocultar info de usuario en sidebar minificado */
.app-sidebar-minified .pap-user-info,
.app-sidebar-minified .pap-user-logout { display: none; }

.app-sidebar-minified .pap-sidebar-user { justify-content: center; }

/* =============================================
   HEADER — empieza después del sidebar, altura fija
   ============================================= */
#header.pap-header.app-header {
    left: 220px !important;
    background: #fff !important;
    border-bottom: 1px solid #e2e8f0 !important;
    box-shadow: none !important;
    height: 60px !important;
    padding: 0 20px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

/* navbar-header: oculto en desktop, visible en mobile para los togglers */
#header.pap-header .navbar-header {
    display: none !important;
}
@media (max-width: 767px) {
    #header.pap-header.app-header { left: 0 !important; }
    #header.pap-header .navbar-header.pap-mobile-only { display: flex !important; }
}

/* Logo — oculto (ya no se usa en header) */
.pap-header-logo { display: none !important; }

/* Acciones a la derecha */
#header.pap-header .navbar-nav {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 0 8px !important;
    height: 60px !important;
    overflow: visible !important;
}

/* Contener cada navbar-item dentro de los 60px */
#header.pap-header .navbar-nav .navbar-item {
    height: 60px !important;
    display: flex !important;
    align-items: center !important;
    padding: 0 !important;
}

/* El pap-hdr-btn (bell) siempre 34px — especificidad alta */
#header.pap-header .navbar-nav .navbar-item > a.pap-hdr-btn,
#header.pap-header .navbar-nav .navbar-item > .pap-hdr-btn {
    height: 34px !important;
    width: 34px !important;
    min-width: 34px !important;
    padding: 0 !important;
}

/* User link: flex, sin altura fija, centrado */
#header.pap-header .navbar-nav .navbar-item > a.pap-header-user {
    display: flex !important;
    align-items: center !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    height: auto !important;
}

/* Botón notificaciones */
.pap-hdr-btn {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    border-radius: 8px !important;
    border: 1px solid #e2e8f0 !important;
    background: #f8fafc !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    cursor: pointer !important;
    transition: background 0.15s !important;
    color: #64748b !important;
    position: relative !important;
    text-decoration: none !important;
}

.pap-hdr-btn:hover {
    background: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
    color: #334155 !important;
}

.pap-hdr-btn i,
.pap-hdr-btn .fa {
    font-size: 15px !important;
    color: #64748b !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
}

/* Badge */
#header.pap-header .badge {
    top: 4px;
    right: 4px;
    min-width: 16px;
    height: 16px;
    font-size: 9px;
    line-height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    border: 2px solid #fff;
}

/* Usuario en header */
.pap-header-user {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 4px 8px !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    transition: background 0.15s !important;
    text-decoration: none !important;
    color: inherit !important;
    height: auto !important;
    white-space: nowrap;
}

.pap-header-user:hover { background: #f1f5f9; }

/* Avatar — resetear todo lo del template y aplicar mismo estilo que sidebar */
#header.pap-header .navbar-user .image {
    all: unset !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 30px !important;
    height: 30px !important;
    min-width: 30px !important;
    border-radius: 50% !important;
    background: rgba(30, 58, 95, 0.12) !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

#header.pap-header .navbar-user .image i {
    all: unset !important;
    font-family: "Font Awesome 5 Free", "FontAwesome" !important;
    font-weight: 900 !important;
    font-size: 13px !important;
    color: #64748b !important;
    display: block !important;
    line-height: 1 !important;
}

/* Bell icon — mismo reset */
#header.pap-header .pap-hdr-btn .fa-bell {
    all: unset !important;
    font-family: "Font Awesome 5 Free", "FontAwesome" !important;
    font-weight: 900 !important;
    font-size: 14px !important;
    color: #64748b !important;
    display: block !important;
    line-height: 1 !important;
}

/* Badge del bell — mantener position absolute, centrar el texto */
#header.pap-header #notificacion-badge {
    position: absolute !important;
    top: -4px !important;
    right: -4px !important;
    line-height: 16px !important;
    text-align: center !important;
    padding: 0 4px !important;
}

.pap-header-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
    overflow: hidden;
}

.pap-header-user-name {
    font-size: 12px;
    font-weight: 500;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.pap-header-user-role {
    font-size: 10px;
    color: #94a3b8;
    white-space: nowrap;
}

/* Divisor vertical */
.pap-hdr-divider {
    display: inline-block;
    width: 1px;
    height: 20px;
    background: #e2e8f0;
    margin: 0 4px;
    vertical-align: middle;
}

/* Espaciador — no necesario con float layout */
.pap-header-spacer { display: none; }

/* =============================================
   PACE — barra de progreso al borde superior
   ============================================= */
.pace .pace-progress {
    top: 0 !important;
}

/* =============================================
   MODO OSCURO — ajustes header
   ============================================= */
[data-bs-theme="dark"] #header.pap-header.app-header,
.app-header[data-bs-theme="dark"]#header.pap-header {
    background: #1e293b !important;
    border-bottom-color: rgba(255,255,255,0.08) !important;
}

[data-bs-theme="dark"] .pap-sidebar-toggle,
[data-bs-theme="dark"] .pap-hdr-btn {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.1);
    color: #94a3b8;
}

[data-bs-theme="dark"] .pap-sidebar-toggle:hover,
[data-bs-theme="dark"] .pap-hdr-btn:hover {
    background: rgba(255,255,255,0.09);
}

[data-bs-theme="dark"] .pap-header-user:hover {
    background: rgba(255,255,255,0.06);
}

[data-bs-theme="dark"] .pap-header-user-name {
    color: #e2e8f0;
}

[data-bs-theme="dark"] .pap-hdr-divider {
    background: rgba(255,255,255,0.1);
}

[data-bs-theme="dark"] .pap-header-logo {
    filter: brightness(0.9);
}
