/**
 * Wordcraft — Collapsible Sidebar Navigation
 * Injected by sidebar.js on all app-shell pages.
 * Replaces the flat top nav with categorised collapsible groups.
 */

/* ── 1. LAYOUT ─────────────────────────────────────────────────────────── */

:root {
  --sb-width: 220px;
  --sb-bg:    #0f1320;
  --sb-border: rgba(212, 168, 83, 0.12);
  --sb-amber:  #d4a853;
  --sb-text:   #f5f0e8;
  --sb-muted:  #8a8274;
}

/* Push body content right on desktop */
body.wc-sidebar-layout {
  padding-left: var(--sb-width) !important;
}

/* Hide original top nav */
body.wc-sidebar-layout > nav:first-of-type {
  display: none !important;
}

/* ── 2. SIDEBAR SHELL ───────────────────────────────────────────────────── */

.wc-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sb-width);
  height: 100vh;
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  /* custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: rgba(212,168,83,0.2) transparent;
}
.wc-sidebar::-webkit-scrollbar { width: 4px; }
.wc-sidebar::-webkit-scrollbar-thumb { background: rgba(212,168,83,0.2); border-radius: 2px; }

/* ── 3. LOGO HEADER ─────────────────────────────────────────────────────── */

.wc-sidebar-logo {
  display: flex;
  align-items: center;
  padding: 22px 16px 18px;
  border-bottom: 1px solid var(--sb-border);
  text-decoration: none;
  flex-shrink: 0;
  font-family: 'DM Serif Display', serif;
  font-size: 20px;
  color: var(--sb-text);
  letter-spacing: 1px;
}
.wc-sidebar-logo .logo-dot { color: var(--sb-amber); }

/* ── 4. CATEGORY SECTIONS ───────────────────────────────────────────────── */

.wc-sidebar-section {
  border-bottom: 1px solid var(--sb-border);
}

/* Clickable category header */
.wc-sidebar-cat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 10px 16px;
  cursor: pointer;
  user-select: none;
  color: var(--sb-muted);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  transition: color 0.15s, background 0.15s;
  border-left: 2px solid transparent;
}
.wc-sidebar-cat:hover {
  color: var(--sb-text);
  background: rgba(255,255,255,0.03);
}
.wc-sidebar-cat.wc-cat-open {
  color: var(--sb-text);
  border-left-color: var(--sb-amber);
}
.wc-sidebar-cat:focus-visible {
  outline: 2px solid var(--sb-amber);
  outline-offset: -2px;
}

/* Chevron */
.wc-sb-chevron {
  display: inline-flex;
  align-items: center;
  transition: transform 0.22s ease;
  opacity: 0.5;
  flex-shrink: 0;
}
.wc-cat-open .wc-sb-chevron {
  transform: rotate(180deg);
  opacity: 0.9;
}

/* ── 5. COLLAPSIBLE LINKS ────────────────────────────────────────────────── */

.wc-sidebar-links {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.24s ease;
}
.wc-sidebar-links.wc-links-open {
  max-height: 600px;
}

/* Individual link */
.wc-sidebar-links a {
  display: flex;
  align-items: center;
  padding: 7px 14px 7px 22px;
  color: var(--sb-muted);
  text-decoration: none;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight: 450;
  line-height: 1.3;
  transition: color 0.14s, background 0.14s;
  border-left: 2px solid transparent;
  gap: 6px;
}
.wc-sidebar-links a:hover {
  color: var(--sb-text);
  background: rgba(255,255,255,0.04);
  border-left-color: rgba(212,168,83,0.3);
}
.wc-sidebar-links a.wc-link-active {
  color: var(--sb-amber);
  background: rgba(212,168,83,0.07);
  border-left-color: var(--sb-amber);
  font-weight: 600;
}

/* ── 6. NOTIFICATION BADGE ─────────────────────────────────────────────── */

.wc-link-badge {
  display: none;
  background: var(--sb-amber);
  color: #0d0d0d;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  line-height: 1.4;
  flex-shrink: 0;
}

/* ── 7. FOOTER (User Identity + Sign Out) ──────────────────────────────── */

.wc-sidebar-footer {
  margin-top: auto;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--sb-border);
  flex-shrink: 0;
}

/* User identity row */
.wc-sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 6px 6px;
  margin-bottom: 2px;
  overflow: hidden;
}

/* Initials avatar circle */
.wc-sidebar-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(212, 168, 83, 0.18);
  border: 1px solid rgba(212, 168, 83, 0.35);
  color: var(--sb-amber);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Email text */
.wc-sidebar-email {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  color: var(--sb-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

/* Sign In link (shown when no user logged in) */
.wc-sidebar-signin {
  display: block;
  padding: 7px 6px;
  color: var(--sb-amber);
  text-decoration: none;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.3px;
  transition: opacity 0.15s;
}
.wc-sidebar-signin:hover { opacity: 0.8; }

.wc-sidebar-signout {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--sb-muted);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  padding: 7px 6px;
  cursor: pointer;
  transition: color 0.15s;
  letter-spacing: 0.3px;
}
.wc-sidebar-signout:hover { color: #e74c3c; }

/* ── 8. MOBILE ──────────────────────────────────────────────────────────── */

/* Hamburger toggle button */
.wc-sidebar-hamburger {
  display: none;
  position: fixed;
  top: 12px;
  left: 14px;
  z-index: 300;
  background: rgba(15,19,32,0.95);
  border: 1px solid rgba(212,168,83,0.25);
  border-radius: 8px;
  padding: 9px;
  cursor: pointer;
  color: var(--sb-text);
  align-items: center;
  justify-content: center;
  line-height: 0;
  transition: background 0.15s, border-color 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.wc-sidebar-hamburger:hover {
  background: rgba(212,168,83,0.1);
  border-color: rgba(212,168,83,0.5);
}

/* Backdrop overlay on mobile */
.wc-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 199;
}
.wc-sidebar-backdrop.wc-backdrop-open {
  display: block;
  animation: wc-fade-backdrop 0.2s ease;
}
@keyframes wc-fade-backdrop {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

  .wc-sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .wc-sidebar.wc-sidebar-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }

  .wc-sidebar-hamburger {
    display: flex;
  }
}

/* Very small phones */
@media (max-width: 375px) {
  .wc-sidebar-hamburger {
    top: 10px;
    left: 10px;
  }
}
