/* ==========================================================
   Pocket Lineup
========================================================== */

:root {
  --bs-primary: #0d6efd;
  --card-radius: 16px;
  --transition: .25s;

  --app-navbar-height: 56px;
  --app-footer-height: 44px;
  --app-main-padding-y: 12px;

  --app-main-height: calc(100dvh - var(--app-navbar-height) - var(--app-footer-height));
  --page-card-height: calc(var(--app-main-height) - 24px);
  --datatable-scroll-height: calc(100dvh - 330px);
}

/* ==========================================================
   Layout principal
========================================================== */

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  background: #f4f6f9;
}

.navbar {
  min-height: var(--app-navbar-height);
  z-index: 1000;
}

.navbar-brand {
  font-size: 1.35rem;
  font-weight: 700;
}

.app-main {
  height: var(--app-main-height);
  overflow: hidden;
  padding-top: var(--app-main-padding-y) !important;
  padding-bottom: var(--app-main-padding-y) !important;
}

.app-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--app-footer-height);
  /* Doit rester sous les modales Bootstrap (z-index 1055). */
  z-index: 1020;
  border-top: 1px solid #ddd;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 .75rem !important;
}

.app-footer .container,
.app-footer .container-fluid {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================
   Commun
========================================================== */

.fade-in {
  animation: fadeIn .25s ease-in-out;
}

.card {
  border: none;
  border-radius: var(--card-radius);
  transition: var(--transition);
}

.card:hover {
  transform: translateY(-2px);
}

.shadow-sm {
  box-shadow: 0 5px 18px rgba(0, 0, 0, .08) !important;
}

/* ==========================================================
   Layouts par page
========================================================== */

.page-table,
.page-list,
.page-dashboard,
.page-form {
  height: 100%;
  overflow: hidden;
}

.page-table > .card,
.page-list > .card,
.page-dashboard > .card,
.page-form > .card {
  height: var(--page-card-height);
  overflow: hidden;
}

.page-table .card-body,
.page-list .card-body,
.page-dashboard .card-body,
.page-form .card-body {
  overflow: hidden;
}

/* ==========================================================
   DataTables
========================================================== */

.dataTables_wrapper {
  width: 100%;
}

.dataTables_filter {
  margin-bottom: .75rem;
}

.dataTables_filter label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .5rem;
  flex-wrap: wrap;
  width: 100%;
}

.dataTables_filter input {
  margin-left: 0 !important;
  max-width: 240px;
}

.dataTables_scroll {
  border-top: 1px solid var(--bs-border-color);
  border-radius: 0 0 var(--card-radius) var(--card-radius);
  overflow: hidden;
}

.dataTables_scrollBody {
  height: var(--datatable-scroll-height) !important;
  max-height: var(--datatable-scroll-height) !important;
  overflow-y: auto !important;
  overflow-x: auto !important;
  border-bottom: 1px solid var(--bs-border-color);
}

.dataTables_scrollHead table,
.dataTables_scrollBody table,
.dataTables_scrollFoot table {
  width: 100% !important;
}

table.dataTable {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

table.dataTable th,
table.dataTable td {
  vertical-align: middle;
}

table.dataTable thead th,
table.dataTable tfoot th,
table.dataTable tfoot td {
  white-space: nowrap;
}

.dataTables_empty {
  padding: 2rem !important;
}

/* ==========================================================
   Dashboard
========================================================== */

.dashboard {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 1rem;
}

.stat-card {
  text-align: center;
  height: 100%;
}

.stat-value {
  font-size: 2.4rem;
  font-weight: bold;
  color: var(--bs-primary);
}

.stat-title {
  color: #6c757d;
  font-size: .95rem;
  margin-top: 6px;
}

.stat-value-text {
  font-size: 1.1rem;
  line-height: 1.3;
}

/* ==========================================================
   Ordre de frappe
========================================================== */

.lineup .card-header {
  gap: .75rem;
  flex-wrap: wrap;
}

.lineup .card-header .d-flex {
  flex-wrap: wrap;
}

.lineup .card-header button {
  white-space: nowrap;
}

.page-list.lineup > .card > .card-body {
  height: calc(var(--page-card-height) - 58px);
  overflow-y: auto;
  overflow-x: hidden;
}

#lineupResult {
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  padding-bottom: 1rem;
}

