/* ========================================
   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;
  color: var(--green);
  filter: drop-shadow(0 0 6px 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 {
  right: 50%;
  transform: translateX(50%);
}
.sidebar.-collapsed > .toggle > .icon {
  transform: rotate(180deg);
}


/* ─── Nav ─── */
.sidebar > .nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar .nav-section {
  font-family: var(--mono);
  font-size: 9.5px;
  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; }


/* 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(--gold);
  background: linear-gradient(90deg, rgba(255, 210, 63, 0.1), 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(--gold);
  box-shadow: 0 0 8px var(--gold-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(--gold), #f0b820);
  color: var(--paper-ink);
  font-weight: 600;
  justify-content: center;
  box-shadow: 0 6px 18px var(--gold-glow);
}
.sidebar .nav-item.-cta:hover {
  background: linear-gradient(135deg, #ffe170, #f0b820);
  color: var(--paper-ink);
}
.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 > .sidebar-brand { justify-content: center; padding-top: 8px; }
.sidebar.-collapsed .nav-item { justify-content: center; padding: 10px 0; }
.sidebar.-collapsed .nav-item.-active::after {
  right: 8px;
}


/* ─── Carrusel de sponsors ─── */
.sidebar-sponsors {
  margin: 6px 0 0;
  padding-bottom: 6px;
}

.sidebar-sponsor-slides {
  position: relative;
  height: 168px;
  margin: 6px 0 0;
  overflow: hidden;
  border-radius: var(--radius);
}

.sidebar-sponsor-slide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--card);
  text-decoration: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.sidebar-sponsor-slide.active {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-sponsor-slide > .slide-img {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: var(--card-2);
  overflow: hidden;
}

.sidebar-sponsor-slide > .slide-img > img {
  max-width: 100%;
  max-height: 96px;
  object-fit: contain;
  transition: transform 300ms ease;
}

.sidebar-sponsor-slide.active:hover > .slide-img > img {
  transform: scale(1.04);
}

.sidebar-sponsor-slide > .slide-footer {
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  background: var(--card);
}

.sidebar-sponsor-slide > .slide-footer > .slide-name {
  display: block;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Oculto cuando el sidebar está colapsado */
.sidebar.-collapsed .sidebar-sponsors { display: none; }

/* ─── 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; }
  .sidebar-sponsors { display: none; }
}
