/* =========================================================
   GRUNDLAYOUT
========================================================= */

.history-page{
  position: relative;
  min-height: 100vh;
}

/* Bakgrundsbild */
.history-page::before{
  content:"";
  position: fixed;
  inset: 0;
  background: url("/static/img/history_thl-bg.png") center / cover no-repeat;
  opacity: 0.75;
  z-index: -2;
  pointer-events: none;
}

/* Ljus overlay ovanpå bakgrunden */
.history-page::after{
  content:"";
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.50);
  z-index: -1;
  pointer-events: none;
}

/* Innehållswrapper */
.history-page-wrap{
  position: relative;
  z-index: 2;
  padding: 28px 18px;
  max-width: 1200px;
  margin: 0 auto;
}

/* Tillbaka-länk */
.history-back-link{
  display: block;
  width: fit-content;
  margin: 0 0 8px 0;
  padding: 0;
  color: #1f2937;
  font-weight: 600;
  text-decoration: none;
  text-align: left;
}

.history-back-link:hover{
  text-decoration: underline;
}


/* =========================================================
   GEMENSAMMA KORT / TABELLER
========================================================= */

.history-card{
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
  text-align: left;
  box-sizing: border-box;
}

.history-card h2,
.history-card h3{
  text-align: left;
}

.history-card h3{
  margin: 0 0 10px 0;
  font-family: "EurostileExtended", Arial, sans-serif;
  letter-spacing: .5px;
}

.history-card p,
.history-card li{
  text-align: left;
}

.history-card .history-meta{
  font-size: 14px;
  line-height: 1.45;
  color: #374151;
}

.history-card .history-winner{
  font-weight: 700;
}

/* Mindre kort i t.ex. grupp-/slutspelsdelar */
.sub-card{
  background: #fff;
  border: 1px solid #e7e7e7;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}

.sub-card h4{
  margin: 0 0 10px 0;
}

/* Grid / block / badges / listor */
.history-grid-2{
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
  gap: 24px;
}

.history-grid-3{
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr) minmax(260px, 1fr);
  gap: 24px;
}

.history-block{
  margin-top: 16px;
}

.history-game-type{
  margin-top: 8px;
}

.history-badge{
  display: inline-block;
  background: #66aee8;
  color: #fff;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

/* 🔵 Mörkare för ProHockey */
.history-badge.pro{
  background: #2f6fa3;   /* mörkare blå */
}

.history-bullets{
  margin: 8px 0 0 18px;
  padding: 0;
}

.phase-subtitle{
  margin-top: 4px;
  color: #555;
  font-size: 14px;
}

/* Gemensamma tabeller */
.table-wrap{
  overflow-x: auto;
  margin-top: 8px;
}

.history-table{
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.history-table th,
.history-table td{
  border-bottom: 1px solid #eee;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid #eee;
}

.history-table thead th{
  font-size:13px;
  text-transform:uppercase;
  letter-spacing:.6px;
  color:#333;
  font-weight:400;
}

.history-table tbody tr:hover{
  background: rgba(99,172,232,0.08);
}

.history-table thead tr{
  background: rgba(195,183,166,0.2);
  border-bottom: 2px solid rgba(0,0,0,0.05);
}

.history-table th,
.history-table td{
  padding:8px 10px;
  border-bottom:1px solid #eee;
}

.history-table tbody tr:last-child td{
  border-bottom: none;
}

.group-phase-block{
  margin-top: 22px;
}

.group-phase-block:first-of-type{
  margin-top: 14px;
}

.group-phase-block h4{
  margin: 0 0 10px 0;
  font-size: 28px;
  font-family: "EurostileExtended", Arial, sans-serif;
  letter-spacing: .4px;
}

.group-phase-block .match-list{
  margin-bottom: 14px;
}

.history-date{
  color: #a74c3c; /*Färgen på datumer history-korten*/
  font-weight: 700;
}


/* =========================================================
   HISTORY-RUBRIKEN
========================================================= */
.history-list-top{
  margin-bottom: 18px;
}

.history-list-top .history-title{
  padding-bottom: 12px;
}

.history-list-top .history-sub{
  margin-top: 8px;
  min-height: auto;
}

.history-list-top .subtitle-main{
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
  text-align: left;
}

.history-list-top .subtitle-sub{
  font-size: 13px;
  color: #806b71;
  font-weight: 500;
}


/* =========================================================
   HISTORY-LISTA
========================================================= */

.history-list{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;              /* ← detta skapar luft mellan korten */
  max-width: 1200px;
  margin: 0 auto;
}

/* Hover bara på översiktskorten */
#history-list .history-card{
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 18px 20px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  cursor: pointer;
}

#history-list .history-card:hover{
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.14);
  background: rgba(255,255,255,0.97);
}