#lineupResult .lineup-player-card,
.lineup-player-card {
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  margin-bottom: .75rem;
}

.lineup-strategy-summary {
  background: #fff;
  color: var(--bs-body-color);
  transition: .15s ease-in-out;
}

.lineup-strategy-summary:hover {
  background: #f8f9fa;
}

.lineup-strategy-summary.border-primary {
  background: rgba(13, 110, 253, .08);
  border-color: var(--bs-primary) !important;
}

/* ==========================================================
   Rapports / Paramètres
========================================================== */

.reports .card-body,
.settings .card-body {
    overflow:auto;
}

/* ==========================================================
   Stats inline
========================================================== */

.stat-inline {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  margin-right: .55rem;
  white-space: nowrap;
}

.stat-inline-key {
  font-weight: 700;
}

.stat-inline-primary {
  color: var(--bs-primary);
}

.stat-inline-good {
  color: #198754;
}

.stat-inline-warning {
  color: #fd7e14;
}

.stat-inline-negative {
  color: #dc3545;
}

/* ==========================================================
   Modales
========================================================== */

.modal-dialog-scrollable .modal-content {
  max-height: calc(100dvh - 2rem);
}

.modal-dialog-scrollable .modal-body {
  overflow-y: auto;
}

/* ==========================================================
   Modale stats match
========================================================== */

#gameStatsModal .modal-body {
  max-height: calc(100dvh - 220px);
  overflow-y: auto;
}

#gameStatsModal .modal-footer,
#gameStatsModal .game-stats-footer {
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 5;
  background: var(--bs-body-bg);
  border-top: 1px solid var(--bs-border-color);
  padding: .45rem .75rem;
  min-height: 52px;
}

#gameStatsModal .table-responsive {
  overflow-x: auto;
}

#gameStatsModal table {
  min-width: 760px;
}

#gameStatsModal table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bs-light);
}

#gameStatsModal table th:first-child,
#gameStatsModal table td:first-child {
  min-width: 150px;
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--bs-body-bg);
}

#gameStatsModal table thead th:first-child {
  z-index: 3;
  background: var(--bs-light);
}

.stat-stepper {
  display: flex;
  align-items: center;
  gap: .15rem;
  min-width: 92px;
}

.stat-stepper .stat-input {
  width: 25px;
  min-width: 25px;
  text-align: center;
  padding: .2rem;
  appearance: textfield;
  -moz-appearance: textfield;
}

.stat-stepper .stat-input::-webkit-outer-spin-button,
.stat-stepper .stat-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.stat-stepper-btn {
  width: 28px;
  min-width: 28px;
  padding-left: 0;
  padding-right: 0;
  font-weight: 700;
}

