/* ═══════════════════════════════════════════════════════
   Secdrift — Sidebar Component
   ═══════════════════════════════════════════════════════ */

/* ── Sidebar Container ─────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  width: 60px;
  z-index: 1000;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.25s var(--ease);
}

.sidebar.expanded {
  width: 220px;
}

/* ── Header ────────────────────────────────────────────── */
.sidebar-header {
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--amber), #e67e22);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-family: var(--display);
}

.sidebar-brand {
  font-family: var(--display);
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity 0.2s var(--ease), width 0.25s var(--ease);
}

.sidebar.expanded .sidebar-brand {
  opacity: 1;
  width: auto;
}

/* ── Pin Button ────────────────────────────────────────── */
.sidebar-pin {
  position: absolute;
  top: 14px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.2s, background 0.15s, color 0.15s;
}

.sidebar.expanded .sidebar-pin {
  opacity: 1;
}

.sidebar-pin:hover {
  background: var(--surface);
  color: var(--text-2);
}

.sidebar-pin.pinned {
  color: var(--amber);
}

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

/* ── Navigation ────────────────────────────────────────── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
}

.sidebar-nav::-webkit-scrollbar {
  width: 3px;
}

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

/* ── Nav Items ─────────────────────────────────────────── */
.sidebar-item {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  gap: 12px;
  cursor: pointer;
  color: var(--text-2);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  position: relative;
  user-select: none;
}

.sidebar-item:hover {
  background: var(--surface);
  color: var(--text);
}

.sidebar-item.active {
  background: var(--surface-2);
  color: var(--amber);
  box-shadow: inset 3px 0 0 var(--amber);
}

.sidebar-item svg {
  width: 18px;
  height: 18px;
  min-width: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-label {
  white-space: nowrap;
  opacity: 0;
  width: 0;
  overflow: hidden;
  font-size: 13.5px;
  font-family: var(--body);
  font-weight: 450;
  transition: opacity 0.2s var(--ease), width 0.25s var(--ease);
}

.sidebar.expanded .sidebar-label {
  opacity: 1;
  width: auto;
}

/* ── Chevron for expandable items ──────────────────────── */
.sidebar-chevron {
  margin-left: auto;
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: transform 0.2s var(--ease), opacity 0.2s, width 0.25s;
}

.sidebar.expanded .sidebar-chevron {
  opacity: 1;
  width: 16px;
}

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

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

/* ── Submenu ───────────────────────────────────────────── */
.sidebar-sub {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s var(--ease);
  padding-left: 20px;
}

.sidebar-sub.open {
  max-height: 200px;
}

.sidebar-subitem {
  display: flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  gap: 10px;
  cursor: pointer;
  color: var(--text-3);
  text-decoration: none;
  font-size: 13px;
  font-family: var(--body);
  transition: background 0.15s, color 0.15s;
}

.sidebar-subitem:hover {
  background: var(--surface);
  color: var(--text-2);
}

.sidebar-subitem.active {
  color: var(--amber);
  background: var(--surface-2);
}

.sidebar-subitem svg {
  width: 4px;
  height: 4px;
  min-width: 4px;
}

/* ── Badge (Snart) ─────────────────────────────────────── */
.sidebar-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-3);
  font-family: var(--mono);
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity 0.2s, width 0.25s;
}

.sidebar.expanded .sidebar-badge {
  opacity: 1;
  width: auto;
}

/* ── Footer ────────────────────────────────────────────── */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.sidebar-avatar {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--amber);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-family: var(--mono);
}

.sidebar-username {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  font-family: var(--body);
  color: var(--text-2);
  opacity: 0;
  width: 0;
  transition: opacity 0.2s var(--ease), width 0.25s var(--ease);
}

.sidebar.expanded .sidebar-username {
  opacity: 1;
  width: auto;
}

.sidebar-logout {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  transition: color 0.15s, background 0.15s;
  opacity: 0;
  flex-shrink: 0;
  transition: opacity 0.2s, color 0.15s, background 0.15s;
}

.sidebar.expanded .sidebar-logout {
  opacity: 1;
}

.sidebar-logout:hover {
  color: var(--red);
  background: var(--red-dim);
}

.sidebar-logout svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Body Layout ───────────────────────────────────────── */
body.has-sidebar {
  margin-left: 60px;
  transition: margin-left 0.25s var(--ease);
}

/* ── Mobile Toggle ─────────────────────────────────────── */
.sidebar-mobile-toggle {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1001;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.sidebar-mobile-toggle svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Mobile Overlay ────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .sidebar.mobile-open .sidebar-label,
  .sidebar.mobile-open .sidebar-brand,
  .sidebar.mobile-open .sidebar-username,
  .sidebar.mobile-open .sidebar-chevron,
  .sidebar.mobile-open .sidebar-badge,
  .sidebar.mobile-open .sidebar-logout {
    opacity: 1;
    width: auto;
  }

  .sidebar.mobile-open .sidebar-pin {
    display: none;
  }

  body.has-sidebar {
    margin-left: 0;
  }

  .sidebar-mobile-toggle {
    display: flex;
  }

  .sidebar-overlay.visible {
    display: block;
  }
}
