/**
 * Fil: /assets/css/tabeller.css
 * Syfte: Publik sida för grupp-tabeller och matcher.
 *
 * Tabeller:
 * - rena och läsbara
 * - flaggor i lagkolumnen
 *
 * Matchkort:
 * - flaggor via samma sprite-system som /user/tip_matches.php
 * - arena
 * - mer likt gamla VM-tipset
 */

/* Sida */
.tabeller-page {
  max-width: 1180px;
  margin: 0 auto;
}

.tabeller-page-title {
  margin-bottom: 1rem;
}

.tabeller-page-title h1 {
  margin-bottom: .15rem;
}

/* Grid med gruppkort */
.tabeller-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

/* Gruppkort */
.tabeller-card {
  background: #fff;
  border: 1px solid var(--ft-border-color);
  border-radius: .9rem;
  box-shadow: 0 .125rem .35rem rgba(0,0,0,.06);
  overflow: hidden;
}

.tabeller-card-header {
  padding: .9rem 1rem .65rem;
  border-bottom: 1px solid var(--ft-border-color-soft);
  background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
}

.tabeller-group-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 850;
  line-height: 1.15;
}

.tabeller-card-body {
  padding: .75rem 1rem 1rem;
}

/* Tabell */
.tabeller-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.tabeller-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}

.tabeller-table th,
.tabeller-table td {
  padding: .45rem .35rem;
  border-bottom: 1px solid var(--ft-border-color-soft);
  vertical-align: middle;
}

.tabeller-table thead th {
  color: #495064;
  font-weight: 850;
  text-align: center;
  white-space: nowrap;
  border-bottom: 2px solid var(--ft-border-color);
}

.tabeller-table tbody tr:last-child td {
  border-bottom: 0;
}

.tabeller-team-cell {
  min-width: 8.9rem;
  padding-left: .25rem !important;
}

.tabeller-team-main {
  display: flex;
  align-items: center;
  gap: .42rem;
  min-width: 0;
}

.tabeller-team-name {
  display: block;
  font-weight: 800;
  line-height: 1.12;
  overflow-wrap: anywhere;
  min-width: 0;
}

.tabeller-num {
  text-align: center;
  white-space: nowrap;
  font-weight: 650;
  color: #444b5d;
}

.tabeller-points {
  text-align: center;
  white-space: nowrap;
  font-weight: 900;
  color: #1f2633;
}

/*
 * Flaggor.
 *
 * Samma princip som i /user/tip_matches.php:
 * sprite-elementet får behålla sin egen form,
 * vi skalar bara ner det.
 */
.tabeller-flag {
  display: inline-block;
  width: auto;
  height: auto;
  line-height: 1;
  flex: 0 0 auto;
}

.tabeller-flag-sprite {
  transform: scale(.46);
  transform-origin: center center;
  margin: 0;
}

.tabeller-flag-placeholder {
  display: inline-block;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 999px;
  background: #e9ecef;
  border: 1px solid var(--ft-border-color-soft);
}

/* Match-toggle */
.tabeller-match-toggle-wrap {
  padding-top: .75rem;
  text-align: center;
}

.tabeller-match-toggle {
  border: 0;
  background: #f1f3f5;
  color: #1f2633;
  font-weight: 850;
  font-size: 1rem;
  padding: .55rem .85rem;
  border-radius: .65rem;
}

.tabeller-match-toggle:hover,
.tabeller-match-toggle:focus {
  background: #e9ecef;
  color: #111827;
}

.tabeller-match-toggle .fa-chevron-down {
  transition: transform .18s ease;
}

.tabeller-match-toggle[aria-expanded="true"] .fa-chevron-down {
  transform: rotate(180deg);
}

/* Matchlista */
.tabeller-matches {
  margin-top: .8rem;
  display: grid;
  gap: .7rem;
}

.tabeller-match-card {
  border: 1px solid var(--ft-border-color);
  border-radius: .85rem;
  padding: .85rem;
  background: #fff;
  box-shadow:
    inset 0 0 0 3px rgba(0,0,0,.025),
    0 .08rem .18rem rgba(0,0,0,.04);
}

.tabeller-match-time {
  text-align: center;
  font-weight: 850;
  color: #495064;
  margin-bottom: .45rem;
  font-size: 1rem;
  word-spacing: .45rem;
}

