/* ===================================
   THEME SYSTEM - DARK/LIGHT MODE
   Toggle entre modos oscuro y claro
   =================================== */

/* ============ VARIABLES BASE ============ */

:root {
  /* Dimensiones del Sistema */
  --sidebar-width: 260px;
  --sidebar-width-collapsed: 70px;
  --header-height: 64px;
  --spacing-unit: 4px;

  /* Espaciado */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;
  --space-4xl: 64px;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --radius-3xl: 24px;
  --radius-full: 9999px;

  /* Transiciones */
  --transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-theme: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-Index */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-sidebar: 500;
  --z-header: 600;
  --z-modal: 1000;
  --z-tooltip: 1100;
  --z-theme-toggle: 1200;

  /* Fuentes */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", sans-serif;
  --font-mono: "Monaco", "Consolas", "Courier New", monospace;

  /* Line Heights */
  --lh-tight: 1.25;
  --lh-normal: 1.5;
  --lh-relaxed: 1.75;

  /* Font Weights */
  --fw-light: 300;
  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-extrabold: 800;
}

/* ============ DARK THEME (DEFAULT) ============ */

:root,
[data-theme="dark"] {
  /* Colores Primarios */
  --color-primary: #3b82f6;
  --color-primary-light: #60a5fa;
  --color-primary-lighter: #93c5fd;
  --color-primary-dark: #2563eb;
  --color-primary-darker: #1d4ed8;
  
  /* Colores Secundarios */
  --color-secondary: #8b5cf6;
  --color-secondary-light: #a78bfa;
  --color-secondary-dark: #7c3aed;
  
  /* Estados */
  --color-success: #22c55e;
  --color-success-light: #4ade80;
  --color-success-dark: #16a34a;
  --color-warning: #f59e0b;
  --color-warning-light: #fbbf24;
  --color-warning-dark: #d97706;
  --color-error: #ef4444;
  --color-error-light: #f87171;
  --color-error-dark: #dc2626;
  --color-info: #0ea5e9;
  --color-info-light: #38bdf8;
  --color-info-dark: #0284c7;

  /* Fondos Dark */
  --bg-body: #0f172a;
  --bg-primary: #1e293b;
  --bg-secondary: #334155;
  --bg-tertiary: #475569;
  --bg-elevated: #1e293b;
  --bg-card: linear-gradient(145deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.98));
  --bg-card-solid: #1e293b;
  --bg-input: #0f172a;
  --bg-hover: rgba(59, 130, 246, 0.1);
  --bg-active: rgba(59, 130, 246, 0.15);
  
  /* Textos Dark */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-muted: #475569;
  --text-accent: #60a5fa;
  --text-on-primary: #ffffff;

  /* Bordes Dark */
  --border-light: rgba(148, 163, 184, 0.15);
  --border-default: rgba(148, 163, 184, 0.25);
  --border-strong: rgba(148, 163, 184, 0.4);
  --border-focus: rgba(59, 130, 246, 0.5);

  /* Sombras Dark */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);
  --shadow-2xl: 0 24px 64px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.3);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 1px rgba(148, 163, 184, 0.1);

  /* Gradientes Dark */
  --gradient-brand: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  --gradient-success: linear-gradient(135deg, #22c55e 0%, #4ade80 100%);
  --gradient-danger: linear-gradient(135deg, #ef4444 0%, #f87171 100%);
  --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
  --gradient-sidebar: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);

  /* Overlay */
  --overlay: rgba(0, 0, 0, 0.6);
  --overlay-light: rgba(0, 0, 0, 0.3);

  /* Scrollbar */
  --scrollbar-track: transparent;
  --scrollbar-thumb: rgba(148, 163, 184, 0.3);
  --scrollbar-thumb-hover: rgba(148, 163, 184, 0.5);
}

/* ============ LIGHT THEME ============ */