/* ==========================================================
   Loading
========================================================== */

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(255, 255, 255, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-box {
  background: #fff;
  border-radius: 18px;
  padding: 28px 36px;
  text-align: center;
  min-width: 240px;
}

/* ==========================================================
   Animations
========================================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================
   Page scroll commune
========================================================== */

.page-scroll {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 1rem;
}

/* Pages formulaire / contenu simple */
.page-form {
  height: 100%;
  overflow: hidden;
}

.page-form > .card {
  height: var(--page-card-height);
  overflow: hidden;
}

.page-form > .card > .card-body {
  height: calc(var(--page-card-height) - 58px);
  overflow: hidden;
  overflow-y: auto;
}

/* ==========================================================
   Player Types
========================================================== */

.player-type {
    font-weight: 600;
}

.player-type-leadoff {
    color: #66b2ff;
}

.player-type-contact {
    color: #66d98f;
}

.player-type-power {
    color: #ff8c69;
}

.player-type-producer {
    color: #ffd166;
}

.player-type-speed {
    color: #4dd0e1;
}

.player-type-risk {
    color: #e57373;
}

.player-type-balanced {
    color: #adb5bd;
}
/* ==========================================================
   Modale stats match — thème clair et alternance des lignes
========================================================== */

/*
 * Bootstrap applique ses couleurs de tableau directement aux cellules.
 * On cible donc les cellules avec > * afin que la première colonne sticky
 * demeure cohérente avec le reste de la ligne en thème clair.
 */
[data-bs-theme="light"] #gameStatsModal tbody tr:nth-child(odd) > * {
  background-color: #ffffff;
  color: #212529;
}

[data-bs-theme="light"] #gameStatsModal tbody tr:nth-child(even) > * {
  background-color: #eef1f4;
  color: #212529;
}

[data-bs-theme="light"] #gameStatsModal tbody tr:hover > * {
  background-color: #dbeafe;
  color: #212529;
}

/* La colonne Joueur reste sticky et reprend exactement la couleur de sa ligne. */
[data-bs-theme="light"] #gameStatsModal tbody tr:nth-child(odd) > td:first-child {
  background-color: #ffffff;
}

[data-bs-theme="light"] #gameStatsModal tbody tr:nth-child(even) > td:first-child {
  background-color: #eef1f4;
}

[data-bs-theme="light"] #gameStatsModal tbody tr:hover > td:first-child {
  background-color: #dbeafe;
}

[data-bs-theme="light"] #gameStatsModal tbody td:first-child {
  color: #212529;
}

/* ==========================================================
   Coach Advisor
========================================================== */

.lineup-advice {
  padding-top: .5rem;
  border-top: 1px solid var(--bs-border-color);
}

.lineup-advice-group {
  line-height: 1.8;
}

.lineup-advice-item {
  display: inline-block;
  margin-left: .35rem;
  margin-right: .1rem;
  margin-bottom: .25rem;
  padding: .15rem .4rem;
  border-radius: 999px;
  font-size: .78rem;
  line-height: 1.35;
}

.lineup-advice-strength {
  color: #198754;
  background: rgba(25, 135, 84, .10);
}

.lineup-advice-watch {
  color: #9a5b00;
  background: rgba(255, 193, 7, .14);
}

/* ==========================================================
   Lineup — rangs et détails repliables
========================================================== */

.lineup-player-layout {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: .7rem;
  align-items: start;
}

.lineup-rank {
  width: 34px;
  height: 34px;
  min-height: 34px;

  border-radius: 50%;

  display: flex;
  align-items: center;
  justify-content: center;

  align-self: start;
  margin-top: .1rem;

  font-size: 1rem;
  font-weight: 800;
  line-height: 1;

  color: #fff;
  background: var(--bs-primary);

  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .16),
    0 2px 5px rgba(0, 0, 0, .18);
}

.lineup-player-content {
  min-width: 0;
}

.lineup-player-name {
  font-size: 1.05rem;
  line-height: 1.25;
}

.lineup-score {
  flex: 0 0 auto;
}

.lineup-details-toggle {
  font-size: .8rem;
  text-decoration: none;
}

.lineup-details-toggle:hover,
.lineup-details-toggle:focus {
  text-decoration: underline;
}

.lineup-player-details {
  margin-top: .25rem;
  padding-top: .65rem;
  border-top: 1px solid var(--bs-border-color);
}

/* Cinq premiers rangs plus faciles à repérer */

.lineup-player-card:nth-child(1) .lineup-rank {
  background: #0d6efd;
}

.lineup-player-card:nth-child(2) .lineup-rank {
  background: #198754;
}