.history-inline-gap{
  display: inline-block;
  width: 18px;
}

.history-meta > div{
  margin-top: 4px;
}

.history-meta > div:first-child{
  margin-top: 0;
}


/* =========================================================
   HISTORY-DETAIL – TOPPSEKTION / TABS / FILTER
========================================================= */

.history-top{
  display: flex;
  gap: 14px;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* Titelblock */
.history-title{
  position: relative;
  padding-bottom: 12px;
}

.history-title h1{
  margin: 0;
  font-family: "EurostileExtended", Arial, sans-serif;
  letter-spacing: 1px;
}

.history-title::after{
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 60px;
  height: 3px;
  background: #63ace8;
  border-radius: 2px;
}

.history-sub{
  margin-top: 6px;
  min-height: 42px;
  line-height: 1.2;
  text-align: left;
}

.subtitle-main{
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.4px;
  margin-bottom: 2px;
  text-align: left;
}

.subtitle-sub{
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
}

/* Tabs */
.history-tabs{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.history-tab-btn{
  border: 1px solid #ddd;
  background: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.history-tab-btn:hover{
  filter: brightness(0.96);
}

.history-tab-btn.active{
  border-color: #9ecc71;
  background: #63ace8;
  color: #fff;
}

.history-tab{
  display: none;
}

.history-tab.active{
  display: block;
}

/* Filterkort */
.history-filters{
  display: none;
}

.history-card.history-filters{
  padding: 22px 26px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.history-filters .history-help{
  margin-top: 8px;
  font-size: 12px;
  text-align: center;
  color: #6b7280;
}

.history-filters button{
  margin-left: auto;
}

.history-filters .filters{
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  flex-wrap: wrap;
}

.history-filters .btn-primary{
  margin-left: auto;
}

.history-filters label:first-child{
  margin-right: 16px;
}

.btn-primary{
  background: #66aee8;
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: 10px;
  cursor: pointer;
}

.btn-primary:hover{
  filter: brightness(0.95);
}


/* =========================================================
   HISTORY-DETAIL – STANDINGS / LAGSTATISTIK
========================================================= */

.history-standings-table{
  table-layout: auto;
}

.history-standings-table th,
.history-standings-table td{
  text-align: center;
}

.history-standings-table th:first-child,
.history-standings-table td:first-child{
  width: 15%;
  white-space: nowrap;
  padding-left: 6px;
  padding-right: 6px;
}

.history-standings-table th:nth-child(2),
.history-standings-table td:nth-child(2){
  text-align: left;
  width: 180px;
}

/* Standings som stats-sidan */
.history-stats-standings{
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.history-stats-standings th,
.history-stats-standings td{
  border-bottom: 1px solid #eee;
  padding: 8px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/*.history-stats-standings tbody tr:nth-child(even){
  background: #f8fafc;
}*/

/* # */
.history-stats-standings th:nth-child(1),
.history-stats-standings td:nth-child(1){
  width: 5ch;
  min-width: 5ch;
  max-width: 5ch;
  text-align: left;
  padding-right: 8px;
  font-variant-numeric: tabular-nums;
}

/* Team */
.history-stats-standings th:nth-child(2),
.history-stats-standings td:nth-child(2){
  width: 180px;
  text-align: left;
}

/* Övriga kolumner */
.history-stats-standings th:nth-child(n+3),
.history-stats-standings td:nth-child(n+3){
  text-align: center;
}

/* Sektioner */
.history-stats-standings th:nth-child(7),
.history-stats-standings td:nth-child(7){
  padding-left: 30px;
  border-left: 1px solid #eee;
}

.history-stats-standings th:nth-child(10),
.history-stats-standings td:nth-child(10){
  padding-left: 30px;
  border-left: 1px solid #eee;
}

.history-stats-standings th:nth-child(13),
.history-stats-standings td:nth-child(13){
  padding-left: 30px;
  border-left: 1px solid #eee;
}

.history-stats-standings .pos{
  color: #17823b;
  font-weight: 500;
}

.history-stats-standings .neg{
  color: #d93025;
  font-weight: 500;
}

/* Gruppspelsrubrik på en rad */
.group-phase-table-title{
  margin: 0 0 10px 0;
  font-family: "EurostileExtended", Arial, sans-serif;
  letter-spacing: .5px;
  font-size: 16px;
  text-align: left;
}

/* Samma tabellstil som facit */
.history-stats-standings th:last-child,
.history-stats-standings td:last-child{
  font-weight: 700;
}

/* Positiv/negativ +/- och S± */
.history-stats-standings .pos{
  color: #17823b;
  font-weight: 500;
}

.history-stats-standings .neg{
  color: #d93025;
  font-weight: 500;
}

/* =========================================================
   HISTORY – RUBRIKBAKGRUND FÖR TABELLRUBRIKER
========================================================= */

.history-stats-standings thead th,
.history-players-table thead th,
.history-goalies-table thead th,
#dangerTableHistory thead th,
.history-position-table thead th{
  background: rgba(195, 183, 166, 0.2);
  border-bottom: 2px solid rgba(0,0,0,0.05);
  color: #6b7280;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 400;
}


/* =========================================================
   HISTORY-DETAIL – SPELARSTATISTIK / MÅLVAKTSLIGA
========================================================= */

.filters{
  display:flex;
  gap:16px;
  align-items:center;
  flex-wrap:wrap;
}

#resetPlayers,
#resetPositions{
  margin-left: auto;
}

.history-players-table,
.history-goalies-table{
  table-layout: fixed;
}

/* SPELARSTATISTIK */
.history-players-table th:nth-child(1),
.history-players-table td:nth-child(1){
  width: 5ch;
  min-width: 5ch;
  max-width: 5ch;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.history-players-table th:nth-child(2),
.history-players-table td:nth-child(2){
  width: 7ch;
  text-align: left;
}

.history-players-table th:nth-child(3),
.history-players-table td:nth-child(3){
  width: 15%;
}

.history-players-table th:nth-child(4),
.history-players-table td:nth-child(4){
  width: 14%;
}

.history-players-table th:nth-child(5),
.history-players-table td:nth-child(5),
.history-players-table th:nth-child(6),
.history-players-table td:nth-child(6){
  width: 7ch;
  text-align: center;
}

.history-players-table th:nth-child(7),
.history-players-table td:nth-child(7),
.history-players-table th:nth-child(9),
.history-players-table td:nth-child(9),
.history-players-table th:nth-child(10),
.history-players-table td:nth-child(10){
  width: 8ch;
  text-align: center;
}

.history-players-table th:nth-child(8),
.history-players-table td:nth-child(8){
  width: 9ch;
  text-align: center;
}

.history-players-table td:nth-child(3),
.history-players-table td:nth-child(4){
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-players-table th:nth-child(n+5),
.history-players-table td:nth-child(n+5){
  text-align: center;
}

/* MÅLVAKTSLIGA */
.history-goalies-table th:nth-child(1),
.history-goalies-table td:nth-child(1){
  width: 5ch;
  min-width: 5ch;
  max-width: 5ch;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.history-goalies-table th:nth-child(2),
.history-goalies-table td:nth-child(2){
  width: 7ch;
  text-align: left;
}

.history-goalies-table th:nth-child(3),
.history-goalies-table td:nth-child(3){
  width: 15%;
}

.history-goalies-table th:nth-child(4),
.history-goalies-table td:nth-child(4){
  width: 14%;
}

.history-goalies-table th:nth-child(5),
.history-goalies-table td:nth-child(5),
.history-goalies-table th:nth-child(6),
.history-goalies-table td:nth-child(6){
  width: 7ch;
  text-align: center;
}

.history-goalies-table th:nth-child(7),
.history-goalies-table td:nth-child(7){
  width: 8ch;
  text-align: center;
}

.history-goalies-table th:nth-child(8),
.history-goalies-table td:nth-child(8),
.history-goalies-table th:nth-child(9),
.history-goalies-table td:nth-child(9){
  width: 10ch;
  text-align: center;
}

.history-goalies-table th:nth-child(10),
.history-goalies-table td:nth-child(10){
  width: 8ch;
  text-align: center;
  font-weight: 600;
}

.history-goalies-table td:nth-child(3),
.history-goalies-table td:nth-child(4){
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* =========================================================
   HISTORY-DETAIL – MATCHLISTOR / NYCKELTAL / POSITIONER
========================================================= */

.match-list{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
}

.match-row{
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 30px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
}

.team-home{
  text-align: left;
  font-weight: 600;
}

.team-away{
  text-align: right;
  font-weight: 600;
}

.score{
  font-weight: 700;
  white-space: nowrap;
}

.tie-meta{
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 14px;
  color: #374151;
}

.history-keynumbers{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.keyrow{
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid #e5e7eb;
}

.keyrow:first-child{
  border-top: none;
  padding-top: 0;
}

.playoff-series-block{
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.playoff-series-card{
  margin-bottom: 0;
}

.playoff-series-card h4{
  margin-bottom: 12px;
}

.playoff-series-card{
  margin-bottom: 0;
  padding: 16px;
}

.playoff-series-card + .playoff-series-card{
  margin-top: 4px;
}

/* Positionstabeller */
.positions-grid{
  display: grid;
  grid-template-columns: auto auto;
  justify-content: center;
  gap: 80px;
  align-items: start;
}

.positions-grid h4{
  text-align: center;
}

.history-position-table{
  table-layout: fixed;
  width: 350px;
}

.positions-grid .history-position-table{
  width: 350px;
}

.history-position-table th:nth-child(1),
.history-position-table td:nth-child(1){
  width: 18%;
  text-align: left;
}

.history-position-table th:nth-child(2),
.history-position-table td:nth-child(2){
  width: 22%;
  text-align: center;
}

.history-position-table th:nth-child(3),
.history-position-table td:nth-child(3){
  width: 20%;
  text-align: center;
  font-weight: 600;
}

/* Målfarligaste lag */
#dangerTableHistory{
  table-layout: fixed;
}

#dangerTableHistory th:nth-child(1),
#dangerTableHistory td:nth-child(1){
  width: 3ch;
  text-align: center;
}

#dangerTableHistory th:nth-child(2),
#dangerTableHistory td:nth-child(2){
  width: 150px;
  text-align: left;
}

#dangerTableHistory th:nth-child(3),
#dangerTableHistory td:nth-child(3){
  width: 55px;
  text-align: center;
}

#dangerTableHistory th:nth-child(4),
#dangerTableHistory td:nth-child(4),
#dangerTableHistory th:nth-child(5),
#dangerTableHistory td:nth-child(5),
#dangerTableHistory th:nth-child(6),
#dangerTableHistory td:nth-child(6){
  width: 60px;
  text-align: center;
}

#dangerTableHistory th:nth-child(7),
#dangerTableHistory td:nth-child(7),
#dangerTableHistory th:nth-child(8),
#dangerTableHistory td:nth-child(8),
#dangerTableHistory th:nth-child(9),
#dangerTableHistory td:nth-child(9){
  width: 95px;
  text-align: center;
}

#dangerTableHistory th:nth-child(10),
#dangerTableHistory td:nth-child(10){
  width: 105px;
  text-align: center;
}

#dangerTableHistory th:nth-child(11),
#dangerTableHistory td:nth-child(11){
  width: 105px;
  text-align: center;
}

/* Sortering */
#teamsContent th.sortable{
  cursor: pointer;
  white-space: nowrap;
}

#teamsContent th.sortable:hover{
  text-decoration: underline;
}

#teamsContent th.sortable.is-active{
  font-weight: 700;
}

