/* =============================================================================
 * ScoreEnDirect — Football sidebar
 * Onglets Populaires / Pays & ligues + accordeon + recherche
 * ============================================================================ */

/* ---------- LAYOUT wrapper : sidebar + livescore ---------- */
.football-layout {
  display: block;
}

@media (min-width: 1000px) {
  .football-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 16px;
    align-items: flex-start;
  }
  .football-layout .widget-shell {
    min-width: 0;
  }
}

/* ---------- SIDEBAR container ---------- */
.football-sidebar {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}

@media (min-width: 1000px) {
  .football-sidebar {
    position: sticky;
    top: 12px;
    max-height: calc(100vh - 24px);
    display: flex;
    flex-direction: column;
  }
}

/* ---------- MOBILE : drawer (pas de trigger dedie, on utilise #btn-menu) ---------- */
@media (max-width: 999px) {
  /* Synchronisation breakpoint : styles.css ne montre le hamburger header
     qu'a partir de <=960px. En mode drawer (<=999px), on force son affichage
     pour couvrir la fenetre 961..999px ou sinon aucun trigger n'est visible. */
  .header__menu-btn { display: grid !important; place-items: center; }

  .football-sidebar {
    position: fixed;
    top: 0; left: 0;
    /* 100dvh survit a la mobile URL bar : sans ca, le footer scrollable se
       retrouve sous le fold quand la barre d'adresse est visible.
       Fallback 100vh pour navigateurs sans support dvh. */
    height: 100vh;
    height: 100dvh;
    width: min(88vw, 320px);
    max-height: none;
    z-index: 100;
    border-radius: 0;
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 220ms ease;
    display: flex;
    flex-direction: column;
  }
  .football-sidebar.is-open {
    transform: translateX(0);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.22);
  }
  .football-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
  }
  .football-sidebar-backdrop.is-open { display: block; }
  .fs-close {
    display: inline-flex;
    padding: 4px;
    background: transparent;
    border: 0;
    color: var(--text-muted);
    cursor: pointer;
    margin-left: auto;
  }
  /* Body scroll lock : quand la sidebar est ouverte, on empeche le body de
     scroller derriere (evite que le user tape sur la sidebar et fasse defiler
     le livescore). Applique par football-sidebar.js. */
  body.fs-body-locked {
    overflow: hidden;
    /* On preserve la position pour eviter le "jump-to-top" que provoque
       overflow:hidden seul quand la page est deja scrollee. */
    position: fixed;
    inset: 0;
    width: 100%;
  }
}

@media (min-width: 1000px) {
  .fs-close { display: none; }
  .football-sidebar-backdrop { display: none !important; }
}