.lineup-player-card:nth-child(3) .lineup-rank {
  background: #fd7e14;
}

.lineup-player-card:nth-child(4) .lineup-rank {
  background: #dc3545;
}

.lineup-player-card:nth-child(5) .lineup-rank {
  background: #6f42c1;
}

.lineup-player-card:nth-child(n+6) .lineup-rank {
  background: #6c757d;
}

/* ==========================================================
   Tendance récente
========================================================== */

.lineup-trend {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .1rem .42rem;
  border-radius: 999px;
  font-weight: 600;
  line-height: 1.35;
}

.profile-trend-up {
  color: #198754;
  background: rgba(25, 135, 84, .12);
}

.profile-trend-down {
  color: #dc3545;
  background: rgba(220, 53, 69, .12);
}

.profile-trend-stable {
  color: #0d6efd;
  background: rgba(13, 110, 253, .10);
}

.profile-trend-insufficient {
  color: #6c757d;
  background: rgba(108, 117, 125, .10);
}


/* ==========================================================
   Lineup — mode visible et Drag & Drop
========================================================== */

.lineup-mode-summary {
  font-weight: 600;
}

.lineup-mode-summary[data-mode="season"] {
  background-color: #6c757d !important;
}

.lineup-mode-summary[data-mode="tournament"] {
  background-color: #dc3545 !important;
}

.lineup-mode-summary[data-mode="development"] {
  background-color: #198754 !important;
}

.lineup-player-layout {
  grid-template-columns: 34px 22px minmax(0, 1fr);
}

.lineup-drag-handle {
  width: 30px;
  min-width: 30px;
  height: 30px;
  margin-top: .1rem;
  padding: 0;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--bs-secondary-color);

  font-size: 1.5rem;
  line-height: 1;  

  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.lineup-drag-handle:hover,
.lineup-drag-handle:focus-visible {
  background: rgba(108, 117, 125, .14);
  color: var(--bs-body-color);
}

.lineup-drag-handle:active {
  cursor: grabbing;
}

.lineup-sortable-ghost {
  opacity: .35;
}

.lineup-sortable-chosen {
  box-shadow: 0 0 0 2px rgba(13, 110, 253, .35);
}

.lineup-sortable-drag {
  opacity: .95;
}


/* ==========================================================
   Lineup — état de génération
========================================================== */

.lineup-generation-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
}

.lineup-generation-status-main {
  display: flex;
  align-items: center;
  gap: .45rem;
  flex-wrap: wrap;
}

.lineup-order-source-badge,
.lineup-mode-summary,
.lineup-style-summary {
  font-weight: 600;
}

.lineup-order-source-badge[data-source="manual"] {
  color: #212529 !important;
}

.lineup-manual-order-message {
  padding-left: .15rem;
}


/* ==========================================================
   Lineup — disposition compacte
   Ce bloc final remplace visuellement les anciennes dimensions.
========================================================== */

.lineup-player-card {
  margin-bottom: .45rem !important;
}

.lineup-player-card .card-body {
  padding-top: .55rem !important;
  padding-bottom: .55rem !important;
}

.lineup-player-layout {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 58px;
  column-gap: .65rem;
  align-items: start;
}

.lineup-rank {
  width: 28px;
  height: 28px;
  min-height: 28px;
  margin-top: .1rem;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;
  color: #fff;
  background: var(--bs-primary);

  font-size: .82rem;
  font-weight: 800;
  line-height: 1;

  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .16),
    0 1px 3px rgba(0, 0, 0, .18);
}

.lineup-player-content {
  min-width: 0;
}

.lineup-player-name {
  margin-bottom: .12rem;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}

.lineup-player-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .22rem;

  margin-bottom: .25rem;

  color: var(--bs-secondary-color);
  font-size: .82rem;
  line-height: 1.25;
}

.lineup-meta-separator {
  color: var(--bs-secondary-color);
  opacity: .65;
}