#teamsContent th.sortable::after{
  content: " ⇅";
  opacity: 0.45;
}

#teamsContent th.sortable.is-active.is-desc::after{
  content: " ▼";
  opacity: 0.85;
}

#teamsContent th.sortable.is-active.is-asc::after{
  content: " ▲";
  opacity: 0.85;
}


/* =========================================================
   MATCHMODAL
========================================================= */

.match-modal{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.40);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.match-modal-content{
  position: relative;
  background: #fff;
  border-radius: 14px;
  padding: 24px 28px;
  width: 900px;
  max-width: 96vw;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
}

.match-modal-content{
  position: relative;
  overflow: hidden;
}

/* gemensam stil */
.match-bg-logo{
  position: absolute;
  top: 20px;
  width: 200px;
  height: 120px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.12; /* 🔥 viktigt – subtil */
  pointer-events: none;
}

/* vänster */
.match-bg-logo.left{
  left: 65px;
}

/* höger */
.match-bg-logo.right{
  right: 65px;
}

.match-modal-close{
  position: absolute;
  top: 10px;
  right: 14px;
  border: none;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: #374151;
}

.match-header{
  text-align: center;
  margin-bottom: 14px;
}

.match-header h2{
  margin: 0;
  font-family: "EurostileExtended", Arial, sans-serif;
}