.tabeller-match-title {
  text-align: center;
  font-weight: 850;
  color: #1f2633;
  margin-bottom: .45rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.tabeller-match-flags {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  margin-bottom: .45rem;
}

.tabeller-match-flags .tabeller-flag-sprite {
  transform: scale(.58);
}

.tabeller-match-flags .tabeller-flag-placeholder {
  width: 2.25rem;
  height: 2.25rem;
}

.tabeller-match-result {
  text-align: center;
  font-weight: 900;
  font-size: 1.1rem;
  color: #1f2633;
  white-space: nowrap;
  margin-bottom: .35rem;
}

.tabeller-match-venue {
  text-align: center;
  color: var(--ft-muted);
  font-size: .88rem;
  font-weight: 650;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

/* Bästa grupptreor */
.tabeller-third-row-qualified {
  background: rgba(25, 135, 84, 0.80);
}

.tabeller-third-row-out {
  background: rgba(220, 53, 69, 0.80);
}

.tabeller-third-row-qualified .tabeller-third-rank,
.tabeller-third-row-qualified .tabeller-team-name,
.tabeller-third-row-qualified .tabeller-points {
  font-weight: 800;
}

.tabeller-third-row-out .tabeller-third-rank,
.tabeller-third-row-out .tabeller-team-name {
  font-weight: 800;
}

.tabeller-third-note {
  line-height: 1.45;
}

/* Bästa grupptreor - kompaktare och mindre radbrytning */
.tabeller-third-table {
  table-layout: auto;
}

.tabeller-third-table th,
.tabeller-third-table td {
  padding-left: .28rem;
  padding-right: .28rem;
}

.tabeller-third-place-head,
.tabeller-third-place-cell {
  width: 2.4rem;
  min-width: 2.4rem;
}

.tabeller-third-table .tabeller-team-cell {
  min-width: 0;
  padding-left: .2rem !important;
}

.tabeller-third-table .tabeller-team-main {
  gap: .28rem;
  flex-wrap: nowrap;
}

.tabeller-third-table .tabeller-team-name {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.tabeller-third-table .tabeller-flag-sprite {
  transform: scale(.42);
}

.tabeller-third-table .tabeller-flag-placeholder {
  width: 1.45rem;
  height: 1.45rem;
}

/* Tomma lägen */
.tabeller-empty {
  padding: 1rem;
  color: var(--ft-muted);
  background: #f8f9fa;
  border-radius: .6rem;
  text-align: center;
}

/* Mobil */
@media (max-width: 992px) {
  .tabeller-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 576px) {
  .tabeller-page-title h1 {
    font-size: 1.55rem;
  }

  .tabeller-card {
    border-radius: .8rem;
  }

  .tabeller-card-header {
    padding: .85rem .85rem .6rem;
  }

  .tabeller-card-body {
    padding: .65rem .75rem .85rem;
  }

  .tabeller-group-title {
    font-size: 1.45rem;
  }

  .tabeller-table {
    font-size: .84rem;
  }

  .tabeller-table th,
  .tabeller-table td {
    padding: .42rem .21rem;
  }

  .tabeller-team-cell {
    min-width: 8.1rem;
    padding-left: .25rem !important;
  }

  .tabeller-team-main {
    gap: .34rem;
  }

  .tabeller-team-name {
    font-size: .9rem;
  }

  .tabeller-flag-sprite {
    transform: scale(.42);
  }

  .tabeller-flag-placeholder {
    width: 1.5rem;
    height: 1.5rem;
  }

  .tabeller-third-place-head,
  .tabeller-third-place-cell {
    width: 1.8rem;
    min-width: 1.8rem;
  }

  .tabeller-third-table th,
  .tabeller-third-table td {
    padding-left: .18rem;
    padding-right: .18rem;
  }

  .tabeller-third-table .tabeller-team-cell {
    min-width: 0;
    padding-left: .12rem !important;
  }

  .tabeller-third-table .tabeller-team-main {
    gap: .2rem;
  }

  .tabeller-third-table .tabeller-team-name {
    font-size: .86rem;
  }

  .tabeller-third-table .tabeller-flag-sprite {
    transform: scale(.38);
  }

  .tabeller-third-table .tabeller-flag-placeholder {
    width: 1.35rem;
    height: 1.35rem;
  }

  .tabeller-match-card {
    padding: .75rem .65rem;
  }

  .tabeller-match-time {
    font-size: .98rem;
    word-spacing: .4rem;
  }

  .tabeller-match-title {
    font-size: 1rem;
  }

  .tabeller-match-flags {
    gap: 1rem;
  }

  .tabeller-match-flags .tabeller-flag-sprite {
    transform: scale(.55);
  }

  .tabeller-match-flags .tabeller-flag-placeholder {
    width: 2.15rem;
    height: 2.15rem;
  }

  .tabeller-match-result {
    font-size: 1.05rem;
  }
}