/**
 * Sidebar Navigation - Modern Tool Navigation
 * Always visible sidebar with all tools for easy navigation
 */

/* ===========================
   Sidebar Container
   =========================== */

.tool-sidebar {
  position: fixed;
  left: 0;
  top: 73px; /* Below header */
  bottom: 0;
  width: 280px;
  background: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  z-index: var(--z-sticky);
  transition: all var(--transition-base);
  padding: var(--space-6) 0;
  transform: translateX(-100%);
  box-shadow: none;
}

/* Sidebar OPEN state - visible */
.tool-sidebar.open {
  transform: translateX(0);
  box-shadow: var(--shadow-2xl);
}

[data-theme="dark"] .tool-sidebar {
  background: var(--bg-primary);
  border-right-color: var(--border-color);
}

/* Adjust main content when sidebar is present */
.has-sidebar {
  margin-left: 0;
  transition: margin-left var(--transition-base);
}

/* Desktop: Sidebar open by default on tool pages */
@media (min-width: 1025px) {
  body:not(.homepage) .tool-sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  body:not(.homepage) .has-sidebar {
    margin-left: 0;
    transition: margin-left var(--transition-base);
  }

  /* Adjust content margin when sidebar is open */
  body:not(.homepage).sidebar-open .has-sidebar {
    margin-left: 280px;
  }
}

/* ===========================
   Sidebar Sections
   =========================== */

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

.sidebar-section-title {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  padding: 0 var(--space-6);
  margin-bottom: var(--space-3);
}

/* ===========================
   Sidebar Items
   =========================== */

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-6);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
  position: relative;
}

.sidebar-item:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-left-color: var(--brand-200);
}

.sidebar-item.active {
  background: var(--brand-50);
  color: var(--brand-700);
  border-left-color: var(--brand-600);
  font-weight: 600;
}

[data-theme="dark"] .sidebar-item.active {
  background: rgba(20, 184, 166, 0.1);
  color: var(--brand-400);
}

/* ===========================
   Sidebar Icons
   =========================== */

.sidebar-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: currentColor;
  transition: transform var(--transition-fast);
}

.sidebar-item:hover .sidebar-icon {
  transform: scale(1.1);
}

.sidebar-item.active .sidebar-icon {
  color: var(--brand-600);
}

[data-theme="dark"] .sidebar-item.active .sidebar-icon {
  color: var(--brand-400);
}

/* ===========================
   Sidebar Text
   =========================== */

.sidebar-text {
  flex: 1;
}

.sidebar-name {
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.4;
  display: block;
}

.sidebar-item.active .sidebar-name {
  font-weight: 600;
}

.sidebar-desc {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  line-height: 1.3;
  margin-top: 2px;
}

/* ===========================
   Sidebar Toggle Button (always visible, slides with sidebar)
   =========================== */

.sidebar-toggle-btn {
  position: fixed;
  left: 0; /* Start at left edge when closed */
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  background: var(--brand-600);
  border: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  z-index: calc(var(--z-sticky) + 2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
  transition: left var(--transition-base), background var(--transition-fast), transform var(--transition-fast);
}

/* When sidebar is OPEN, button moves to right edge of sidebar */
.tool-sidebar.open ~ .sidebar-toggle-btn {
  left: 240px; /* 280px sidebar - 40px button width */
}

.sidebar-toggle-btn:hover {
  background: var(--brand-700);
  transform: translateY(-50%) scale(1.05);
}

.sidebar-toggle-btn span {
  width: 20px;
  height: 2px;
  background: white;
  border-radius: 2px;
  transition: all var(--transition-fast);
}

/* Default: burger icon (3 horizontal bars) */
/* When sidebar is OPEN, button shows X to indicate "click to close" */
.sidebar-toggle-btn.show-close span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.sidebar-toggle-btn.show-close span:nth-child(2) {
  opacity: 0;
}

.sidebar-toggle-btn.show-close span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* Old mobile toggle - HIDDEN */
.sidebar-toggle {
  display: none !important;
}

/* ===========================
   Mobile Sidebar Overlay
   =========================== */

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: calc(var(--z-sticky) - 1);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
  backdrop-filter: blur(4px);
}

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

/* ===========================
   Responsive Behavior
   =========================== */

@media (max-width: 768px) {
  .tool-sidebar {
    width: 100%;
    max-width: 320px;
  }
}

/* ===========================
   Scrollbar Styling
   =========================== */

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

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

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

.tool-sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ===========================
   Active Page Indicator
   =========================== */

.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--brand-600);
  border-radius: 0 2px 2px 0;
}

/* ===========================
   Hover Effects
   =========================== */

.sidebar-item::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: linear-gradient(90deg, var(--brand-50) 0%, transparent 100%);
  transition: width var(--transition-fast);
  pointer-events: none;
}

[data-theme="dark"] .sidebar-item::after {
  background: linear-gradient(90deg, rgba(20, 184, 166, 0.05) 0%, transparent 100%);
}

.sidebar-item:hover::after {
  width: 100%;
}

/* ===========================
   Divider
   =========================== */

.sidebar-divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--space-4) var(--space-6);
}

/* ===========================
   Badge for New/Beta Features
   =========================== */

.sidebar-badge {
  font-size: 0.625rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--brand-100);
  color: var(--brand-700);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

[data-theme="dark"] .sidebar-badge {
  background: rgba(20, 184, 166, 0.2);
  color: var(--brand-400);
}
