:root {
  /* Base palette */
  --color-obsidian: #1a1a18;
  --color-charcoal: #2a2a26;
  --color-warm-gold: #a3946b;
  --color-parchment: #e8e4de;
  --color-bone: #f5f2ec;
  --color-wc-red: rgb(195, 41, 28);

  /* Semantic colors — light mode */
  --color-primary: var(--color-wc-red);
  --color-primary-foreground: #ffffff;
  --color-primary-hover: #a3211a;
  --color-secondary: var(--color-parchment);
  --color-secondary-foreground: var(--color-obsidian);
  --color-accent: var(--color-warm-gold);
  --color-accent-foreground: var(--color-obsidian);
  --color-background: var(--color-bone);
  --color-foreground: var(--color-obsidian);
  --color-muted: var(--color-parchment);
  --color-muted-foreground: #6b6760;
  --color-border: #d9d4cb;
  --color-destructive: #b84a3e;
  --color-destructive-foreground: var(--color-bone);
  --color-success: #4f7a5c;
  --color-success-foreground: var(--color-bone);
  --color-warning: #b88a3a;
  --color-warning-foreground: var(--color-obsidian);
  --color-card: #ffffff;
  --color-card-foreground: var(--color-obsidian);
  --color-sidebar: #ffffff;
  --color-sidebar-foreground: var(--color-obsidian);
  --color-footer: var(--color-obsidian);
  --color-footer-foreground: var(--color-bone);

  /* Typography */
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-heading: var(--font-sans);

  /* Spacing & Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

/* Dark mode — applied when <html> has the `dark` class */
.dark {
  --color-primary: #d83b2e;
  --color-primary-foreground: #ffffff;
  --color-primary-hover: #e85c50;
  --color-secondary: var(--color-charcoal);
  --color-secondary-foreground: var(--color-bone);
  --color-accent: var(--color-warm-gold);
  --color-accent-foreground: var(--color-obsidian);
  --color-background: var(--color-obsidian);
  --color-foreground: var(--color-bone);
  --color-muted: var(--color-charcoal);
  --color-muted-foreground: #9a9388;
  --color-border: #3a3a35;
  --color-destructive: #e06b5c;
  --color-destructive-foreground: var(--color-obsidian);
  --color-success: #7aa289;
  --color-success-foreground: var(--color-obsidian);
  --color-warning: #d4a864;
  --color-warning-foreground: var(--color-obsidian);
  --color-card: var(--color-charcoal);
  --color-card-foreground: var(--color-bone);
  --color-sidebar: var(--color-obsidian);
  --color-sidebar-foreground: var(--color-bone);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.55), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}
/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
 * vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS
 * files in this directory. Styles in this file should be added after the last require_* statement.
 * It is generally better to create a new file per style scope.
 *


 */

/* Smooth color transitions when toggling dark mode */
html {
  color-scheme: light;
}
html.dark {
  color-scheme: dark;
}

/*
 * Dark-mode compatibility layer for Tailwind utility classes that don't yet
 * use theme variables. Always-dark surfaces (e.g. the site footer) are scoped
 * out via :not([data-theme-static]).
 */
.dark .bg-white:not([data-theme-static]) { background-color: var(--color-card); }
.dark .bg-white\/80:not([data-theme-static]) { background-color: color-mix(in srgb, var(--color-card) 80%, transparent); }
.dark .bg-gray-50:not([data-theme-static]),
.dark .bg-slate-50:not([data-theme-static]) { background-color: var(--color-muted); }
.dark .bg-gray-100:not([data-theme-static]),
.dark .bg-slate-100:not([data-theme-static]) { background-color: var(--color-muted); }

.dark .text-gray-900:not([data-theme-static]),
.dark .text-slate-900:not([data-theme-static]) { color: var(--color-foreground); }
.dark .text-gray-800:not([data-theme-static]),
.dark .text-slate-800:not([data-theme-static]) { color: var(--color-foreground); }
.dark .text-gray-700:not([data-theme-static]),
.dark .text-slate-700:not([data-theme-static]) { color: var(--color-foreground); }
.dark .text-gray-600:not([data-theme-static]),
.dark .text-slate-600:not([data-theme-static]) { color: var(--color-muted-foreground); }
.dark .text-gray-500:not([data-theme-static]),
.dark .text-slate-500:not([data-theme-static]) { color: var(--color-muted-foreground); }
.dark .text-gray-400:not([data-theme-static]),
.dark .text-slate-400:not([data-theme-static]) { color: var(--color-muted-foreground); }

.dark .border-gray-200:not([data-theme-static]),
.dark .border-slate-200:not([data-theme-static]) { border-color: var(--color-border); }
.dark .border-gray-300:not([data-theme-static]),
.dark .border-slate-300:not([data-theme-static]) { border-color: var(--color-border); }

/*
 * Admin sidebar — fixed full-viewport column.
 * Off-canvas on mobile, permanently visible on desktop (≥1024px).
 * Toggled on mobile via the `open` state class from the mobile-menu controller.
 * On desktop we force `display: flex` so the controller's `hidden` toggling
 * (used for the public navbar mobile menu) can't take the sidebar down.
 */
