/* ========================================
   Sidebar — boletería style.
   Dark fixed panel on the left, organised as a "programa" with
   labelled sections (— MENÚ / — CUENTA / — TORNEO · …).
   The dark surface contrasts against the cream-paper tickets in
   the main content area.

   Markup contract (kept stable so the sidebar Stimulus controller
   keeps working):
     .sidebar [data-controller="sidebar" target]
       > .sidebar-brand       link wrapping logo + name
         > .icon              logo SVG
         > .sidebar-brand__text   "CLAVALO" Bebas
       > .sidebar-brand__tag  mono tag below brand
       > .toggle              collapse button
       > .nav
         > .nav-section       "— MENÚ"
         > .nav-item          link
           > .icon
           > .label
       > .bottom
         > .stamp             "SERVICIO OPERATIVO"

   Variants on `.sidebar`:
     -collapsed                rail mode (icons only)
   ======================================== */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 18px;
  z-index: 200;
  transition: width 200ms ease;
  overflow: hidden;
}

/* Reset the global form-field .label rule (atoms.css) leaking into
   the sidebar — display:block, margin-bottom:6px, font-family,
   font-size were overriding our brand and nav-item typography. */
.sidebar .label {
  display: inline;
  margin: 0;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
}

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


/* ─── Brand ─── */
/* Use namespaced classes (sidebar-brand, not .brand/.label) so the
   global .label rule from atoms.css can't leak into the brand mark
   and turn the title into Space Grotesk italic. */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  color: var(--ink);
  text-decoration: none;
}
.sidebar-brand > .icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  color: var(--green);
  filter: drop-shadow(0 0 8px var(--green-glow));
}
.sidebar-brand__text {
  font-family: var(--font-scoreboard);
  font-size: 22px;
  font-weight: 400;
  font-style: normal;
  line-height: 1;
  letter-spacing: 0.12em;
  color: var(--ink);
  white-space: nowrap;
}

.sidebar-brand__tag {
  display: block;
  margin: 8px 14px 22px;
  padding-top: 12px;
  border-top: 1px dashed var(--line-strong);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 400;
  letter-spacing: 0.22em;
  color: var(--muted);
  text-transform: uppercase;
  overflow: hidden;
  white-space: nowrap;
}


/* ─── Toggle ─── */
.sidebar > .toggle {
  position: absolute;
  top: 24px;
  right: 14px;
  background: none;
  border: 0;
  padding: 4px;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius);
  transition: color 150ms;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar > .toggle:hover { color: var(--ink); }

.sidebar.-collapsed > .toggle {
  top: 92px;
  right: 50%;
  transform: translateX(50%);
  width: 36px;
  height: 36px;
  padding: 6px;
  background: rgba(10, 219, 198, 0.08);
  border: 1px solid var(--line-strong);
  color: var(--accent);
}
.sidebar.-collapsed > .toggle:hover {
  background: rgba(10, 219, 198, 0.16);
  color: var(--accent);
}
.sidebar.-collapsed > .toggle > .icon {
  width: 20px;
  height: 20px;
  transform: rotate(180deg);
}
/* Brand collapsed: sin padding horizontal para que entre el logo grande,
   icono 44px con glow. */
.sidebar.-collapsed > .sidebar-brand {
  padding: 14px 0 0;
  justify-content: center;
}
.sidebar.-collapsed > .sidebar-brand > .icon {
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 0 12px var(--green-glow));
}
/* Premium en collapsed: SIN pill dorado, solo la crown grande centrada. */
.sidebar.-collapsed.-collapsed .nav-item.-premium {
  margin: 6px 0;
  padding: 10px 0;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  border: 0;
  background: none;
  box-shadow: none;
}
.sidebar.-collapsed.-collapsed .nav-item.-premium:hover {
  background: rgba(255, 210, 63, 0.08);
  border: 0;
}
.sidebar.-collapsed.-collapsed .nav-item.-premium > .icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
/* Quitar el border-left de los nav-items en collapsed para que centren perfecto */
.sidebar.-collapsed .nav-item {
  border-left: 0;
}
/* El indicador activo pasa a ser un dot teal a la derecha (ya estaba) +
   un sutil bg, sin border-left que desplaza. */
.sidebar.-collapsed .nav-item.-active {
  background: rgba(10, 219, 198, 0.08);
}


/* ─── Nav ─── */
.sidebar > .nav {
  flex: 1;
  min-height: 0; /* permite que flex shrink funcione y el nav scrollee */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.sidebar > .nav::-webkit-scrollbar { width: 3px; }
.sidebar > .nav::-webkit-scrollbar-track { background: transparent; }
.sidebar > .nav::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 2px; }

