/* ========================================
   Variables — Branding Editora Perú
   ======================================== */
:root {
  --sidebar-width:        240px;
  --navbar-height:        56px;
  --transition-speed:     0.25s;

  --sidebar-bg:           #0F172A;
  --sidebar-text:         #adb5bd;
  --sidebar-text-hover:   #ffffff;
  --sidebar-active-bg:    rgba(255,255,255,0.12);

  --color-brand:          #C8102E;
  --color-primary:        #0A74DA;
  --color-secondary:      #F7B500;
  --color-text:           #111827;
  --color-bg:             #f5f7fa;

  --bs-primary:           #0A74DA;
  --bs-primary-rgb:       10, 116, 218;
}

*, *::before, *::after { box-sizing: border-box; }

body.app-body {
  background: var(--color-bg);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

/* ========================================
   Sidebar
   ======================================== */
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1020;
  transition: transform var(--transition-speed) ease;
}

.app-sidebar.collapsed {
  transform: translateX(-100%);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  height: var(--navbar-height);
  flex-shrink: 0;
}

.sidebar-brand-logo {
  width: 32px;
  height: 32px;
  background: var(--color-brand);
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-brand-text {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.sidebar-nav {
  padding: 0.75rem 0;
  flex: 1;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  padding: 0.625rem 1.25rem;
  color: var(--sidebar-text);
  font-size: 0.875rem;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.sidebar-nav .nav-link:hover {
  background: rgba(255,255,255,0.07);
  color: var(--sidebar-text-hover);
}

.sidebar-nav .nav-link.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  border-left: 3px solid var(--color-primary);
}

.sidebar-link-danger {
  color: #f87171 !important;
}

.sidebar-link-danger:hover {
  background: rgba(248,113,113,0.12) !important;
  color: #fca5a5 !important;
}

.nav-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  padding: 1rem 1.25rem 0.25rem;
  list-style: none;
}

.collapse-arrow {
  margin-left: auto;
  font-size: 0.75rem;
  transition: transform 0.2s;
}
.nav-link[aria-expanded="true"] .collapse-arrow {
  transform: rotate(180deg);
}

.sidebar-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

/* ========================================
   Main area
   ======================================== */
.app-main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-speed) ease;
}

body.sidebar-collapsed .app-main {
  margin-left: 0;
}