.admin-sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  height: 100vh;
  transform: translateX(-100%);
  transition: transform 200ms ease-out;
}

.admin-sidebar.open {
  transform: translateX(0);
}

@media (min-width: 1024px) {
  .admin-sidebar {
    display: flex !important;
    width: 16rem;
    max-width: none;
    transform: translateX(0);
    transition: none;
  }
}

/* Admin sidebar — stays white in light mode, uses themed surface in dark mode. */
.dark aside[data-mobile-menu-target="menu"][data-theme-static] {
  background-color: var(--color-sidebar);
  color: var(--color-sidebar-foreground);
}

/* Calendar view toggle buttons */
.active-view {
  background-color: var(--color-primary);
  color: var(--color-primary-foreground);
}

.active-view:hover {
  opacity: 0.9;
}

.inactive-view {
  border: 1px solid var(--color-border);
  background-color: transparent;
  color: var(--color-foreground);
}

.inactive-view:hover {
  background-color: var(--color-secondary);
}

/* Pagy pagination */
.pagy.series-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.pagy.series-nav > a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md, 0.5rem);
  color: var(--color-foreground);
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}

.pagy.series-nav > a:hover:not([aria-disabled="true"]) {
  background-color: var(--color-muted);
}

.pagy.series-nav > a[aria-current="page"] {
  background-color: var(--color-primary);
  color: var(--color-primary-foreground);
}

.pagy.series-nav > a[aria-disabled="true"]:not([aria-current="page"]) {
  color: var(--color-muted-foreground);
  cursor: default;
  opacity: 0.5;
}

.pagy.series-nav > a[role="separator"] {
  opacity: 1;
  letter-spacing: 0.1em;
}

.pagy.series-nav > a[aria-label="Previous"],
.pagy.series-nav > a[aria-label="Next"] {
  font-size: 0;
  overflow: hidden;
}

.pagy.series-nav > a[aria-label="Previous"]::before,
.pagy.series-nav > a[aria-label="Next"]::before {
  content: "";
  display: block;
  width: 1rem;
  height: 1rem;
  background-color: currentColor;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

.pagy.series-nav > a[aria-label="Previous"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='currentColor' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M15 19l-7-7 7-7'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='currentColor' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M15 19l-7-7 7-7'/%3E%3C/svg%3E");
}

.pagy.series-nav > a[aria-label="Next"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='currentColor' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M9 5l7 7-7 7'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='currentColor' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M9 5l7 7-7 7'/%3E%3C/svg%3E");
}

/* ── Tournament bracket (/bracket) ────────────────────────────────────────── */
.tb-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 10px;
  -webkit-overflow-scrolling: touch;
}
.tb-frame { min-width: 1640px; }

/* Round-label header bar */
.tb-head {
  display: flex;
  align-items: stretch;
  margin-bottom: 16px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.tb-head-cell {
  flex: 0 0 176px;
  width: 176px;
  padding: 9px 10px;
  text-align: center;
  background: var(--color-primary);
  color: var(--color-primary-foreground);
  border-right: 1px solid color-mix(in srgb, var(--color-primary-foreground) 16%, transparent);
}
.tb-head-cell:last-child { border-right: 0; }
.tb-head-cell--center { flex: 0 0 220px; width: 220px; }
.tb-head-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tb-head-dates { display: block; font-size: 10px; opacity: 0.8; margin-top: 2px; }

/* Bracket grid */
.tb {
  display: flex;
  align-items: stretch;
  min-height: 640px;
  --g: 22px;
  --line: var(--color-border);
}
.tb-round { flex: 0 0 176px; width: 176px; display: flex; flex-direction: column; }
.tb-match { position: relative; flex: 1 1 0; display: flex; align-items: center; }
.tb-side-left .tb-match { justify-content: flex-start; }
.tb-side-right .tb-match { justify-content: flex-end; }

/* Match card */
.tb-card {
  position: relative;
  z-index: 1;
  width: calc(100% - var(--g));
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 6px 9px;
  font-size: 12px;
}
.tb-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.tb-card-status { font-size: 10px; font-weight: 600; color: var(--color-muted-foreground); }
.tb-card-num { font-size: 10px; color: var(--color-muted-foreground); }
.tb-team { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 2px 0; }
.tb-team + .tb-team { border-top: 1px solid var(--color-border); }
.tb-team-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--color-foreground); }
.tb-team-score { font-variant-numeric: tabular-nums; color: var(--color-muted-foreground); min-width: 12px; text-align: right; }
.tb-team--win .tb-team-name,
.tb-team--win .tb-team-score { font-weight: 700; color: var(--color-primary); }

/* ── Connectors ──
   Each card draws short horizontal stubs; odd matches draw the vertical "bus"
   that joins a pair. flex:1 on equal-height columns aligns parents to the
   midpoint of their two feeders automatically. */

