/* =========================================================
   SIDEBAR MODERN - Premium Navigation Panel
   Version: 2.0.0
   Features: Glassmorphism, Smooth Animations, Mobile-First
   ========================================================= */

/* === CSS CUSTOM PROPERTIES === */
:root {
  /* Sidebar Colors */
  --sidebar-bg: linear-gradient(180deg, #0a0f1a 0%, #111827 50%, #1a1f2e 100%);
  --sidebar-border: rgba(99, 102, 241, 0.15);
  --sidebar-glow: rgba(99, 102, 241, 0.08);

  /* Nav Link Colors */
  --nav-link-color: rgba(226, 232, 240, 0.75);
  --nav-link-hover-bg: rgba(99, 102, 241, 0.12);
  --nav-link-hover-color: #f1f5f9;
  --nav-link-active-bg: linear-gradient(135deg, rgba(99, 102, 241, 0.25) 0%, rgba(139, 92, 246, 0.18) 100%);
  --nav-link-active-color: #ffffff;
  --nav-link-active-border: linear-gradient(180deg, #6366f1, #8b5cf6);

  /* Group Title */
  --nav-group-color: rgba(148, 163, 184, 0.65);

  /* User Menu */
  --user-menu-bg: rgba(30, 41, 59, 0.6);
  --user-menu-hover-bg: rgba(51, 65, 85, 0.6);

  /* Dropdown */
  --dropdown-bg: linear-gradient(145deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.99));
  --dropdown-border: rgba(99, 102, 241, 0.25);
  --dropdown-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5), 0 -8px 24px rgba(99, 102, 241, 0.15);

  /* Mobile */
  --mobile-overlay-bg: rgba(0, 0, 0, 0.65);

  /* Animations */
  --sidebar-transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --nav-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Light theme adjustments */
[data-theme="light"] {
  --sidebar-bg: linear-gradient(180deg, #1e293b 0%, #334155 50%, #475569 100%);
  --sidebar-border: rgba(99, 102, 241, 0.2);
  --nav-link-color: rgba(241, 245, 249, 0.85);
  --nav-group-color: rgba(203, 213, 225, 0.7);
}

/* === SIDEBAR CONTAINER === */
.backoffice-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width, 260px);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  z-index: var(--z-sidebar, 500);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--sidebar-transition),
              transform var(--sidebar-transition),
              box-shadow var(--sidebar-transition);

  /* Glassmorphism effect */
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);

  /* Premium shadow */
  box-shadow: 4px 0 32px rgba(0, 0, 0, 0.25),
              1px 0 0 var(--sidebar-glow);
}

/* Subtle inner glow */
.backoffice-sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 200px;
  background: radial-gradient(ellipse at top center, rgba(99, 102, 241, 0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* === SIDEBAR HEADER === */
.sidebar-header {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  transition: all var(--nav-transition);
}

.sidebar-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.5rem;
  position: relative;
  overflow: hidden;

  /* Animated glow */
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4),
              0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  transition: all 0.4s var(--bounce);
}

.sidebar-icon::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(255, 255, 255, 0.2) 50%, transparent 100%);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.sidebar-brand:hover .sidebar-icon {
  transform: scale(1.05) rotate(-3deg);
  box-shadow: 0 6px 28px rgba(99, 102, 241, 0.5),
              0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}

.sidebar-brand:hover .sidebar-icon::before {
  opacity: 1;
}

.sidebar-brand-text {
  flex: 1;
  min-width: 0;
  transition: opacity 0.2s ease 0.1s, visibility 0s linear 0s;
}

.sidebar-brand-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, #e2e8f0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-brand-subtitle {
  font-size: 0.7rem;
  color: rgba(148, 163, 184, 0.8);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-top: 2px;
  font-weight: 600;
}

/* === SIDEBAR NAVIGATION === */
.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  z-index: 1;

  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}