.app-navbar {
  position: sticky;
  top: 0;
  z-index: 1010;
  height: var(--navbar-height);
  background: linear-gradient(135deg, #C8102E 0%, #580818 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.app-navbar .breadcrumb         { align-items: center; margin: 0; }
.app-navbar .breadcrumb-item   { display: flex; align-items: center; line-height: 1; }
.app-navbar .breadcrumb-item + .breadcrumb-item::before { color: rgba(255,255,255,0.4); }
.app-navbar .breadcrumb-item a,
.app-navbar .breadcrumb-item.active { color: rgba(255,255,255,0.8); font-size: 0.85rem; text-decoration: none; }
.app-navbar .breadcrumb-item a:hover { color: #fff; }

.sidebar-toggle { color: #fff !important; }
.sidebar-toggle:hover { background: rgba(255,255,255,0.1) !important; border-radius: 0.375rem; }

.app-navbar .dropdown-toggle,
.app-navbar .btn-link { color: #fff !important; }

.app-content {
  flex: 1;
  padding: 1.75rem 1.5rem;
}

/* ========================================
   Modales
   ======================================== */
.modal-content {
  border: none;
  border-radius: 0.875rem;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
}

.modal-header {
  background: linear-gradient(135deg, #C8102E 0%, #580818 100%);
  color: #fff;
  padding: 1rem 1.25rem;
  border-bottom: none;
}

.modal-header .modal-title,
.modal-header .btn-close { color: #fff; }
.modal-header .btn-close { filter: invert(1) brightness(2); opacity: 0.8; }
.modal-header .btn-close:hover { opacity: 1; }

.modal-body { background: #fff; padding: 1.5rem 1.25rem; }
.modal-footer { background: #f8fafc; border-top: 1px solid #e9ecef; padding: 0.875rem 1.25rem; }

/* ========================================
   Tablas
   ======================================== */
.table > :not(caption) > * > th {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
}

/* ========================================
   Focus visible (WCAG)
   ======================================== */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 767.98px) {
  .app-sidebar {
    transform: translateX(-100%);
    z-index: 1040;
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
  }

  .app-sidebar.mobile-open {
    transform: translateX(0);
  }

  .app-main,
  body.sidebar-collapsed .app-main {
    margin-left: 0;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1039;
  }

  .sidebar-overlay.visible { display: block; }

  .app-content { padding: 1rem; }
}

/* ========================================
   Layout Mega Menú
   ======================================== */
.app-main-full {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.mega-menu-overlay {
  position: fixed;
  inset: 0;
  top: var(--navbar-height);
  background: rgba(0,0,0,0.25);
  z-index: 1008;
  display: none;
}

.mega-menu-overlay.visible { display: block; }

.mega-menu-panel {
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  right: 0;
  background: #fff;
  border-top: 3px solid var(--color-brand);
  box-shadow: 0 8px 32px rgba(0,0,0,0.13);
  z-index: 1009;
  display: none;
  max-height: calc(100vh - var(--navbar-height) - 1rem);
  overflow-y: auto;
}

.mega-menu-panel.open { display: block; }

.mega-menu-group-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--color-brand);
  display: flex;
  align-items: center;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 0.625rem;
}

.mega-menu-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.25rem;
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.875rem;
  border-radius: 0.25rem;
  transition: color 0.15s, background 0.15s;
}

.mega-menu-link:hover {
  color: var(--color-primary);
  background: rgba(10,116,218,0.06);
  padding-left: 0.5rem;
}


/* ── Módulo Usuarios ──────────────────────────────────────── */
.usuario-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; flex-shrink: 0;
}
.avatar-activo   { background: #fde8eb; color: #C8102E; }
.avatar-inactivo { background: #f1f5f9; color: #94a3b8; }

/* ── Cabecera de sección (card-header) ──────────────────────────────────
   Slate de marca + línea roja Editora. Uso: <div class="card-header sec-header">.
   Mismo estilo que las secciones de NotSolicitudAccesoPublico/Nueva y PortalPago. */
.sec-header {
  background: linear-gradient(135deg, #1e2a3a 0%, #2c3e55 100%);
  border-bottom: 3px solid var(--color-brand, #C8102E);
  color: #fff;
  padding-top: .75rem; padding-bottom: .75rem;
}
.sec-header .text-muted { color: #cbd5e1 !important; }
.sec-header .pg-sub     { color: #cbd5e1; }
.sec-header .badge.bg-secondary { background: var(--color-brand, #C8102E) !important; }
.sec-header .btn-outline-secondary { color: #fff; border-color: rgba(255,255,255,.55); }
.sec-header .btn-outline-secondary:hover,
.sec-header .btn-outline-secondary:focus { color: #1e2a3a; background: #fff; border-color: #fff; }

/* ── Compatibilidad con Bootstrap 5.3 ──────────────────────────────────
   El sitio carga Bootstrap 5.1, que no trae las utilidades *-subtle ni *-emphasis
   (fondos suaves y textos oscuros de los distintivos de estado). Sin ellas el
   distintivo queda con letra blanca sobre fondo transparente. Valores de Bootstrap 5.3. */
.bg-primary-subtle   { background-color: #cfe2ff !important; }
.bg-secondary-subtle { background-color: #e2e3e5 !important; }
.bg-success-subtle   { background-color: #d1e7dd !important; }
.bg-danger-subtle    { background-color: #f8d7da !important; }
.bg-warning-subtle   { background-color: #fff3cd !important; }
.bg-info-subtle      { background-color: #cff4fc !important; }

.border-primary-subtle   { border-color: #9ec5fe !important; }
.border-secondary-subtle { border-color: #c4c8cb !important; }
.border-success-subtle   { border-color: #a3cfbb !important; }
.border-danger-subtle    { border-color: #f1aeb5 !important; }
.border-warning-subtle   { border-color: #ffe69c !important; }
.border-info-subtle      { border-color: #9eeaf9 !important; }

.text-primary-emphasis   { color: #052c65 !important; }
.text-secondary-emphasis { color: #2b2f32 !important; }
.text-success-emphasis   { color: #0a3622 !important; }
.text-danger-emphasis    { color: #58151c !important; }
.text-warning-emphasis   { color: #664d03 !important; }
.text-info-emphasis      { color: #055160 !important; }

/* Permite truncar textos largos dentro de un flex */
.min-w-0 { min-width: 0; }

