/**
 * CRM-style sidebar for Betzetu Admin
 */
body.theme-tabler {
  --crm-sidebar-width: 17.5rem;
  --crm-sidebar-bg: #0f172a;
  --crm-sidebar-bg-elevated: #1e293b;
  --crm-sidebar-border: rgba(148, 163, 184, 0.12);
  --crm-sidebar-text: #cbd5e1;
  --crm-sidebar-text-muted: #64748b;
  --crm-sidebar-accent: #3b82f6;
  --crm-sidebar-accent-soft: rgba(59, 130, 246, 0.14);
  --crm-sidebar-hover: rgba(255, 255, 255, 0.06);
  --betzetu-sidebar-width: var(--crm-sidebar-width);
}

body.theme-tabler #sidebar.crm-sidebar {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  bottom: 0 !important;
  width: var(--crm-sidebar-width) !important;
  max-width: var(--crm-sidebar-width) !important;
  height: 100vh !important;
  z-index: 1030;
  background: linear-gradient(180deg, var(--crm-sidebar-bg) 0%, #111827 100%);
  border-right: 1px solid var(--crm-sidebar-border);
  box-shadow: 4px 0 24px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  padding: 0;
}

body.theme-tabler .crm-sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

/* Brand */
body.theme-tabler .crm-sidebar-brand {
  padding: 1.25rem 1.125rem 1rem;
  border-bottom: 1px solid var(--crm-sidebar-border);
  flex-shrink: 0;
}

body.theme-tabler .crm-sidebar-brand a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

body.theme-tabler .crm-sidebar-brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  padding: 4px;
}

body.theme-tabler .crm-brand-name {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

body.theme-tabler .crm-brand-tag {
  display: block;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--crm-sidebar-text-muted);
  margin-top: 2px;
  letter-spacing: 0.02em;
}

/* Scrollable nav */
body.theme-tabler .crm-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem 0.75rem 1rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}

body.theme-tabler .crm-sidebar-nav::-webkit-scrollbar {
  width: 5px;
}

body.theme-tabler .crm-sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 4px;
}

body.theme-tabler .crm-nav-group {
  margin-bottom: 1.125rem;
}

body.theme-tabler .crm-nav-group:last-child {
  margin-bottom: 0;
}

body.theme-tabler .crm-nav-label {
  padding: 0 0.625rem 0.5rem;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--crm-sidebar-text-muted);
  user-select: none;
}

/* Nav links */
body.theme-tabler .crm-nav-link.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  margin-bottom: 2px;
  border-radius: 10px;
  color: var(--crm-sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  position: relative;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

body.theme-tabler .crm-nav-link.nav-item:hover {
  background: var(--crm-sidebar-hover);
  color: #f1f5f9;
}

body.theme-tabler .crm-nav-link.nav-item.active {
  background: var(--crm-sidebar-accent-soft);
  color: #fff;
  font-weight: 600;
}

body.theme-tabler .crm-nav-link.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  min-height: 18px;
  border-radius: 0 4px 4px 0;
  background: var(--crm-sidebar-accent);
}

body.theme-tabler .crm-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #94a3b8;
  flex-shrink: 0;
  font-size: 1.05rem;
  transition: background 0.15s ease, color 0.15s ease;
}

body.theme-tabler .crm-nav-link.nav-item:hover .crm-nav-icon {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}

body.theme-tabler .crm-nav-link.nav-item.active .crm-nav-icon {
  background: rgba(59, 130, 246, 0.22);
  color: #93c5fd;
}

body.theme-tabler .crm-nav-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.theme-tabler .crm-nav-badge:empty {
  display: none !important;
}

body.theme-tabler .crm-nav-badge {
  flex-shrink: 0;
  min-width: 1.375rem;
  height: 1.375rem;
  padding: 0 0.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 700;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

body.theme-tabler .crm-nav-link.nav-item.active .crm-nav-badge {
  background: rgba(59, 130, 246, 0.35);
  color: #fff;
}

body.theme-tabler .crm-nav-badge.crm-nav-badge-alert {
  background: rgba(239, 68, 68, 0.22);
  color: #fecaca;
}

body.theme-tabler .crm-nav-badge.notification-badge {
  background: rgba(245, 158, 11, 0.25);
  color: #fde68a;
}

/* Footer */
body.theme-tabler .crm-sidebar-footer {
  flex-shrink: 0;
  padding: 0.875rem 1rem 1rem;
  border-top: 1px solid var(--crm-sidebar-border);
  background: rgba(0, 0, 0, 0.15);
}

body.theme-tabler .crm-sidebar-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--crm-sidebar-text-muted);
  margin-bottom: 0.625rem;
}

body.theme-tabler .crm-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
  flex-shrink: 0;
}

body.theme-tabler .crm-sidebar-quick {
  display: flex;
  gap: 0.5rem;
}

body.theme-tabler .crm-sidebar-quick .btn {
  flex: 1;
  font-size: 0.75rem;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
}

body.theme-tabler .crm-sidebar-quick .btn-outline-crm {
  color: var(--crm-sidebar-text);
  border: 1px solid var(--crm-sidebar-border);
  background: transparent;
}

body.theme-tabler .crm-sidebar-quick .btn-outline-crm:hover {
  background: var(--crm-sidebar-hover);
  color: #fff;
}

/* Mobile overlay */
body.theme-tabler .crm-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1025;
  backdrop-filter: blur(2px);
}

body.theme-tabler .crm-sidebar-overlay.visible {
  display: block;
}

@media (max-width: 991.98px) {
  body.theme-tabler #sidebar.crm-sidebar {
    transform: translateX(-105%);
    transition: transform 0.22s ease;
  }

  body.theme-tabler #sidebar.crm-sidebar.open,
  body.theme-tabler #sidebar.crm-sidebar.mobile-open {
    transform: translateX(0);
  }
}
