/* ============================================================
   HEADER.CSS: BARRA SUPERIOR Y CONTROLES DE NAVEGACIÓN
   SaaS Dark Design System (Zinc / Slate 52px compact header)
   ============================================================ */

.app-header {
  height: 52px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  z-index: 50;
  flex-shrink: 0;
  position: relative;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-badge {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(37, 99, 235, 0.35));
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #60a5fa;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  transition: all var(--transition-fast);
}

.logo-badge:hover {
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.25);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-title {
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: #ffffff;
  margin: 0;
  line-height: 1;
}

.app-subtitle {
  display: none !important; /* Retirado definitivamente según especificación de identidad */
}

.header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  max-width: 500px;
  padding: 0 16px;
}

.file-info-badge {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 4px 12px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  transition: all var(--transition-fast);
  max-width: 100%;
}

.file-info-badge:hover {
  border-color: var(--border-color-hover);
  background: var(--bg-overlay);
}

.file-name {
  font-weight: 500;
  color: var(--text-main);
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.25);
  padding: 2px 7px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Perfil de Usuario y Badge de Rol RBAC */
.user-profile-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  font-size: 0.78rem;
  color: var(--text-muted);
  user-select: none;
}

.user-profile-badge.hidden {
  display: none !important;
}

.user-avatar-icon {
  color: var(--text-dim);
  flex-shrink: 0;
}

.user-display-name {
  font-weight: 500;
  color: var(--text-main);
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 9999px;
  line-height: 1.3;
  text-transform: capitalize;
  white-space: nowrap;
}

.role-badge-superadmin {
  background: rgba(168, 85, 247, 0.12);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.role-badge-admin {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.role-badge-usuario {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Divisor sutil entre perfil y acciones */
.header-actions .user-profile-badge {
  margin-right: 4px;
}

/* Ajustes a botones en el header */
.header-actions .btn {
  height: 32px;
  padding: 0 10px;
  font-size: 0.8rem;
  gap: 6px;
  white-space: nowrap;
}

.header-actions .btn svg {
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .app-header {
    padding: 0 12px;
  }
  .header-actions .btn span {
    display: none;
  }
  .header-actions .btn {
    padding: 0 8px;
  }
  .file-name {
    max-width: 140px;
  }
}

/* ============================================================
   MENÚ LATERAL RETRÁCTIL (OFFCANVAS DRAWER) Y CONTROLES TOPBAR
   ============================================================ */

.btn-hamburger {
  width: 32px;
  height: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
}

.btn-hamburger:hover {
  background: var(--bg-overlay);
  color: #ffffff;
  border-color: var(--border-color-hover);
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

/* Indicador de Estado de Conexión */
.connection-status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 500;
  color: #34d399;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 2px 8px;
  border-radius: 9999px;
  user-select: none;
}

.connection-status-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  background-color: #34d399;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.6);
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* Selector de Páginas en Header (Visor/Corrector) */
.header-page-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 2px 6px;
  border-radius: 6px;
  margin-left: 8px;
}

.header-page-nav button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  transition: all var(--transition-fast);
}

.header-page-nav button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.header-page-nav button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.header-page-nav span {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main);
  padding: 0 4px;
}

/* Backdrop del Drawer */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Contenedor Principal del Menú Retráctil */
.app-sidebar-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 85vw;
  background: #121215;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.7);
}

.app-sidebar-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #18181b;
}

.drawer-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.drawer-avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(37, 99, 235, 0.4));
  border: 1px solid rgba(59, 130, 246, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #60a5fa;
  flex-shrink: 0;
}

.drawer-user-meta {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.drawer-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #71717a;
  padding: 0 10px 6px 10px;
  user-select: none;
}

.drawer-nav-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drawer-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: #a1a1aa;
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.drawer-nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

.drawer-nav-item.active {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-left: 2px solid #3b82f6;
}

.drawer-nav-item svg {
  color: #71717a;
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.drawer-nav-item:hover svg,
.drawer-nav-item.active svg {
  color: #60a5fa;
}

.drawer-footer {
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #141417;
}

.drawer-logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #f87171;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.drawer-logout-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}

/* ============================================================
   BOTÓN LIMPIAR SESIÓN (CABECERA, DRAWER Y PASO 0)
   ============================================================ */
.header-reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  border-color: var(--border-color);
  background: transparent;
  transition: all var(--transition-fast);
}

.header-reset-btn:hover {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}

.header-reset-btn svg {
  color: inherit;
  transition: transform var(--transition-fast);
}

.header-reset-btn:hover svg {
  transform: rotate(-8deg);
}

.drawer-item-danger {
  color: #f87171 !important;
}

.drawer-item-danger svg {
  color: #f87171 !important;
  transition: transform var(--transition-fast);
}

.drawer-item-danger:hover {
  background: rgba(239, 68, 68, 0.12) !important;
  color: #fca5a5 !important;
  border-left: 2px solid #ef4444;
}

.drawer-item-danger:hover svg {
  color: #fca5a5 !important;
  transform: rotate(-8deg);
}

.btn-danger-soft {
  color: #f87171 !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
  background: rgba(239, 68, 68, 0.06) !important;
  transition: all var(--transition-fast);
}

.btn-danger-soft:hover {
  color: #fca5a5 !important;
  border-color: rgba(239, 68, 68, 0.5) !important;
  background: rgba(239, 68, 68, 0.16) !important;
}