[data-theme="light"] {
  /* Colores Primarios */
  --color-primary: #2563eb;
  --color-primary-light: #3b82f6;
  --color-primary-lighter: #60a5fa;
  --color-primary-dark: #1d4ed8;
  --color-primary-darker: #1e40af;
  
  /* Colores Secundarios */
  --color-secondary: #7c3aed;
  --color-secondary-light: #8b5cf6;
  --color-secondary-dark: #6d28d9;
  
  /* Estados */
  --color-success: #16a34a;
  --color-success-light: #22c55e;
  --color-success-dark: #15803d;
  --color-warning: #d97706;
  --color-warning-light: #f59e0b;
  --color-warning-dark: #b45309;
  --color-error: #dc2626;
  --color-error-light: #ef4444;
  --color-error-dark: #b91c1c;
  --color-info: #0284c7;
  --color-info-light: #0ea5e9;
  --color-info-dark: #0369a1;

  /* Fondos Light */
  --bg-body: #f8fafc;
  --bg-primary: #ffffff;
  --bg-secondary: #f1f5f9;
  --bg-tertiary: #e2e8f0;
  --bg-elevated: #ffffff;
  --bg-card: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.95));
  --bg-card-solid: #ffffff;
  --bg-input: #ffffff;
  --bg-hover: rgba(37, 99, 235, 0.08);
  --bg-active: rgba(37, 99, 235, 0.12);
  
  /* Textos Light */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --text-muted: #94a3b8;
  --text-accent: #2563eb;
  --text-on-primary: #ffffff;

  /* Bordes Light */
  --border-light: rgba(0, 0, 0, 0.06);
  --border-default: rgba(0, 0, 0, 0.1);
  --border-strong: rgba(0, 0, 0, 0.2);
  --border-focus: rgba(37, 99, 235, 0.5);

  /* Sombras Light */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.12);
  --shadow-2xl: 0 24px 64px rgba(0, 0, 0, 0.15);
  --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.15);
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.08), 0 0 1px rgba(0, 0, 0, 0.1);

  /* Gradientes Light */
  --gradient-brand: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  --gradient-success: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
  --gradient-danger: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  --gradient-warning: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
  --gradient-sidebar: linear-gradient(180deg, #1e293b 0%, #334155 100%);

  /* Overlay */
  --overlay: rgba(0, 0, 0, 0.4);
  --overlay-light: rgba(0, 0, 0, 0.2);

  /* Scrollbar */
  --scrollbar-track: transparent;
  --scrollbar-thumb: rgba(0, 0, 0, 0.2);
  --scrollbar-thumb-hover: rgba(0, 0, 0, 0.35);
}

/* ============ THEME TOGGLE BUTTON ============ */

.theme-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-theme-toggle);
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--gradient-brand);
  color: var(--text-on-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  transition: all var(--transition-base);
  font-size: 1.5rem;
}

.theme-toggle:hover {
  transform: scale(1.1) rotate(15deg);
  box-shadow: var(--shadow-xl), var(--shadow-glow);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  position: absolute;
  transition: all var(--transition-theme);
}

[data-theme="dark"] .theme-toggle .icon-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

[data-theme="dark"] .theme-toggle .icon-moon {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

[data-theme="light"] .theme-toggle .icon-sun {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

[data-theme="light"] .theme-toggle .icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Header Theme Toggle (alternativo) */
.theme-toggle-header {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: all var(--transition-base);
}

.theme-toggle-header:hover {
  background: var(--bg-hover);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ============ BASE STYLES ============ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-primary);
  line-height: var(--lh-normal);
  font-weight: var(--fw-normal);
  overflow-x: hidden;
  min-height: 100vh;
  transition: background-color var(--transition-theme), color var(--transition-theme);
}

/* ============ SCROLLBAR ============ */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  background-clip: padding-box;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* ============ TYPOGRAPHY ============ */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  color: var(--text-primary);
  transition: color var(--transition-theme);
}

h1 { font-size: 2rem; letter-spacing: -0.02em; }
h2 { font-size: 1.75rem; letter-spacing: -0.015em; }
h3 { font-size: 1.5rem; letter-spacing: -0.01em; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-light);
}

/* ============ LAYOUT ============ */

.backoffice-layout {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-body);
  transition: background-color var(--transition-theme);
}

/* ============ SIDEBAR ============ */

.backoffice-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--gradient-sidebar);
  border-right: 1px solid var(--border-light);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.3s ease;
}

/* Sidebar Collapsed State */
.backoffice-layout.sidebar-collapsed .backoffice-sidebar {
  width: var(--sidebar-width-collapsed);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.backoffice-layout.sidebar-collapsed .backoffice-main {
  margin-left: var(--sidebar-width-collapsed);
}

.backoffice-layout.sidebar-collapsed .sidebar-brand-text,
.backoffice-layout.sidebar-collapsed .nav-text {
  opacity: 0;
  visibility: hidden;
  width: 0;
  overflow: hidden;
  transition: opacity 0.15s ease, visibility 0s linear 0.15s;
}

.sidebar-brand-text,
.nav-text {
  transition: opacity 0.3s ease 0.1s, visibility 0s linear 0s;
  white-space: nowrap;
}

.backoffice-layout.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: var(--space-md);
  position: relative;
}