.sidebar-nav::-webkit-scrollbar {
  width: 5px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.4), rgba(139, 92, 246, 0.3));
  border-radius: 10px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.6), rgba(139, 92, 246, 0.5));
}

/* === NAV GROUPS === */
.nav-group {
  margin-bottom: 0.5rem;
  padding: 0 0.75rem;
}

.nav-group-title {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--nav-group-color);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 0.75rem 1rem 0.5rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  transition: color var(--nav-transition);
}

.nav-group-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(148, 163, 184, 0.2), transparent);
  margin-left: 0.5rem;
}

/* === NAV LINKS === */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 1rem;
  margin: 0.2rem 0;
  color: var(--nav-link-color);
  text-decoration: none;
  border-radius: 12px;
  position: relative;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--nav-transition);
  overflow: hidden;

  /* Left border indicator */
  border-left: 3px solid transparent;
}

/* Hover glow effect */
.nav-link::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 50%, var(--nav-link-hover-bg), transparent 70%);
  opacity: 0;
  transition: opacity var(--nav-transition);
  pointer-events: none;
}

.nav-link:hover {
  color: var(--nav-link-hover-color);
  background: var(--nav-link-hover-bg);
  border-left-color: rgba(99, 102, 241, 0.5);
  transform: translateX(4px);
}

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

/* Active state */
.nav-link.active {
  background: var(--nav-link-active-bg);
  color: var(--nav-link-active-color);
  border-left-color: #6366f1;
  font-weight: 600;

  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.2),
              inset 0 0 20px rgba(99, 102, 241, 0.05);
}

.nav-link.active::before {
  background: radial-gradient(circle at 30% 50%, rgba(99, 102, 241, 0.15), transparent 70%);
  opacity: 1;
}

/* Active indicator dot */
.nav-link.active::after {
  content: '';
  position: absolute;
  right: 1rem;
  width: 6px;
  height: 6px;
  background: #6366f1;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.8);
  animation: activePulse 2s ease-in-out infinite;
}

@keyframes activePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.2); }
}

/* === NAV ICONS === */
.nav-icon {
  font-size: 1.25rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.3s var(--bounce);
  position: relative;
  z-index: 1;
}

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

.nav-link.active .nav-icon {
  transform: scale(1.1);
}

/* === NAV TEXT === */
.nav-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.2s ease 0.1s, visibility 0s linear 0s;
}

/* === SIDEBAR FOOTER / USER MENU === */
.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem;
  border-radius: 14px;
  background: var(--user-menu-bg);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: all var(--nav-transition);
  border: 1px solid transparent;
}

.user-menu:hover {
  background: var(--user-menu-hover-bg);
  border-color: rgba(99, 102, 241, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

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

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #ffffff;
  font-size: 1rem;
  flex-shrink: 0;
  position: relative;

  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  transition: all 0.3s var(--bounce);
}

/* Online indicator - SOLO para el avatar del sidebar del usuario logueado */
.user-menu .user-avatar::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border-radius: 50%;
  border: 2px solid #0a0f1a;
  box-shadow: 0 2px 4px rgba(34, 197, 94, 0.4);
}

.user-menu:hover .user-avatar {
  transform: scale(1.05);
}

.user-info {
  flex: 1;
  min-width: 0;
  transition: opacity 0.2s ease 0.1s, visibility 0s linear 0s;
}

.user-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.user-role {
  font-size: 0.7rem;
  color: rgba(148, 163, 184, 0.8);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

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

.user-menu:hover .user-menu-icon {
  color: #94a3b8;
  transform: rotate(90deg) scale(1.1);
}

/* === USER DROPDOWN === */
.user-dropdown {
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 0.75rem;
  right: 0.75rem;
  background: var(--dropdown-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--dropdown-border);
  border-radius: 16px;
  padding: 0.5rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.95);
  transition: all 0.25s var(--bounce);
  z-index: 100;

  box-shadow: var(--dropdown-shadow);
  pointer-events: none;
}

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

