/* ═══════════════════════════════════════════
   ToneSpoon — Sidebar Navigation
   ═══════════════════════════════════════════ */

:root {
  --sb-w: 224px;
  --sb-collapsed: 64px;
}

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 30;
  width: var(--sb-w);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  background: rgba(15,15,20,0.85);
  border-right: 1px solid rgba(255,255,255,0.06);
  transition: width 0.35s cubic-bezier(0.32, 0.08, 0.24, 1);
  overflow: hidden;
  user-select: none;
}

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

/* ── Logo ──────────────────────────────── */

.sidebar__logo {
  display: flex;
  align-items: center;
  height: 64px;
  padding: 0 20px;
  cursor: pointer;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: padding 0.35s cubic-bezier(0.32, 0.08, 0.24, 1);
}

.sidebar.collapsed .sidebar__logo {
  padding: 0;
  justify-content: center;
}

.sidebar__logo-full {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  background: linear-gradient(135deg, #e0dbd4 0%, #a3b5b1 50%, #c4b8c0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  opacity: 0.75;
  transition: opacity 0.2s ease;
}

.sidebar__logo:hover .sidebar__logo-full,
.sidebar__logo:hover .sidebar__logo-short {
  opacity: 1;
}

.sidebar__logo-short {
  display: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #e0dbd4 0%, #a3b5b1 50%, #c4b8c0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  opacity: 0.75;
  transition: opacity 0.2s ease;
}

.sidebar.collapsed .sidebar__logo-full { display: none; }
.sidebar.collapsed .sidebar__logo-short { display: block; }

/* ── Nav links ──────────────────────────── */

.sidebar__nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 10px;
  overflow-y: auto;
}

.sidebar.collapsed .sidebar__nav {
  padding: 14px 7px;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 11px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  transition: all 0.25s ease;
  position: relative;
}

.sidebar__link::before {
  content: '';
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 2.5px; height: 0;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  transition: height 0.3s cubic-bezier(0.2,0.8,0.2,1);
}

.sidebar__link.active::before {
  height: 22px;
}

.sidebar.collapsed .sidebar__link {
  justify-content: center;
  gap: 0;
  padding: 11px 6px;
}

.sidebar__link:hover {
  color: var(--text);
  background: rgba(255,255,255,0.04);
}

.sidebar__link.active {
  color: var(--text);
  background: rgba(255,255,255,0.06);
}

.sidebar__icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  object-fit: contain;
  opacity: 0.5;
  transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.2,0.8,0.2,1);
  filter: invert(1);
}

.sidebar__link:hover .sidebar__icon {
  transform: scale(1.12);
}

[data-theme="light"] .sidebar__icon {
  filter: invert(0);
}

.sidebar__link.active .sidebar__icon,
.sidebar__link:hover .sidebar__icon {
  opacity: 0.9;
}

.sidebar.collapsed .sidebar__icon {
  width: 26px;
  height: 26px;
}

.sidebar__label {
  opacity: 1;
  transition: opacity 0.15s ease 0.05s, transform 0.25s ease;
}

.sidebar.collapsed .sidebar__label {
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity 0.08s ease, width 0s 0.2s;
}

/* ── Footer / theme toggle ──────────────── */

.sidebar__footer {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  border-top: 1px solid rgba(255,255,255,0.04);
}

.sidebar.collapsed .sidebar__footer {
  justify-content: center;
  padding: 14px 10px;
}

.sidebar .theme-toggle {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.09);
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; line-height: 1; padding: 0;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.sidebar .theme-toggle:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.18);
  color: var(--text);
}

.sidebar__theme-label {
  margin-left: 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: opacity 0.15s ease;
}

.sidebar.collapsed .sidebar__theme-label {
  opacity: 0;
  width: 0;
  margin-left: 0;
  overflow: hidden;
}

/* ── Body offset ────────────────────────── */

body.has-sidebar {
  padding-left: var(--sb-w);
  transition: padding-left 0.35s cubic-bezier(0.32, 0.08, 0.24, 1);
}

body.has-sidebar.sidebar-collapsed {
  padding-left: var(--sb-collapsed);
}

/* ── Light theme ────────────────────────── */

[data-theme="light"] .sidebar {
  background: rgba(244,241,235,0.88);
  border-right-color: rgba(0,0,0,0.06);
}

[data-theme="light"] .sidebar__logo {
  border-bottom-color: rgba(0,0,0,0.05);
}

[data-theme="light"] .sidebar__footer {
  border-top-color: rgba(0,0,0,0.05);
}

[data-theme="light"] .sidebar__link:hover {
  background: rgba(0,0,0,0.04);
}

[data-theme="light"] .sidebar__link.active {
  background: rgba(0,0,0,0.05);
}

[data-theme="light"] .sidebar .theme-toggle {
  border-color: rgba(0,0,0,0.1);
  background: rgba(0,0,0,0.04);
}

[data-theme="light"] .sidebar .theme-toggle:hover {
  background: rgba(0,0,0,0.08);
  border-color: rgba(0,0,0,0.18);
}

