/* Estadio Nocturno — mobile-first theme */
:root {
  --bg: #0f1419;
  --surface: #161c23;
  --border: #232a33;
  --accent: #5f9e7e;
  --accent-contrast: #08130d;
  --text: #e6edf3;
  /* Raised from #8b949e (contrast ~3.8:1 on --bg) to meet AA 4.5:1 for normal text */
  --text-muted: #9daab5;
  --danger: #f7768e;
}

/* Reset & base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  /* Prevent horizontal overflow at root level */
  overflow-x: hidden;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* Prevent body horizontal scroll */
  overflow-x: hidden;
}

/* ─── Global focus outlines (a11y) ─── */
/* Fallback for engines/contexts where :focus-visible doesn't fire */
:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
/* Modern engines: only show outline on keyboard/programmatic focus */
:focus:not(:focus-visible) {
  outline: none;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ─── Skip navigation link (a11y) ─── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.5rem 1rem;
  border-radius: 0 0 4px 4px;
  font-weight: 700;
  z-index: 9999;
  text-decoration: none;
  transition: top 0.1s;
}

.skip-link:focus {
  top: 0;
}

/* ─── App shell ─── */
#app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ─── Top nav ─── */
.top-nav {
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.25rem;
  position: sticky;
  top: 0;
  z-index: 100;
  /* Prevent content overflow on narrow screens */
  overflow: hidden;
}

.top-nav__brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.02em;
  /* Ensure brand never gets crushed off screen */
  flex-shrink: 0;
  white-space: nowrap;
}

.top-nav__brand:hover {
  color: var(--text);
}

.top-nav__actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  /* Allow actions to shrink/wrap on small screens */
  min-width: 0;
}

/* Nav auth links — ensure tap-target size (48px high recommended) */
.top-nav__auth-link {
  display: inline-block;
  padding: 0.4rem 0.6rem;
  min-height: 36px;
  line-height: 1.4;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: color 0.15s;
  white-space: nowrap;
}

.top-nav__auth-link:hover {
  color: var(--text);
}

.top-nav__auth-link--accent {
  background-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

.top-nav__auth-link--accent:hover {
  opacity: 0.85;
  color: var(--accent-contrast);
}

.top-nav__auth,
.top-nav__groups {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.top-nav__username {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Logout button styled as link */
.top-nav__auth form button.top-nav__auth-link {
  background: transparent;
  border: none;
  cursor: pointer;
}

/* ─── Utility ─── */
.text-muted-theme {
  color: var(--text-muted);
}

/* ─── Language switcher ─── */
.lang-switcher {
  display: flex;
  gap: 0.25rem;
}

.lang-switcher form {
  margin: 0;
  display: contents;
}

.lang-switcher a,
.lang-switcher button {
  font-size: 0.8rem;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.lang-switcher a:hover,
.lang-switcher button:hover,
.lang-switcher a.active,
.lang-switcher button.active {
  color: var(--accent);
  border-color: var(--accent);
}

/* ─── Main content ─── */
.main-content {
  flex: 1;
  padding: 1.5rem 1rem;
  width: 100%;
  /* Prevent content from escaping its container on narrow viewports */
  min-width: 0;
  overflow-x: hidden;
}

/* ─── Footer ─── */
.app-footer {
  background-color: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.app-footer a {
  color: var(--text-muted);
  text-decoration: underline;
  transition: color 0.15s;
}

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

.app-footer__links {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}

/* ─── Card / surface ─── */
.card-dark {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
}

/* ─── Hero ─── */
.hero {
  text-align: center;
  padding: 3rem 1rem;
}

.hero__title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.hero__title span {
  color: var(--accent);
}

.hero__subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.hero__cta {
  display: inline-flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ─── Buttons ─── */
.btn-accent {
  background-color: var(--accent);
  color: var(--accent-contrast);
  border: none;
  padding: 0.65rem 1.4rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: opacity 0.15s;
}

.btn-accent:hover {
  opacity: 0.85;
  color: var(--accent-contrast);
}

.btn-outline {
  background-color: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.65rem 1.4rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background-color 0.15s, color 0.15s;
}

.btn-outline:hover {
  background-color: var(--accent);
  color: var(--accent-contrast);
}

/* ─── Alerts / banners ─── */
.alert-danger {
  background-color: rgba(247, 118, 142, 0.1);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

/* ─── Typography ─── */
h1,
h2,
h3,
h4 {
  color: var(--text);
  margin-top: 0;
}

a {
  color: var(--accent);
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* ─── Layout: main + sidebar ─── */
.layout-with-sidebar__main {
  min-width: 0; /* prevent grid blowout */
}

/* ─── News panel ─── */
.news-panel {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.875rem;
}

.news-panel__title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.news-panel__toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.25rem 0;
  cursor: pointer;
}

.news-panel__toggle-icon {
  font-size: 0.8rem;
  transition: transform 0.2s;
}

.news-panel__list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.news-panel__item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.news-panel__item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.news-panel__link {
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  line-height: 1.4;
  transition: color 0.15s;
}

.news-panel__link:hover {
  color: var(--accent);
}

.news-panel__source {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.news-panel__empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
}

/* ─── Responsive tables ─── */
/* Any table inside .table-responsive already handles overflow on Bootstrap,
   but we add this for any non-Bootstrap tables too */
table {
  max-width: 100%;
}

/* ─── Ensure Bootstrap containers don't overflow on mobile ─── */
.container,
.container-fluid {
  overflow-x: hidden;
}

/* ─── Match cards mobile layout ─── */
@media (max-width: 575px) {
  /* Prevent score-stepper from overflowing narrow cards */
  .score-stepper {
    flex-wrap: wrap;
  }

  /* Make sure match teams don't overflow */
  .match-card .card-body {
    overflow-x: hidden;
  }

  /* Ranking table — stack on very narrow screens handled via Bootstrap table-responsive */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ─── Desktop expansion at 768px+ ─── */
@media (min-width: 768px) {
  .main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
  }

  .hero__title {
    font-size: 2.8rem;
  }

  .hero__subtitle {
    font-size: 1.2rem;
  }

  /* Side-panel layout hook */
  .layout-with-sidebar {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1.5rem;
    align-items: start;
  }

  /* On desktop expand nav brand slightly */
  .top-nav__brand {
    font-size: 1.2rem;
  }
}

/* ─── Mobile nav: hide sidebar (news) below 768px; shown as collapsible ─── */
@media (max-width: 767px) {
  /* On mobile the sidebar stacks below main content; give it some breathing room */
  .layout-with-sidebar .news-panel {
    margin-top: 1rem;
  }
}