/* LEFT side: out toward center (right), in from outer (left) */
.tb-side-left.has-next .tb-card::after,
.tb-side-left.out-only .tb-card::after {
  content: ""; position: absolute; top: 50%; left: 100%;
  width: var(--g); height: 2px; background: var(--line); transform: translateY(-50%);
}
.tb-side-left.has-next .tb-match:nth-child(odd)::after {
  content: ""; position: absolute; right: 0; top: 50%;
  width: 2px; height: 100%; background: var(--line);
}
.tb-side-left.has-prev .tb-card::before {
  content: ""; position: absolute; top: 50%; right: 100%;
  width: var(--g); height: 2px; background: var(--line); transform: translateY(-50%);
}

/* RIGHT side: mirror — out toward center (left), in from outer (right) */
.tb-side-right.has-next .tb-card::after,
.tb-side-right.out-only .tb-card::after {
  content: ""; position: absolute; top: 50%; right: 100%;
  width: var(--g); height: 2px; background: var(--line); transform: translateY(-50%);
}
.tb-side-right.has-next .tb-match:nth-child(odd)::after {
  content: ""; position: absolute; left: 0; top: 50%;
  width: 2px; height: 100%; background: var(--line);
}
.tb-side-right.has-prev .tb-card::before {
  content: ""; position: absolute; top: 50%; left: 100%;
  width: var(--g); height: 2px; background: var(--line); transform: translateY(-50%);
}

/* Center column: champion, final, third place */
.tb-center {
  flex: 0 0 220px; width: 220px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
}
.tb-final-wrap { position: relative; width: 100%; display: flex; justify-content: center; }
.tb-final-wrap::before {
  content: ""; position: absolute; top: 50%; left: 0; width: 100%; height: 2px;
  background: var(--line); transform: translateY(-50%); z-index: 0;
}
.tb-final-wrap .tb-card { width: 160px; }

.tb-champion {
  width: 100%;
  text-align: center;
  background: var(--color-primary);
  color: var(--color-primary-foreground);
  border-radius: var(--radius-md);
  padding: 12px 10px;
  box-shadow: var(--shadow-md);
}
.tb-champion-eyebrow { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.85; }
.tb-champion-name { font-size: 16px; font-weight: 800; margin-top: 2px; }

.tb-third { width: 100%; text-align: center; }
.tb-third-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-muted-foreground); margin-bottom: 6px; }
.tb-third .tb-card { width: 160px; margin: 0 auto; }

/* Bracket — vista por rondas (tabs): grid de 2 columnas, tarjetas grandes */
.bracket-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}
@media (min-width: 768px) { .bracket-grid { grid-template-columns: repeat(2, 1fr); } }

/* Tarjetas más grandes y legibles (estilo Mis Predicciones). El árbol mantiene
   su tamaño compacto: estos overrides están acotados a .bracket-grid. */
.bracket-grid .tb-card { width: 100%; padding: 16px 18px; border-radius: var(--radius-lg); font-size: 15px; }
.bracket-grid .tb-card-top { margin-bottom: 8px; }
.bracket-grid .tb-card-status,
.bracket-grid .tb-card-num { font-size: 12px; }
.bracket-grid .tb-team { padding: 7px 0; gap: 10px; }
.bracket-grid .tb-team-name { font-size: 16px; }
.bracket-grid .tb-team-score { font-size: 16px; min-width: 16px; }
.bracket-grid .tb-card-foot { margin-top: 0; padding-top: 8px; font-size: 12px; }

.bracket-grid-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted-foreground);
  margin-bottom: 8px;
}

/* Pie de tarjeta del bracket: sede + pick/acierto del usuario */
.tb-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid var(--color-border);
  font-size: 10px;
}
.tb-card-venue { color: var(--color-muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-card-pick { flex-shrink: 0; white-space: nowrap; color: var(--color-muted-foreground); }
.tb-card-pick--hit { color: var(--color-success); font-weight: 700; }
.tb-card-pick--miss { color: var(--color-destructive); }

/* Predicciones: opción de pick con estado "seleccionado" inmediato (sin JS) */
.pick-option { border-color: var(--color-border); color: var(--color-foreground); }
.pick-option:hover { background-color: var(--color-secondary); }
.pick-option:has(input:checked) {
  border-color: var(--color-primary);
  background-color: color-mix(in srgb, var(--color-primary) 12%, transparent);
  color: var(--color-primary);
  font-weight: 600;
}
.pick-option:has(input:focus-visible) { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* Tarjeta del bracket como enlace al detalle (sin alterar el layout/conectores) */
.tb-card-link { display: contents; color: inherit; }
.tb-card-link .tb-card { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.tb-card-link:hover .tb-card { border-color: var(--color-primary); box-shadow: var(--shadow-md); }

/* iOS Safari hace zoom al enfocar un input con font-size < 16px. Forzamos 16px
   en los campos de formulario en móvil para evitarlo (sin tocar el pinch-zoom). */
@media (max-width: 767px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select,
  textarea {
    font-size: 16px;
  }
}