/* ── Site footer ────────────────────────── */

.site-footer {
  position: relative; z-index: 2; text-align: center;
  padding: 40px 24px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.5rem; letter-spacing: 0.1em;
  color: rgba(160,156,150,0.35); text-transform: uppercase;
}

.site-footer a {
  color: inherit; text-decoration: none;
  transition: color 0.3s ease;
}

.site-footer a:hover { color: var(--accent); }

/* ── Breadcrumbs ────────────────────────── */

.breadcrumb {
  position: relative; z-index: 2;
  margin-bottom: 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem; letter-spacing: 0.08em;
  text-transform: uppercase;
  animation: fadeUp 0.45s cubic-bezier(0.2,0.8,0.2,1) both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.breadcrumb a {
  color: rgba(240,237,232,0.52); text-decoration: none;
  transition: color 0.25s ease;
}
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb__sep { margin: 0 6px; opacity: 0.22; color: var(--text-muted); }
.breadcrumb__current { color: var(--text); font-weight: 500; }

[data-theme="light"] .breadcrumb a {
  color: rgba(28,28,34,0.48);
}

@media (max-width: 520px) {
  .breadcrumb { margin-bottom: 14px; font-size: 0.54rem; }
}

/* ── Responsive ─────────────────────────── */

@media (max-width: 900px) {
  :root {
    --sb-w: 200px;
    --sb-collapsed: 56px;
  }
}

@media (max-width: 500px) {
  :root {
    --sb-w: 170px;
    --sb-collapsed: 44px;
  }
}

/* ── Back to Top ────────────────────────── */

.back-to-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 40;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(30,30,40,0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; line-height: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.25s ease;
  transform: translateY(10px);
  font-family: 'JetBrains Mono', monospace;
}
.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.back-to-top:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.2);
  color: var(--text);
}
[data-theme="light"] .back-to-top {
  background: rgba(240,237,232,0.8);
  border-color: rgba(0,0,0,0.1);
}
[data-theme="light"] .back-to-top:hover {
  background: rgba(0,0,0,0.06);
  border-color: rgba(0,0,0,0.2);
}

/* ── Mobile Nav Toggle ───────────────────── */

.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 35;
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(15,15,20,0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
}
.mobile-nav-toggle span {
  display: block;
  width: 17px; height: 1.5px;
  background: var(--text-muted);
  border-radius: 1px;
  transition: all 0.3s ease;
  transform-origin: center;
}
[data-theme="light"] .mobile-nav-toggle {
  background: rgba(244,241,235,0.82);
  border-color: rgba(0,0,0,0.1);
}

/* Sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 28;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.sidebar-overlay.is-visible {
  display: block;
  animation: overlayFadeIn 0.3s ease;
}
@keyframes overlayFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (max-width: 768px) {
  body.has-sidebar {
    padding-left: 0 !important;
  }

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

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.08, 0.24, 1);
    width: var(--sb-w) !important;
  }

  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0,0,0,0.5);
  }
}

/* ═══════════════════════════════════════════
   Auth — Sidebar Section
   ═══════════════════════════════════════════ */

.sidebar__auth {
  padding: 10px 14px;
  border-top: 1px solid rgba(255,255,255,0.04);
}
.sidebar.collapsed .sidebar__auth {
  padding: 10px 6px;
  display: flex; justify-content: center;
}

.sidebar__auth-signin {
  display: block; width: 100%;
  padding: 9px 0; border-radius: 8px;
  border: 1px solid rgba(163,181,177,0.2);
  background: rgba(163,181,177,0.06);
  color: var(--accent); cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.72rem; font-weight: 500;
  letter-spacing: 0.03em;
  transition: all 0.25s ease;
}
.sidebar__auth-signin:hover {
  background: rgba(163,181,177,0.14);
  border-color: rgba(163,181,177,0.35);
}
.sidebar.collapsed .sidebar__auth-signin {
  width: 38px; height: 38px; padding: 0; border-radius: 50%;
  font-size: 0.65rem; font-weight: 600;
}

.sidebar__auth-user {
  display: flex; align-items: center; gap: 10px;
}
.sidebar.collapsed .sidebar__auth-user {
  justify-content: center; gap: 0; flex-direction: column;
}

.sidebar__auth-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: rgba(163,181,177,0.15);
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem; font-weight: 600; color: var(--accent);
}
.sidebar__auth-avatar--early {
  background: rgba(212, 168, 83, 0.22);
}