.sidebar .nav-section {
  font-family: var(--mono);
  font-size: 9.5px;
  line-height: 1.5; /* sin esto los caps mono se recortan con overflow:hidden */
  letter-spacing: 0.22em;
  color: var(--muted);
  padding: 14px 12px 6px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar .nav-section:first-child { padding-top: 6px; }

/* ─── Admin: nav más compacto y sencillo (íconos y fuente más chicos) ─── */
.sidebar.-admin .nav-item {
  font-size: 12.5px;
  min-height: 32px;
  padding: 6px 12px;
  gap: 10px;
}
.sidebar.-admin .nav-item .icon { width: 16px; height: 16px; }
.sidebar.-admin .nav-section {
  font-size: 8.5px;
  letter-spacing: 0.18em;
  padding: 15px 12px 5px;
}
.sidebar.-admin .nav-section:first-child { padding-top: 6px; }
.sidebar .nav-section.-tournament {
  color: var(--accent);
  opacity: 0.85;
}


/* Nav item — links and submit buttons share the same look. */
.sidebar .nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  min-height: 44px;
  border-left: 2px solid transparent;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  background: none;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  cursor: pointer;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  transition: background 150ms, color 150ms, border-color 150ms;
}
.sidebar .nav-item:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.025);
}

.sidebar .nav-item.-active {
  color: var(--ink);
  border-left-color: var(--accent);
  background: linear-gradient(90deg, rgba(10, 219, 198, 0.10), transparent 70%);
}
.sidebar .nav-item.-active::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--green-glow);
}

.sidebar .nav-item > .icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  opacity: 0.85;
}
.sidebar .nav-item.-active > .icon { opacity: 1; color: var(--ink); }

/* Inline avatar inside nav-item (e.g. "Mi perfil"). */
.sidebar .nav-item > .avatar,
.sidebar .nav-item > .img {
  flex-shrink: 0;
}


/* CTA at the bottom (logged-out state) — gold pill */
.sidebar .nav-item.-cta {
  margin-top: 6px;
  border-left: 0;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  font-weight: 600;
  justify-content: center;
  box-shadow: 0 6px 18px var(--green-glow);
}
.sidebar .nav-item.-cta:hover {
  background: linear-gradient(135deg, #5cf0d8, var(--accent-2));
  color: var(--accent-ink);
}

/* Premium — ítem destacado dentro de "Cuenta" (marco dorado + corona que brilla) */
.sidebar .nav-item.-premium {
  margin: 8px 8px 6px;
  width: auto;
  padding: 11px 12px;
  border: 1px solid rgba(255, 210, 63, 0.45);
  border-radius: var(--radius);
  background: linear-gradient(100deg, rgba(255, 210, 63, 0.14), rgba(255, 210, 63, 0.03) 70%);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 6px 18px -8px var(--gold-glow);
}
.sidebar .nav-item.-premium:hover {
  border-color: rgba(255, 210, 63, 0.8);
  background: linear-gradient(100deg, rgba(255, 210, 63, 0.22), rgba(255, 210, 63, 0.05) 70%);
  color: var(--ink);
}
.sidebar .nav-item.-premium > .icon {
  opacity: 1;
  color: var(--gold);
  animation: premium-crown 2.4s ease-in-out infinite;
}
@keyframes premium-crown {
  0%, 100% { filter: drop-shadow(0 0 4px var(--green-glow)); }
  50%      { filter: drop-shadow(0 0 9px var(--green-glow)) brightness(1.15); }
}
.sidebar .nav-item.-premium.-active::after { display: none; }
@media (prefers-reduced-motion: reduce) {
  .sidebar .nav-item.-premium > .icon { animation: none; }
}
.sidebar .nav-item.-cta::after { content: none; }


/* Submit-button rendered nav-items (logout) — strip default form chrome. */
.sidebar form { width: 100%; margin: 0; }


/* ─── Bottom section ─── */
.sidebar > .bottom {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px dashed var(--line-strong);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sidebar > .bottom > .stamp {
  margin: 12px 4px 0;
}


/* ─── Labels (collapsed mode hides text) ─── */
.sidebar .label,
.sidebar .sidebar-brand__text,
.sidebar-brand__tag,
.sidebar .nav-section,
.sidebar > .bottom > .stamp {
  transition: opacity 200ms ease;
}

.sidebar.-collapsed .label,
.sidebar.-collapsed .sidebar-brand__text,
.sidebar.-collapsed .sidebar-brand__tag,
.sidebar.-collapsed .nav-section,
.sidebar.-collapsed > .bottom > .stamp {
  opacity: 0;
  pointer-events: none;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}
.sidebar.-collapsed .nav-item { justify-content: center; padding: 10px 0; }
.sidebar.-collapsed .nav-item.-active::after {
  right: 8px;
}
/* Empuja el nav abajo para que el primer item no se solape con el toggle. */
.sidebar.-collapsed > .nav { padding-top: 56px; }



/* ─── Responsive ─── */
/* Mobile: bottom-tab takes over. */
@media (max-width: 719px) {
  .sidebar { display: none; }
}

/* Tablet: collapse to icons-only by default. */
@media (min-width: 720px) and (max-width: 1023px) {
  .sidebar { width: var(--sidebar-width-collapsed); }
  .sidebar .label,
  .sidebar .sidebar-brand__text,
  .sidebar-brand__tag,
  .sidebar .nav-section,
  .sidebar > .bottom > .stamp {
    opacity: 0;
    pointer-events: none;
    height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }
  .sidebar > .sidebar-brand { justify-content: center; padding-top: 8px; }
  .sidebar .nav-item { justify-content: center; padding: 10px 0; }

}