/* ---------- TABS ---------- */
.fs-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 4px;
  gap: 2px;
  flex-shrink: 0;
}
.fs-tab {
  flex: 1 1 0;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  color: var(--text-muted, #5a6577);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  transition: background 120ms, color 120ms;
}
.fs-tab:hover { background: var(--bg-elev-2, rgba(0,0,0,0.04)); color: var(--text-strong); }
.fs-tab.is-active {
  background: var(--accent, #1a56db);
  color: #fff;
}

/* ---------- SEARCH (Pays & ligues only) ---------- */
.fs-search {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  flex-shrink: 0;
}
.fs-search input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elev-2, #fff);
  font-size: 12.5px;
  color: var(--text-strong);
}
.fs-search input:focus {
  outline: none;
  border-color: var(--accent, #1a56db);
}

/* ---------- SCROLL AREA : container unique qui contient panels + see-all ----
 * Un seul conteneur scrollable dans la sidebar : atteindre le bas de la sidebar
 * amene naturellement sur "Voir toutes les competitions" (dernier enfant).
 * Aucun footer sticky, aucun position:fixed. Aucun 2eme scrollbar.
 * ------------------------------------------------------------------------- */
.fs-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;   /* stoppe la propagation du swipe vers body */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  min-height: 0;                  /* iOS/flex : necessaire pour que overflow prenne effet */
}

/* Les panels ne scrollent PLUS eux-memes : ils font partie du flow de .fs-scroll.
 * Cache/affiche via attribut hidden ; l'unique panel visible dicte la hauteur. */
.fs-panel { display: block; }
.fs-panel[hidden] { display: none; }

/* ---------- LIST LIGUES (Populaires + accordeon items) ---------- */
.fs-league-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
}
.fs-league-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  color: var(--text-strong, #0f172a);
  text-decoration: none;
  transition: background 100ms;
  border-radius: 4px;
  margin: 1px 4px;
  font-size: 12.5px;
  line-height: 1.25;
}
.fs-league-item:hover {
  background: var(--bg-elev-2, rgba(0,0,0,0.05));
}
.fs-league-item.is-active {
  background: var(--accent-bg, rgba(26, 86, 219, 0.10));
  color: var(--accent, #1a56db);
  font-weight: 600;
}
.fs-league-flag {
  width: 16px;
  height: 12px;
  flex-shrink: 0;
  border-radius: 2px;
  object-fit: cover;
  display: block;
  background: var(--bg-elev-2, #eee);
}
.fs-league-labels {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}
.fs-league-name {
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fs-league-country {
  font-size: 11px;
  color: var(--text-muted, #5a6577);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- ACCORDEON PAYS ---------- */
.fs-country-group { border-bottom: 1px solid var(--border); }
.fs-country-group:last-child { border-bottom: 0; }
.fs-country-letter {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted, #5a6577);
  background: var(--bg-elev-2, rgba(0,0,0,0.03));
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.fs-country-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: 0;
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 100ms;
}
.fs-country-header:hover {
  background: var(--bg-elev-2, rgba(0,0,0,0.04));
}
.fs-country-flag {
  width: 16px;
  height: 12px;
  flex-shrink: 0;
  border-radius: 2px;
  object-fit: cover;
  background: var(--bg-elev-2, #eee);
}
.fs-country-name { flex: 1; }
.fs-country-count {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}
.fs-country-caret {
  transition: transform 150ms;
  color: var(--text-muted);
}
.fs-country-header[aria-expanded="true"] .fs-country-caret {
  transform: rotate(90deg);
}
.fs-country-leagues {
  padding: 2px 0 6px;
  background: var(--bg-elev, #fff);
}
.fs-country-leagues[hidden] { display: none; }
.fs-country-leagues .fs-league-item {
  padding-left: 32px;
  font-size: 12px;
}

/* ---------- SEE ALL (dernier element DU scroll, PAS un footer sticky) ------ */
.fs-see-all {
  display: block;
  padding: 12px;
  margin-top: 6px;
  border-top: 1px solid var(--border);
  color: var(--accent, #1a56db);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  background: var(--bg-elev);
}
.fs-see-all:hover { text-decoration: underline; }

/* ---------- DARK THEME adjust ---------- */
[data-theme="dark"] .fs-search input {
  background: var(--bg-elev-2, #182338);
  color: var(--text-strong, #e8eefc);
}
[data-theme="dark"] .fs-country-letter {
  background: rgba(255, 255, 255, 0.03);
}

/* API-Football logos: fixed footprint in both themes and the mobile drawer. */
#football-sidebar .fs-league-logo {
  width: 22px; height: 22px; flex: 0 0 22px;
  object-fit: contain; display: block;
}

/* Preserve dark/transparent API-Football artwork on a neutral logo surface. */
[data-theme="dark"] #football-sidebar .fs-league-logo {
  background: #fff; padding: 1px; border-radius: 3px; box-sizing: border-box;
}

#football-sidebar .fs-league-country { display: flex; align-items: center; gap: 4px; }
#football-sidebar .fs-league-country-emblem { width: 13px; height: 10px; object-fit: contain; flex: 0 0 13px; }
#football-sidebar .fs-country-flag--international { height: 16px; object-fit: contain; }

/* Keep the loaded navigation frame stable across home, league and match pages. */
@media(min-width:1000px){.football-sidebar[data-sidebar-ssr="1"]{top:calc(var(--sed-header-height,56px) + 12px);height:calc(100dvh - var(--sed-header-height,56px) - 24px);max-height:calc(100dvh - var(--sed-header-height,56px) - 24px);}}
