/* ═══════════════════════════════════════════════
   SIDEBAR — Mandala DMS NavMenu
   Extracted from docs/mockups/ui-redesign-mockup.html
   ═══════════════════════════════════════════════ */

/* ─── CSS Variables ─── */
:root {
  --md-sidebar-width: 250px;
  --md-sidebar-collapsed: 64px;
}

/* ─── Sidebar Base ─── */
.sidebar {
  width: var(--md-sidebar-width);
  background: #0a1f44;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow: hidden;
  overflow-x: hidden;
  transition: width 0.2s ease;
}

/* ─── Bootstrap/Dashkit Reset ─── */
/* Override navbar base rules that conflict with vertical sidebar */
#sidebar.sidebar.navbar {
  padding: 0;
  flex-direction: column;
  align-items: stretch;
  flex-wrap: wrap;
}

/* Hide Bootstrap dropdown caret in profile area */
.sidebar-profile .dropdown-toggle::after {
  display: none !important;
}

/* Reset Bootstrap nav-item margins */
.sidebar .nav-item {
  margin-left: 0;
  margin-right: 0;
}

/* ─── Toggle Button ─── */
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 16px;
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-toggle i {
  width: 20px;
  height: 20px;
  color: rgba(255,255,255,0.65);
  transition: color 0.15s;
  font-size: 20px;
}

.sidebar-toggle:hover i {
  color: rgba(255,255,255,0.9);
}

/* ─── Profile Area ─── */
.sidebar-profile {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.profile-info {
  overflow: hidden;
}

.profile-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-role {
  font-size: 0.6875rem;
  color: #95aac9;
}

/* Profile dropdown */
.sidebar-profile .dropdown-menu {
  min-width: 160px;
}

/* ─── Nav Sections ─── */
.nav-section {
  padding: 20px 0 4px;
}

.nav-section:first-of-type {
  padding-top: 16px;
}

.nav-section-header {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #95aac9;
  padding: 0 20px 8px;
}

/* ─── Scrollable Nav Wrapper & Scrollbar Styling ─── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  /* Firefox: scrollbar-width/color must live in the element rule, not a pseudo-element */
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

/* Blend scrollbar with dark sidebar — webkit */
.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

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

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.25);
}

/* Dashboard standalone (no section header) */
.nav-dashboard {
  padding-top: 16px;
  padding-bottom: 4px;
}

/* ─── Nav Items ─── */
.sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 20px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  position: relative;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar .nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.9);
  text-decoration: none;
}

.sidebar .nav-item.active {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,1);
}

.sidebar .nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #3b82f6;
  border-radius: 0 2px 2px 0;
}

.sidebar .nav-item i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1;
  text-align: center;
}

/* ─── Sidebar Footer ─── */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* ─── Back to Admin Link ─── */
.sidebar .back-to-admin {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  color: #95aac9;
  font-size: 0.75rem;
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: color 0.15s;
}

.sidebar .back-to-admin:hover {
  color: rgba(255,255,255,0.9);
  text-decoration: none;
}

/* ═══════════════════════════════════════════════
   COLLAPSED STATE
   ═══════════════════════════════════════════════ */
.sidebar.collapsed {
  width: var(--md-sidebar-collapsed);
}

.sidebar.collapsed .sidebar-profile {
  padding: 16px 0;
}

.sidebar.collapsed .sidebar-profile .profile-row {
  justify-content: center;
}

.sidebar.collapsed .sidebar-profile .dropdown {
  display: flex;
  justify-content: center;
}

.sidebar.collapsed .profile-info {
  display: none;
}

.sidebar.collapsed .profile-avatar {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.sidebar.collapsed .nav-section-header {
  display: none;
}

.sidebar.collapsed .nav-item span {
  display: none !important;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 9px 0;
  gap: 0;
}

.sidebar.collapsed .sidebar-toggle {
  justify-content: center;
}

.sidebar.collapsed .back-to-admin span {
  display: none;
}

.sidebar.collapsed .back-to-admin {
  justify-content: center;
  padding: 8px 0;
}

/* ═══════════════════════════════════════════════
   MAIN CONTENT TRANSITION
   ═══════════════════════════════════════════════ */
.sidebar ~ .main-content {
  margin-left: 250px;
  transition: margin-left 0.2s ease;
}

.sidebar.collapsed ~ .main-content {
  margin-left: 64px !important;
}

/* ═══════════════════════════════════════════════
   LANGUAGE SWITCHER DARK MODE OVERRIDES
   ═══════════════════════════════════════════════ */
.sidebar-footer .language-toggle {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.1);
}

.sidebar-footer .lang-code {
  color: rgba(255,255,255,0.5);
}

.sidebar-footer .lang-option.active .lang-code {
  color: rgba(255,255,255,0.9);
}

.sidebar-footer .toggle-track {
  background: rgba(255,255,255,0.15);
}

.sidebar-footer .toggle-track:hover {
  background: rgba(255,255,255,0.25);
}

/* Collapsed sidebar: hide language text */
.sidebar.collapsed .sidebar-footer .language-toggle {
  justify-content: center;
  padding: 8px;
  gap: 0;
}

.sidebar.collapsed .sidebar-footer .lang-option .lang-code,
.sidebar.collapsed .sidebar-footer .lang-option .lang-flag {
  display: none;
}

.sidebar.collapsed .sidebar-footer .toggle-track {
  display: none;
}

.sidebar.collapsed .sidebar-footer .language-toggle::before {
  content: '\e9ca';
  font-family: 'Feather';
  font-size: 18px;
  color: rgba(255,255,255,0.65);
}

/* ═══════════════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

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