/* Tooltips para sidebar colapsado */
.backoffice-layout.sidebar-collapsed .nav-link::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(-8px);
  background: #1e293b;
  color: #e5e7eb;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3),
              0 0 0 1px rgba(59, 130, 246, 0.2);
  z-index: 1000;
}

.backoffice-layout.sidebar-collapsed .nav-link::before {
  content: '';
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 6px 6px 0;
  border-color: transparent #1e293b transparent transparent;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
}

.backoffice-layout.sidebar-collapsed .nav-link:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
}

.backoffice-layout.sidebar-collapsed .nav-link:hover::before {
  opacity: 1;
  visibility: visible;
}

.backoffice-layout.sidebar-collapsed .sidebar-brand {
  justify-content: center;
}

.backoffice-layout.sidebar-collapsed .user-info {
  opacity: 0;
  visibility: hidden;
  width: 0;
  overflow: hidden;
  transition: opacity 0.15s ease, visibility 0s linear 0.15s;
}

.user-info {
  transition: opacity 0.3s ease 0.1s, visibility 0s linear 0s;
}

.sidebar-header {
  padding: var(--space-xl);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.sidebar-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow);
}

.sidebar-icon img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.sidebar-brand-text {
  flex: 1;
}

.sidebar-brand-name {
  font-size: 1.25rem;
  font-weight: var(--fw-bold);
  color: #ffffff;
}

.sidebar-brand-subtitle {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 2px;
}

/* Navegación Sidebar */
.sidebar-nav {
  flex: 1;
  padding: var(--space-lg) 0;
  overflow-y: auto;
}

.nav-group {
  margin-bottom: var(--space-xl);
}

.nav-group-title {
  font-size: 0.7rem;
  font-weight: var(--fw-bold);
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  padding: 0 var(--space-xl);
  margin-bottom: var(--space-sm);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-xl);
  color: rgba(255, 255, 255, 0.7);
  border-left: 3px solid transparent;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  font-size: 0.95rem;
  text-decoration: none;
}

.nav-link::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(59, 130, 246, 0.15) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.nav-link:hover::after {
  opacity: 1;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border-left-color: var(--color-primary-light);
  transform: translateX(2px);
}

.nav-link.active {
  background-color: rgba(59, 130, 246, 0.2);
  color: #ffffff;
  border-left-color: var(--color-primary-light);
  font-weight: var(--fw-semibold);
  box-shadow: inset 0 0 20px rgba(59, 130, 246, 0.1);
}

.nav-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-link:hover .nav-icon {
  transform: scale(1.15) rotate(5deg);
}

.nav-link.active .nav-icon {
  animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

.nav-text {
  flex: 1;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: var(--space-lg);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
  position: relative;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.user-menu:hover {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.user-menu:active {
  transform: scale(0.98);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--fw-bold);
  color: #ffffff;
  font-size: 1rem;
  flex-shrink: 0;
}

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

.user-name {
  font-size: 0.95rem;
  font-weight: var(--fw-semibold);
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.user-menu-icon {
  font-size: 1.25rem;
  color: rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
  transition: all var(--transition-fast);
  transform: rotate(90deg);
}

.user-menu:hover .user-menu-icon {
  color: rgba(255, 255, 255, 0.9);
  transform: rotate(90deg) scale(1.1);
}

.user-dropdown.show ~ .user-menu .user-menu-icon {
  color: var(--color-primary);
}

/* User Dropdown */
.user-dropdown {
  position: absolute;
  bottom: 100%;
  left: var(--space-md);
  right: var(--space-md);
  background: #1e293b;
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-lg);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5), 0 -4px 16px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(59, 130, 246, 0.1);
  padding: var(--space-sm);
  margin-bottom: var(--space-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all var(--transition-fast);
  z-index: 9999;
  backdrop-filter: blur(12px);
  pointer-events: none;
}

.sidebar-footer:hover .user-dropdown,
.user-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  color: #e5e7eb;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  font-size: 0.9rem;
  text-decoration: none;
}

.dropdown-item:hover {
  background: rgba(59, 130, 246, 0.15);
  color: #ffffff;
}

.dropdown-item.dropdown-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
}

.dropdown-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: var(--space-sm) 0;
}

/* ============ MAIN CONTENT ============ */

.backoffice-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============ HEADER ============ */