#modalMatchScore{
  margin-top: 6px;
  font-size: 18px;
  font-weight: 700;
  margin-left: 12px;
}

.match-summary{
  text-align: center;
  margin-bottom: 16px;
  font-size: 14px;
  color: #374151;
  line-height: 1.7;
}

.match-score-home{
  margin-right: 6px;
}

.match-score-away{
  margin-left: 6px;
}

.match-score-home,
.match-score-away{
  font-size: 22px;
}

.match-score-home,
.match-score-away,
.match-period-score,
.match-shot-total,
.match-shot-period{
  color: #63ace8;
  font-weight: 700;
}

.match-goals-table{
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.match-goals-table thead th{
  background: rgba(195, 183, 166, 0.2);
  border-bottom: 2px solid rgba(0,0,0,0.05);
  color: #6b7280;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 700;
}

.match-goals-table th,
.match-goals-table td{
  border-bottom: 1px solid #eee;
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Period */
.match-goals-table th:nth-child(1),
.match-goals-table td:nth-child(1){
  width: 10%;
  text-align: center;
}

/* Tid */
.match-goals-table th:nth-child(2),
.match-goals-table td:nth-child(2){
  width: 10%;
  text-align: center;
}

/* Lag */
.match-goals-table th:nth-child(3),
.match-goals-table td:nth-child(3){
  width: 15%;
  text-align: left;
}

/* Målskytt */
.match-goals-table th:nth-child(4),
.match-goals-table td:nth-child(4){
  width: 25%;
}

/* Assist */
.match-goals-table th:nth-child(5),
.match-goals-table td:nth-child(5){
  width: 40%;
}

.match-row-btn{
  width: 100%;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: inherit;
}

.match-row-btn:hover{
  background: #f1f5f9;
}

.match-goals-table tbody tr:hover{
  background: #f1f5f9;
}

.match-row-btn:focus{
  outline: 2px solid #63ace8;
  outline-offset: 2px;
}

/* Periodavdelare */
.match-goals-table tr.period-break td{
  border-top: 3px solid #9ca3af;
  padding-top: 12px;
}


/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 1100px){
  .history-grid-3{
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px){
  .history-grid-2{
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px){
  .match-row{
    grid-template-columns: 1fr;
    text-align: left;
  }

  .team-away{
    text-align: left;
  }

  .score{
    justify-self: start;
  }
}

@media (max-width: 700px){
  .match-list{
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1000px){
  .history-list{
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px){
  .history-list{
    grid-template-columns: 1fr;
  }
}