/*
 * Sidebar Navigation Component
 * SellerCentral-style dynamic sidebar
 */

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

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  overflow-y: auto;
  overflow-x: hidden;
  transition: all var(--transition-base);
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

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

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--border-dark);
}

/* ==========================================
   SIDEBAR HEADER (Logo Area)
   ========================================== */

.sidebar-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-card);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  text-decoration: none;
  color: var(--text-primary);
  transition: opacity var(--transition-base);
}

.sidebar-logo:hover {
  opacity: 0.8;
}

.sidebar-logo-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sidebar-logo-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-logo-full {
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: var(--space-xs) 0;
}

.sidebar-logo-full img {
  height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
}

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

.sidebar-nav {
  flex: 1;
  padding: var(--space-md) 0;
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: var(--space-lg);
}

.sidebar-section-title {
  padding: var(--space-sm) var(--space-lg);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
}

/* ==========================================
   NAVIGATION ITEMS
   ========================================== */

.nav-item {
  display: block;
  padding: var(--space-sm) var(--space-lg);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
  border-left: 3px solid transparent;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(31, 155, 255, 0.05);
  color: var(--primary-blue);
  border-left-color: var(--primary-blue);
}

.nav-item-content {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.nav-item-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-item-icon svg {
  width: 20px;
  height: 20px;
}

.nav-item-text {
  flex: 1;
}

.nav-item-badge {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--error-bg);
  color: var(--error);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

/* Expandable items */
.nav-item-expand {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.nav-item.expanded .nav-item-expand {
  transform: rotate(90deg);
}

/* Nav item with clickable link + separate expand toggle */
.nav-item-link {
  flex: 1;
  text-decoration: none;
  color: inherit;
}

.nav-item-link:hover {
  color: var(--primary-blue);
}

.nav-item[data-expandable] {
  display: flex;
  align-items: center;
}

.nav-item[data-expandable] .nav-item-expand[data-expand-toggle] {
  cursor: pointer;
  padding: 4px;
  margin-right: -4px;
  border-radius: var(--radius-sm);
}

.nav-item[data-expandable] .nav-item-expand[data-expand-toggle]:hover {
  background: rgba(31, 155, 255, 0.1);
}

/* ==========================================
   SUB-NAVIGATION (Nested)
   ========================================== */

.nav-sub {
  display: none;
  padding-left: var(--space-xl);
  margin-top: var(--space-xs);
}

.nav-sub.show {
  display: block;
}

.nav-sub-item {
  display: block;
  padding: var(--space-xs) var(--space-md);
  text-decoration: none;
  color: var(--text-tertiary);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition-fast);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-xs);
}

.nav-sub-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-sub-item.active {
  background: rgba(31, 155, 255, 0.08);
  color: var(--primary-blue);
  font-weight: 600;
}

/* ==========================================
   CLIENT CONTEXT (Dynamic Section)
   ========================================== */

.sidebar-client-context {
  padding: var(--space-lg);
  background: rgba(31, 155, 255, 0.02);
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  margin-bottom: var(--space-md);
}

.client-context-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.client-context-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.client-context-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.client-context-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.client-context-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.client-context-services {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.client-service-badge {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: rgba(31, 155, 255, 0.1);
  border: 1px solid rgba(31, 155, 255, 0.2);
  color: var(--primary-blue);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
}

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

.sidebar-footer {
  position: relative;
  padding: var(--space-lg);
  border-top: 1px solid var(--border-light);
  background: var(--bg-card);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  color: var(--text-primary);
}

.sidebar-user:hover {
  background: var(--bg-hover);
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--bg-blue-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

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

.sidebar-user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: capitalize;
}

/* ==========================================
   USER DROPDOWN (Glassmorphic)
   ========================================== */

.user-dropdown {
  position: absolute;
  bottom: calc(100% + var(--space-sm));
  left: var(--space-lg);
  right: var(--space-lg);
  background: rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  padding: var(--space-sm);
  display: none;
  z-index: calc(var(--z-sidebar) + 1);
}

.user-dropdown.show {
  display: block;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: white;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.user-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.15);
}

.user-dropdown-item svg {
  width: 18px;
  height: 18px;
}

.user-dropdown-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: var(--space-xs) 0;
}

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

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

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

/* ==========================================
   COLLAPSED STATE (Future)
   ========================================== */

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

.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .nav-item-text,
.sidebar.collapsed .nav-item-badge,
.sidebar.collapsed .nav-item-expand,
.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .client-context-label,
.sidebar.collapsed .client-context-name,
.sidebar.collapsed .client-context-services,
.sidebar.collapsed .sidebar-user-info {
  display: none;
}

.sidebar.collapsed .nav-item,
.sidebar.collapsed .nav-sub-item {
  padding: var(--space-sm);
  display: flex;
  justify-content: center;
}

.sidebar.collapsed .nav-item-content {
  justify-content: center;
}

/* ==========================================
   DARK THEME OVERRIDES
   ========================================== */

[data-theme="dark"] .sidebar {
  background: var(--bg-sidebar);
}

[data-theme="dark"] .sidebar-header,
[data-theme="dark"] .sidebar-footer {
  background: var(--bg-card);
}

[data-theme="dark"] .sidebar-logo-full img {
  filter: invert(1) brightness(1.8);
}

[data-theme="dark"] .sidebar-client-context {
  background: rgba(31, 155, 255, 0.05);
}

[data-theme="dark"] .nav-item.active {
  background: rgba(31, 155, 255, 0.1);
}

[data-theme="dark"] .nav-sub-item.active {
  background: rgba(31, 155, 255, 0.12);
}