.backoffice-header {
  height: var(--header-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  padding: 0 var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  transition: all var(--transition-theme);
}

.backoffice-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  flex: 1;
  min-width: 0;
}

.backoffice-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.backoffice-header-title {
  font-size: 1.5rem;
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--transition-theme);
}

/* Sidebar Toggle Button */
#sidebarToggle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

#sidebarToggle::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, var(--color-primary) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
  transform: scale(0);
}

#sidebarToggle:hover::before {
  opacity: 0.15;
  transform: scale(1);
}

#sidebarToggle:hover {
  background: var(--bg-hover);
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

#sidebarToggle:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.15);
}

#sidebarToggle span {
  display: inline-block;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
}

.sidebar-collapsed #sidebarToggle span {
  transform: rotate(180deg);
}

/* Logout Button en Header */
.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  font-size: 0.9rem;
  font-weight: var(--fw-medium);
  color: var(--color-error);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-logout:hover {
  background: var(--color-error);
  color: #ffffff;
  border-color: var(--color-error);
}

/* ============ CONTENT ============ */

.backoffice-content {
  flex: 1;
  padding: var(--space-2xl);
  overflow-y: auto;
  transition: background-color var(--transition-theme);
}

/* ============ FLASH MESSAGES ============ */

.flash-messages {
  padding: 0 var(--space-2xl);
  padding-top: var(--space-lg);
}

.alert {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-md);
  border: 1px solid;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert-success {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: var(--color-success);
}

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--color-error);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--color-warning);
}

.alert-info {
  background: rgba(14, 165, 233, 0.1);
  border-color: rgba(14, 165, 233, 0.3);
  color: var(--color-info);
}

.alert-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

/* ============ CARDS ============ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: all var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  border-color: var(--color-primary);
  transform: translateY(-2px);
}

.card-header {
  padding: var(--space-xl);
  border-bottom: 1px solid var(--border-light);
  background: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .card-header {
  background: rgba(0, 0, 0, 0.02);
}

.card-header h2 {
  font-size: 1.125rem;
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  margin: 0;
}

.card-header p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: var(--space-xs) 0 0 0;
}

.card-body {
  padding: var(--space-xl);
}

/* ============ BUTTONS ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  font-size: 0.9375rem;
  font-weight: var(--fw-medium);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: var(--gradient-brand);
  color: var(--text-on-primary);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-tertiary);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--gradient-danger);
  color: var(--text-on-primary);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
  transform: translateY(-2px);
}

.btn-success {
  background: var(--gradient-success);
  color: var(--text-on-primary);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.btn-success:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4);
  transform: translateY(-2px);
}

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg-hover);
}

.btn-sm {
  padding: var(--space-sm) var(--space-md);
  font-size: 0.875rem;
}

.btn-lg {
  padding: var(--space-lg) var(--space-2xl);
  font-size: 1rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============ FORMS ============ */

.form-group {
  margin-bottom: var(--space-xl);
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
  transition: color var(--transition-theme);
}

.form-control {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--border-focus);
  background: var(--bg-primary);
}

.form-control::placeholder {
  color: var(--text-muted);
}

/* ============ TABLES ============ */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th,
.table td {
  padding: var(--space-lg);
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.table th {
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  background: var(--bg-secondary);
}

.table td {
  color: var(--text-primary);
}

.table tbody tr {
  transition: background-color var(--transition-fast);
}

.table tbody tr:hover {
  background: var(--bg-hover);
}

.table tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

/* ============ BADGES ============ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-xs) var(--space-md);
  font-size: 0.75rem;
  font-weight: var(--fw-semibold);
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--color-success);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-error);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-warning);
}

.badge-info {
  background: rgba(14, 165, 233, 0.15);
  color: var(--color-info);
}

.badge-primary {
  background: rgba(59, 130, 246, 0.15);
  color: var(--color-primary);
}

/* ============ RESPONSIVE ============ */

@media (max-width: 1024px) {
  .backoffice-sidebar {
    margin-left: calc(-1 * var(--sidebar-width));
  }

  .backoffice-sidebar.active {
    margin-left: 0;
  }

  .backoffice-main {
    margin-left: 0;
  }

  .theme-toggle {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }
}

@media (max-width: 768px) {
  .backoffice-content {
    padding: var(--space-lg);
  }

  .backoffice-header {
    padding: 0 var(--space-lg);
  }

  .backoffice-header-title {
    font-size: 1.25rem;
  }
}

/* ============ REDUCE MOTION ============ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