/* Dropdown arrow */
.user-dropdown::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: rgba(30, 41, 59, 0.98);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
  color: rgba(226, 232, 240, 0.9);
  text-decoration: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--nav-transition);
  position: relative;
  overflow: hidden;
}

.dropdown-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: linear-gradient(180deg, #6366f1, #8b5cf6);
  border-radius: 0 4px 4px 0;
  transition: height var(--nav-transition);
}

.dropdown-item:hover {
  background: rgba(99, 102, 241, 0.12);
  color: #ffffff;
  transform: translateX(4px);
}

.dropdown-item:hover::before {
  height: 60%;
}

.dropdown-item.dropdown-danger {
  color: rgba(248, 113, 113, 0.9);
}

.dropdown-item.dropdown-danger:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
}

.dropdown-item.dropdown-danger:hover::before {
  background: linear-gradient(180deg, #ef4444, #dc2626);
}

.dropdown-icon {
  font-size: 1.15rem;
  width: 28px;
  text-align: center;
  transition: transform 0.3s var(--bounce);
}

.dropdown-item:hover .dropdown-icon {
  transform: scale(1.15);
}

.dropdown-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(148, 163, 184, 0.2), transparent);
  margin: 0.5rem 0.5rem;
}

/* === COLLAPSED STATE === */
.backoffice-layout.sidebar-collapsed .backoffice-sidebar {
  width: var(--sidebar-width-collapsed, 70px);
  box-shadow: 2px 0 16px rgba(0, 0, 0, 0.15);
}

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

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

.backoffice-layout.sidebar-collapsed .sidebar-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
}

.backoffice-layout.sidebar-collapsed .nav-group {
  padding: 0 0.5rem;
}

.backoffice-layout.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: 0.875rem;
  margin: 0.25rem 0;
  border-radius: 12px;
  border-left: none;
  position: relative;
}

.backoffice-layout.sidebar-collapsed .nav-link.active::after {
  display: none;
}

.backoffice-layout.sidebar-collapsed .nav-link:hover {
  transform: scale(1.05);
}

.backoffice-layout.sidebar-collapsed .nav-icon {
  width: 24px;
  height: 24px;
  font-size: 1.3rem;
}

/* Collapsed tooltips */
.backoffice-layout.sidebar-collapsed .nav-link[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 16px);
  top: 50%;
  transform: translateY(-50%) translateX(-8px);
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #f1f5f9;
  padding: 0.625rem 1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.2s var(--bounce);
  z-index: 1000;

  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3),
              0 0 0 1px rgba(99, 102, 241, 0.2);
}

.backoffice-layout.sidebar-collapsed .nav-link[data-tooltip]::before {
  content: '';
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: #1e293b;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s var(--bounce);
  z-index: 1000;
}

.backoffice-layout.sidebar-collapsed .nav-link:hover[data-tooltip]::after,
.backoffice-layout.sidebar-collapsed .nav-link:hover[data-tooltip]::before {
  opacity: 1;
  visibility: visible;
}

.backoffice-layout.sidebar-collapsed .nav-link:hover[data-tooltip]::after {
  transform: translateY(-50%) translateX(0);
}

/* Collapsed user menu */
.backoffice-layout.sidebar-collapsed .user-menu {
  justify-content: center;
  padding: 0.75rem;
}

.backoffice-layout.sidebar-collapsed .user-avatar {
  width: 38px;
  height: 38px;
  font-size: 0.9rem;
}

.backoffice-layout.sidebar-collapsed .sidebar-footer {
  padding: 0.75rem;
}

.backoffice-layout.sidebar-collapsed .user-dropdown {
  left: calc(100% + 12px);
  right: auto;
  bottom: 0;
  width: 220px;
  transform: translateX(-12px) scale(0.95);
}

.backoffice-layout.sidebar-collapsed .user-dropdown.show {
  transform: translateX(0) scale(1);
}