.lineup-player-summary-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .3rem .65rem;
}

.lineup-player-summary-row .lineup-trend {
  flex: 0 0 auto;
}

.lineup-player-summary-row .lineup-stats {
  flex: 1 1 auto;
  min-width: 0;
}

.lineup-player-tools {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .35rem;
}

.lineup-score {
  flex: 0 0 auto;
  font-size: .7rem;
  white-space: nowrap;
}

.lineup-details-toggle {
  margin-top: .22rem !important;
  padding-top: .1rem;
  padding-bottom: .1rem;
}

.lineup-player-details {
  margin-top: .2rem;
  padding-top: .5rem;
}


/* ==========================================================
   Installation PWA
========================================================== */

.pwa-install-section {
  padding-bottom: .5rem;
}

.pwa-install-status {
  font-weight: 600;
}

.pwa-install-status[data-status="installed"] {
  color: var(--bs-success);
}

.pwa-install-status[data-status="available"] {
  color: var(--bs-primary);
}

.pwa-install-status[data-status="manual"] {
  color: var(--bs-warning-text-emphasis);
}


/* ==========================================================
   Installation PWA — iPhone / iPad
========================================================== */

.pwa-install-status[data-status="ios"] {
  color: var(--bs-primary);
}

.pwa-ios-instructions {
  padding: .85rem 1rem;

  border: 1px solid var(--bs-border-color);
  border-radius: .75rem;

  background:
    color-mix(
      in srgb,
      var(--bs-primary) 6%,
      var(--bs-body-bg)
    );
}

.pwa-install-steps {
  padding-left: 1.25rem;
}

.pwa-install-steps li {
  margin-bottom: .4rem;
}

.pwa-install-steps li:last-child {
  margin-bottom: 0;
}


/* ==========================================================
   État de connexion
========================================================== */

.network-status-indicator {
  min-height: 30px;
  padding: .25rem .55rem;

  display: inline-flex;
  align-items: center;
  gap: .4rem;

  border: 1px solid rgba(255, 255, 255, .38);
  border-radius: 999px;

  color: #fff;

  font-size: .75rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.network-status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;

  border-radius: 50%;
  background: currentColor;
}

.network-status-online {
  background: rgba(25, 135, 84, .28);
}

.network-status-offline {
  background: rgba(220, 53, 69, .34);
}

.network-status-offline .network-status-dot {
  animation: networkStatusPulse 1.5s ease-in-out infinite;
}

@keyframes networkStatusPulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .4;
  }
}


/* ==========================================================
   Synchronisation automatique
========================================================== */

.auto-sync-section {
  padding-bottom: .5rem;
}

.auto-sync-status {
  padding: .75rem .85rem;

  border: 1px solid var(--bs-border-color);
  border-radius: .75rem;

  background:
    color-mix(
      in srgb,
      var(--bs-secondary-bg) 75%,
      transparent
    );
}

.auto-sync-status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;

  border-radius: 50%;
  background: var(--bs-secondary);
}

.auto-sync-status-dot[data-state="current"] {
  background: var(--bs-success);
}

.auto-sync-status-dot[data-state="checking"],
.auto-sync-status-dot[data-state="syncing"] {
  background: var(--bs-primary);
  animation:
    autoSyncPulse 1.2s
    ease-in-out infinite;
}

.auto-sync-status-dot[data-state="setup-required"],
.auto-sync-status-dot[data-state="local-changes"],
.auto-sync-status-dot[data-state="offline"] {
  background: var(--bs-warning);
}

.auto-sync-status-dot[data-state="error"] {
  background: var(--bs-danger);
}

@keyframes autoSyncPulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: .45;
    transform: scale(.82);
  }
}


.auto-sync-status-dot[data-state="conflict"] {
  background: var(--bs-danger);
}


.auto-sync-status-dot[data-state="content-changed"] {
  background: var(--bs-primary);
}