.sidebar__auth-name {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.sidebar.collapsed .sidebar__auth-name {
  display: none;
}

.sidebar__auth-profile-link {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit;
  flex: 1; min-width: 0;
  border-radius: 8px; padding: 2px 4px; margin: -2px -4px;
  transition: background 0.25s ease;
}
.sidebar__auth-profile-link:hover {
  background: rgba(255,255,255,0.04);
}
.sidebar.collapsed .sidebar__auth-profile-link {
  gap: 0; flex: 0;
}
[data-theme="light"] .sidebar__auth-profile-link:hover {
  background: rgba(0,0,0,0.03);
}

.sidebar__auth-signout {
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.68rem; font-weight: 500; color: var(--text-muted);
  padding: 6px 12px; line-height: 1; border-radius: 6px;
  transition: all 0.2s ease; white-space: nowrap; flex-shrink: 0;
}
.sidebar__auth-signout:hover {
  background: rgba(212,117,107,0.12); border-color: rgba(212,117,107,0.3); color: #d4756b;
}
.sidebar.collapsed .sidebar__auth-signout {
  font-size: 0.58rem; padding: 4px 6px; margin-top: 4px;
}

[data-theme="light"] .sidebar__auth {
  border-top-color: rgba(0,0,0,0.05);
}
[data-theme="light"] .sidebar__auth-signin {
  background: rgba(90,125,110,0.06);
  border-color: rgba(90,125,110,0.18);
}
[data-theme="light"] .sidebar__auth-signin:hover {
  background: rgba(90,125,110,0.14);
}
[data-theme="light"] .sidebar__auth-signout {
  background: rgba(0,0,0,0.02); border-color: rgba(0,0,0,0.06);
}
[data-theme="light"] .sidebar__auth-signout:hover {
  background: rgba(212,117,107,0.1); border-color: rgba(212,117,107,0.25); color: #c0392b;
}

/* ═══════════════════════════════════════════
   Auth Modal
   ═══════════════════════════════════════════ */

.auth-modal {
  display: none;
  position: fixed; inset: 0; z-index: 100;
  align-items: center; justify-content: center;
}
.auth-modal.is-open { display: flex; }

.auth-modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: modalFadeIn 0.25s ease;
}
@keyframes modalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.auth-modal__card {
  position: relative; z-index: 1;
  width: 380px; max-width: 92vw;
  border-radius: 18px;
  backdrop-filter: blur(32px); -webkit-backdrop-filter: blur(32px);
  background: rgba(24,24,34,0.9);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 8px 48px rgba(0,0,0,0.5);
  padding: 32px 28px 24px;
  animation: modalSlideUp 0.35s cubic-bezier(0.2,0.8,0.2,1);
}
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

[data-theme="light"] .auth-modal__card {
  background: rgba(248,245,240,0.92);
  border-color: rgba(0,0,0,0.06);
}

.auth-modal__close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none; cursor: pointer;
  font-size: 1.3rem; color: var(--text-muted);
  line-height: 1; padding: 4px 6px; border-radius: 6px;
  transition: all 0.2s ease;
}
.auth-modal__close:hover { color: var(--text); background: rgba(255,255,255,0.06); }

.auth-modal__tabs {
  display: flex; gap: 0; margin-bottom: 24px;
  border-radius: 10px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.07);
}
.auth-modal__tab {
  flex: 1; padding: 10px 0; border: none; cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem; font-weight: 500;
  color: var(--text-muted);
  background: rgba(255,255,255,0.02);
  transition: all 0.25s ease;
}
.auth-modal__tab.is-active {
  background: rgba(163,181,177,0.12);
  color: var(--accent);
}
[data-theme="light"] .auth-modal__tabs {
  border-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .auth-modal__tab {
  background: rgba(0,0,0,0.02);
}

.auth-modal__form {
  display: flex; flex-direction: column; gap: 12px;
}
.auth-modal__input {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: var(--text); font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem; outline: none;
  transition: border-color 0.3s ease, background 0.3s ease;
}
.auth-modal__input::placeholder { color: rgba(160,156,150,0.45); }
.auth-modal__input:focus {
  border-color: rgba(163,181,177,0.35);
  background: rgba(255,255,255,0.06);
}
[data-theme="light"] .auth-modal__input {
  background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .auth-modal__input:focus {
  background: rgba(0,0,0,0.05); border-color: rgba(90,125,110,0.3);
}

.auth-modal__error {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem; color: #d4756b;
  min-height: 18px; margin: 0;
}

.auth-modal__submit {
  width: 100%; padding: 12px 0; border-radius: 10px;
  border: 1px solid rgba(163,181,177,0.22);
  background: rgba(163,181,177,0.1);
  color: var(--accent); cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem; font-weight: 500; letter-spacing: 0.02em;
  transition: all 0.3s ease;
  margin-top: 4px;
}
.auth-modal__submit:hover {
  background: rgba(163,181,177,0.18);
  border-color: rgba(163,181,177,0.4);
  box-shadow: 0 0 24px rgba(163,181,177,0.1);
}
.auth-modal__submit:disabled {
  opacity: 0.5; cursor: not-allowed;
}
[data-theme="light"] .auth-modal__submit {
  background: rgba(90,125,110,0.08);
  border-color: rgba(90,125,110,0.18);
}
[data-theme="light"] .auth-modal__submit:hover {
  background: rgba(90,125,110,0.16);
  border-color: rgba(90,125,110,0.3);
}

.auth-modal__hint {
  text-align: center; margin-top: 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem; color: var(--text-muted);
  cursor: pointer; user-select: none;
}
.auth-modal__hint b { color: var(--accent); font-weight: 500; }