.backoffice-layout.sidebar-collapsed .user-dropdown::after {
  bottom: 1.5rem;
  left: -8px;
  right: auto;
  border: 8px solid transparent;
  border-right-color: rgba(30, 41, 59, 0.98);
  transform: none;
}

/* === MOBILE OVERLAY === */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: var(--mobile-overlay-bg);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: calc(var(--z-sidebar, 500) - 1);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* === RESPONSIVE - TABLET === */
@media (max-width: 1024px) {
  .backoffice-sidebar {
    width: 280px;
    transform: translateX(-100%);
    box-shadow: none;
    position: fixed;
    z-index: 1000;
    will-change: transform;
  }

  .backoffice-sidebar.active {
    transform: translateX(0);
    box-shadow: 8px 0 48px rgba(0, 0, 0, 0.5);
  }

  /* Disable collapsed state on tablet/mobile */
  .backoffice-layout.sidebar-collapsed .backoffice-sidebar {
    width: 280px !important;
    transform: translateX(-100%) !important;
  }

  .backoffice-layout.sidebar-collapsed .backoffice-sidebar.active {
    transform: translateX(0) !important;
  }

  .backoffice-layout.sidebar-collapsed .sidebar-brand-text,
  .backoffice-layout.sidebar-collapsed .nav-text,
  .backoffice-layout.sidebar-collapsed .nav-group-title,
  .backoffice-layout.sidebar-collapsed .user-info,
  .backoffice-layout.sidebar-collapsed .user-menu-icon {
    opacity: 1 !important;
    visibility: visible !important;
    width: auto !important;
    overflow: visible !important;
  }

  .backoffice-layout.sidebar-collapsed .nav-link {
    justify-content: flex-start !important;
    padding: 0.75rem 1rem !important;
    border-left: 3px solid transparent !important;
  }

  .backoffice-layout.sidebar-collapsed .nav-link[data-tooltip]::after,
  .backoffice-layout.sidebar-collapsed .nav-link[data-tooltip]::before {
    display: none !important;
  }

  .backoffice-layout.sidebar-collapsed .user-dropdown {
    left: 0.75rem !important;
    right: 0.75rem !important;
    bottom: calc(100% + 0.5rem) !important;
    width: auto !important;
  }

  .backoffice-layout.sidebar-collapsed .user-dropdown::after {
    bottom: -8px !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    border: 8px solid transparent !important;
    border-top-color: rgba(30, 41, 59, 0.98) !important;
  }
}

/* === RESPONSIVE - MOBILE === */
@media (max-width: 768px) {
  .backoffice-sidebar {
    width: 85vw;
    max-width: 320px;
  }

  .sidebar-header {
    padding: 1rem;
  }

  .sidebar-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    font-size: 1.35rem;
  }

  .sidebar-brand-name {
    font-size: 1.1rem;
  }

  .nav-group {
    padding: 0 0.5rem;
  }

  .nav-link {
    padding: 0.875rem 1rem;
    border-radius: 10px;
    font-size: 0.95rem;
    min-height: 48px;
  }

  .nav-icon {
    font-size: 1.3rem;
    width: 32px;
    height: 32px;
  }

  .sidebar-footer {
    padding: 0.875rem;
  }

  .user-menu {
    padding: 0.75rem;
    border-radius: 12px;
    min-height: 56px;
  }

  .user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 0.95rem;
  }

  .user-name {
    font-size: 0.9rem;
  }

  .user-dropdown {
    left: 0.5rem;
    right: 0.5rem;
    border-radius: 14px;
  }

  .dropdown-item {
    padding: 0.75rem 0.875rem;
    font-size: 0.9rem;
    min-height: 48px;
  }
}

