/* =============================================================================
   SIDEBAR NAVIGATION — v5.0
   ============================================================================= */

:root {
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 64px;
  --sidebar-bg: #F2EEE3;
  --sidebar-text: #6B6360;
  --sidebar-text-hover: #2B2523;
  --sidebar-active-bg: rgba(184, 92, 58, 0.10);
  --sidebar-active-text: #B85C3A;
  --sidebar-active-border: #B85C3A;
  --sidebar-section-text: #918A85;
  --sidebar-divider: rgba(43, 37, 35, 0.08);
  --sidebar-transition: 0.2s ease;
}

/* ----------------------------------------
   LAYOUT
   ---------------------------------------- */

.ops-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 900;
  transition: width var(--sidebar-transition);
  overflow: hidden;
}

.ops-main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left var(--sidebar-transition);
  padding: 24px 32px;
}

.ops-sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.ops-sidebar.collapsed ~ .ops-main {
  margin-left: var(--sidebar-collapsed-width);
}

/* ----------------------------------------
   BRAND
   ---------------------------------------- */

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--sidebar-divider);
  min-height: 64px;
}

.sidebar-brand-mark {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.sidebar-brand-text {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: #2B2523;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--sidebar-transition);
}

.sidebar-brand-text span {
  display: block;
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  font-size: 11px;
  color: var(--sidebar-section-text);
  margin-top: 2px;
}

.ops-sidebar.collapsed .sidebar-brand-text {
  opacity: 0;
  width: 0;
}

/* ----------------------------------------
   TOGGLE BUTTON
   ---------------------------------------- */

.sidebar-toggle {
  position: absolute;
  top: 22px;
  right: -12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--sidebar-divider);
  color: var(--sidebar-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: transform var(--sidebar-transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.sidebar-toggle:hover {
  color: var(--sidebar-text-hover);
}

.sidebar-toggle svg {
  width: 14px;
  height: 14px;
}

.ops-sidebar.collapsed .sidebar-toggle {
  transform: rotate(180deg);
}

/* ----------------------------------------
   NAVIGATION
   ---------------------------------------- */

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
}

.sidebar-section {
  margin-bottom: 4px;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  cursor: pointer;
  user-select: none;
}

.sidebar-section-label {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-section-text);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--sidebar-transition);
}

.sidebar-section-chevron {
  width: 14px;
  height: 14px;
  color: var(--sidebar-section-text);
  flex-shrink: 0;
  transition: transform 0.15s ease, opacity var(--sidebar-transition);
}

.sidebar-section.section-collapsed .sidebar-section-chevron {
  transform: rotate(-90deg);
}

.sidebar-section-items {
  overflow: hidden;
  max-height: 1000px;
  transition: max-height 0.3s ease;
}

.sidebar-section.section-collapsed .sidebar-section-items {
  max-height: 0;
}

/* Collapsed sidebar: hide labels and chevrons */
.ops-sidebar.collapsed .sidebar-section-label {
  opacity: 0;
}

.ops-sidebar.collapsed .sidebar-section-chevron {
  opacity: 0;
}

.ops-sidebar.collapsed .sidebar-section-header {
  pointer-events: none;
  padding: 4px 0;
}

/* ----------------------------------------
   NAV ITEMS
   ---------------------------------------- */

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 16px;
  border: none;
  background: none;
  color: var(--sidebar-text);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  border-left: 3px solid transparent;
  transition: all 0.12s ease;
  white-space: nowrap;
  position: relative;
}

.sidebar-nav-item:hover {
  color: var(--sidebar-text-hover);
  background: rgba(43, 37, 35, 0.04);
}

.sidebar-nav-item.active {
  color: var(--sidebar-active-text);
  background: var(--sidebar-active-bg);
  border-left-color: var(--sidebar-active-border);
}

.sidebar-nav-icon {
  font-size: 16px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-nav-label {
  overflow: hidden;
  transition: opacity var(--sidebar-transition);
}

.ops-sidebar.collapsed .sidebar-nav-label {
  opacity: 0;
  width: 0;
}

.ops-sidebar.collapsed .sidebar-nav-item {
  justify-content: center;
  padding: 10px 0;
  border-left-width: 0;
}

/* ----------------------------------------
   BADGES
   ---------------------------------------- */

.sidebar-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  line-height: 1.4;
  margin-left: auto;
  flex-shrink: 0;
}

/* External Link Indicator */
.sidebar-nav-external {
  text-decoration: none;
}

.sidebar-nav-external-icon {
  width: 11px;
  height: 11px;
  color: #7C7C78;
  margin-left: auto;
  flex-shrink: 0;
  transition: opacity 0.15s ease;
}

.sidebar-nav-external:hover .sidebar-nav-external-icon {
  color: #323531;
}

.ops-sidebar.collapsed .sidebar-nav-external-icon {
  display: none;
}

.sidebar-badge:empty {
  display: none;
}

.badge-red {
  background: rgba(220, 53, 69, 0.15);
  color: #E8554A;
}

.badge-amber {
  background: rgba(245, 158, 11, 0.15);
  color: #D97706;
}

.badge-muted {
  background: rgba(168, 162, 158, 0.12);
  color: #A8A29E;
}

.ops-sidebar.collapsed .sidebar-badge {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 9px;
  padding: 1px 5px;
  min-width: 14px;
}

/* ----------------------------------------
   FOOTER
   ---------------------------------------- */

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--sidebar-divider);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-version {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--sidebar-section-text);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--sidebar-transition);
}

.ops-sidebar.collapsed .sidebar-version {
  opacity: 0;
}

/* ----------------------------------------
   MOBILE
   ---------------------------------------- */

.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1000;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid #E8E6E1;
  background: #fff;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.mobile-menu-btn svg {
  width: 20px;
  height: 20px;
  color: #2B2523;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 850;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sidebar-backdrop.visible {
  opacity: 1;
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
  }

  .sidebar-backdrop {
    display: block;
    pointer-events: none;
  }

  .sidebar-backdrop.visible {
    pointer-events: auto;
  }

  .ops-sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
    box-shadow: none;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
  }

  .ops-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
  }

  .ops-sidebar.collapsed {
    width: var(--sidebar-width);
  }

  .ops-main {
    margin-left: 0;
    padding: 72px 16px 24px;
  }

  .ops-sidebar.collapsed ~ .ops-main {
    margin-left: 0;
  }

  .sidebar-toggle {
    display: none;
  }
}

/* ----------------------------------------
   PRINT
   ---------------------------------------- */

@media print {
  .ops-sidebar,
  .sidebar-backdrop,
  .mobile-menu-btn {
    display: none !important;
  }

  .ops-main {
    margin-left: 0 !important;
  }
}

/* ----------------------------------------
   HIDE OLD NAV (safety)
   ---------------------------------------- */

.nav-tabs {
  display: none !important;
}

/* Prevent body scroll when mobile sidebar is open */
body.sidebar-mobile-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}