/* === RESPONSIVE - SMALL MOBILE === */
@media (max-width: 480px) {
  .backoffice-sidebar {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
  }

  .sidebar-header {
    padding: 0.875rem;
  }

  .sidebar-icon {
    width: 38px;
    height: 38px;
    font-size: 1.25rem;
  }

  .sidebar-brand-name {
    font-size: 1rem;
  }

  .sidebar-brand-subtitle {
    font-size: 0.65rem;
  }

  .nav-link {
    padding: 0.75rem 0.875rem;
    font-size: 0.9rem;
  }

  .nav-icon {
    font-size: 1.2rem;
    width: 28px;
    height: 28px;
  }

  .user-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
  }

  .user-name {
    font-size: 0.85rem;
  }

  .user-role {
    font-size: 0.65rem;
  }
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
  .backoffice-sidebar,
  .nav-link,
  .user-menu,
  .user-dropdown,
  .dropdown-item,
  .sidebar-icon,
  .nav-icon {
    transition-duration: 0.01ms !important;
  }

  @keyframes activePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
  }
}

/* === SIDEBAR TOGGLE BUTTON ENHANCED === */
#sidebarToggle {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border-default, rgba(148, 163, 184, 0.25));
  background: var(--bg-secondary, #334155);
  color: var(--text-primary, #f1f5f9);
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: all 0.3s var(--bounce);
  padding: 0;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

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

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

#sidebarToggle:hover {
  background: var(--bg-hover, rgba(59, 130, 246, 0.1));
  border-color: #6366f1;
  color: #6366f1;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.25);
}

#sidebarToggle:active {
  transform: translateY(0) scale(0.95);
}

#sidebarToggle span {
  display: inline-block;
  transition: transform 0.35s var(--bounce);
  z-index: 1;
}

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

/* === MOBILE OVERLAY === */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: var(--mobile-overlay-bg);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: calc(var(--z-sidebar, 500) - 1);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* === REGLAS CON MÁXIMA ESPECIFICIDAD PARA MÓVIL === */
@media (max-width: 1024px) {
  /* Sidebar cerrado - MÁXIMA ESPECIFICIDAD */
  html[data-theme] body .backoffice-layout .backoffice-sidebar:not(.active),
  html[data-theme] body .backoffice-layout.sidebar-collapsed .backoffice-sidebar:not(.active) {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    width: 280px !important;
    height: 100vh !important;
    z-index: 1000 !important;
    transform: translateX(-100%) !important;
    -webkit-transform: translateX(-100%) !important;
    -moz-transform: translateX(-100%) !important;
    -ms-transform: translateX(-100%) !important;
    will-change: transform !important;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }

  /* Sidebar abierto - MÁXIMA ESPECIFICIDAD */
  html[data-theme] body .backoffice-layout .backoffice-sidebar.active,
  html[data-theme] body .backoffice-layout.sidebar-collapsed .backoffice-sidebar.active {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    width: 280px !important;
    height: 100vh !important;
    z-index: 1000 !important;
    transform: translateX(0) !important;
    -webkit-transform: translateX(0) !important;
    -moz-transform: translateX(0) !important;
    -ms-transform: translateX(0) !important;
    visibility: visible !important;
    opacity: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    pointer-events: auto !important;
    will-change: transform !important;
    box-shadow: 8px 0 48px rgba(0, 0, 0, 0.5) !important;
  }

  /* Overlay cerrado */
  html[data-theme] body .sidebar-overlay:not(.active) {
    position: fixed !important;
    inset: 0 !important;
    z-index: 999 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    background: rgba(0, 0, 0, 0.7) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
    transition: opacity 0.3s ease, visibility 0.3s ease !important;
  }

  /* Overlay abierto */
  html[data-theme] body .sidebar-overlay.active {
    position: fixed !important;
    inset: 0 !important;
    z-index: 999 !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    background: rgba(0, 0, 0, 0.7) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
  }

  /* Body cuando sidebar está activo */
  html[data-theme] body.sidebar-active {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
  }
}

/* === PRINT STYLES === */
@media print {
  .backoffice-sidebar,
  .sidebar-overlay {
    display: none !important;
  }
}
