/* ── Generic modal ─────────────────────────────────────────────────────────── */
.modal {
    display: none; position: fixed; z-index: 999; left: 0; top: 0; width: 100%; height: 100%;
    overflow: auto; background: rgba(0,0,0,0.4);
}
.modal-content {
    background: #fff; margin: 10% auto; padding: 20px; border-radius: 10px;
    width: 90%; max-width: 350px; box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    position: relative;
}
.close {
    position: absolute; top: 5px; right: 15px; color: #888; font-size: 28px; font-weight: bold; cursor: pointer;
}

/* ── Score / submit buttons ────────────────────────────────────────────────── */
button[type="submit"] {
    background: var(--clr-blue);
    color: #fff;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}
button[type="submit"]:hover {
    background: var(--clr-blue-dark);
}
.save-score-btn {
    background: var(--clr-blue);
    color: #fff;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    font-family: inherit;
    transition: background 0.15s;
}
.save-score-btn:hover  { background: var(--clr-blue-dark); }
.save-score-btn:disabled { background: #93c5fd; cursor: not-allowed; }
.print-match-btn {
    display: inline-block;
    margin-left: 4px;
    font-size: 1.1em;
    text-decoration: none;
    opacity: 0.6;
    transition: opacity 0.15s;
    vertical-align: middle;
}
.print-match-btn:hover { opacity: 1; }

/* ── Toolbar & action buttons ──────────────────────────────────────────────── */
.toolbar-btn {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  background: #fff;
  color: #374151;
  border: 1.5px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
}
.toolbar-btn:hover { background: #f3f4f6; border-color: #9ca3af; color: #374151; }
.split-btn-main {
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  min-height: 44px;
  background: #059669;
  color: #fff;
  border: none;
  border-radius: 6px 0 0 6px;
  font-size: 0.9em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
  box-sizing: border-box;
}
.split-btn-main:hover { background: #047857; color: #fff; }
.split-btn-disabled { background: #9ca3af !important; cursor: default; pointer-events: none; }
.split-btn-seg {
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  background: #047857;
  color: #fff;
  border: none;
  border-left: 1px solid rgba(255,255,255,0.25);
  font-size: 0.95em;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
  box-sizing: border-box;
}
.split-btn-seg:hover { background: #065f46; }
.split-btn-seg-last { border-radius: 0 6px 6px 0; }
.action-btn {
    background: var(--clr-blue);
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 8px 15px;
    text-decoration: none;
    font-size: 1.06em;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
}
.action-btn:hover {
    background: var(--clr-blue-dark);
}
.action-btn-tool {
    background: var(--clr-gray-tool);
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 8px 15px;
    text-decoration: none;
    font-size: 1.06em;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
}
.action-btn-tool:hover { background: #374151; color: #fff; }
.action-btn-danger {
    background: var(--clr-red);
    color: #fff;
}
.action-btn-danger:hover { background: var(--clr-red-dark); color: #fff; }
.action-btn-util {
    background: #f1f5f9 !important;
    border: 1px solid #d1d5db !important;
    border-radius: 5px;
    color: #6b7280;
    padding: 7px 10px;
    font-size: 1em;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}
.action-btn-util:hover { background: #fef3c7 !important; border-color: #f59e0b !important; color: #92400e; }
.modal-label {
    font-size: 0.78em;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 7px;
}
.modal-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.92em;
    cursor: pointer;
}
@keyframes pulse-amber {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0.5); }
    50%       { box-shadow: 0 0 0 7px rgba(245,158,11,0); }
}
.action-btn-pulse {
    animation: pulse-amber 1.5s ease-in-out infinite;
}

/* ── Add bar / inline form ──────────────────────────────────────────────────── */
.add-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
}
.inline-form {
    display: flex;
    gap: 7px;
    align-items: center;
    background: #f9f9fc;
    padding: 11px 13px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}
.hint {
    font-size: 0.93em;
    color: #888;
    margin-left: 5px;
}

/* ── Tournament cards (home page) ──────────────────────────────────────────── */
.tables-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  margin-top: 20px;
}
.table-card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 15px;
  min-width: 180px;
  width: 200px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: border-color 0.2s, background 0.2s;
  display: flex;
  flex-direction: column;
}
.table-card-done {
  border-color: #16a34a;
  background: #f0fdf4;
}
.table-card-complete {
  border-color: #15803d;
  background: #dcfce7;
}
.card-status-badge {
  border-radius: 6px;
  padding: 5px 10px;
  font-weight: 600;
  font-size: 0.82em;
  text-align: center;
  margin-bottom: 8px;
}
.card-status-pools {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}
.card-status-complete {
  background: #15803d;
  color: #fff;
}
.progress-badge {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 0.88em;
  font-weight: 600;
  white-space: nowrap;
}
.progress-badge.progress-done {
  background: #d1fae5;
  color: #065f46;
  border-color: #6ee7b7;
}
.table-card h2 {
  margin: 0 0 10px 0;
}
.table-card .tournoi-name {
  font-weight: bold;
  margin-bottom: 6px;
}
/* ── Card CTA button ──────────────────────────────────────────────────────── */
.card-cta {
  display: block;
  text-align: center;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 0.92em;
  font-weight: 600;
  text-decoration: none;
  background: #1e293b;
  color: #fff;
  transition: opacity 0.15s;
  margin-bottom: 10px;
}
.card-cta:hover { opacity: 0.85; }
.card-cta-amber { background: #f59e0b; color: #fff; }
.card-cta-blue  { background: #1d4ed8; color: #fff; }
.card-cta-green { background: #15803d; color: #fff; }
/* ── Card icon row ────────────────────────────────────────────────────────── */
.card-icon-row {
  display: flex;
  gap: 2px;
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1px 6px;
  margin-top: auto;
}
.card-icon-row .spacer { flex: 1; }
.card-icon-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 4px 5px 3px;
  border-radius: 6px;
  font-size: 1.05em;
  line-height: 1.15;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  transition: background 0.15s;
}
.card-icon-link .cil-label {
  font-size: 0.55em;
  font-weight: 600;
  color: #64748b;
  margin-top: 1px;
}
.card-icon-link:hover { background: #e2e8f0; }
.card-icon-delete:hover { background: #fee2e2; }
.card-icon-delete .cil-label { color: #b91c1c; }

/* ── Settings slide panel ───────────────────────────────────────────────── */
#settings-panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1500;
}
#settings-panel-inner {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 700px;
  max-width: 95vw;
  background: #fff;
  overflow-y: auto;
  box-shadow: -4px 0 40px rgba(0,0,0,.2);
  transform: translateX(100%);
  transition: transform 0.22s ease;
}
#settings-panel-overlay.open #settings-panel-inner {
  transform: translateX(0);
}
#settings-panel-head {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 10;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#settings-panel-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2em;
  color: #6b7280;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
}
#settings-panel-close:hover { background: #f3f4f6; }

/* ── Modale live unifiée ─────────────────────────────────────────────────── */
#modal-live {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
#modal-live-inner {
  background: #fff;
  border-radius: 12px;
  min-width: 580px;
  max-width: 1000px;
  width: 95%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,.25);
  transition: all 0.2s ease;
}
.ltab-tabbar {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
  gap: 10px;
}
.ltab-tab-group {
  display: flex;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}
.ltab-btn {
  padding: 6px 16px;
  border: none;
  border-right: 1.5px solid #e5e7eb;
  cursor: pointer;
  font-size: 0.88em;
  transition: all 0.15s;
  background: #fff;
  font-family: inherit;
}
#ltab-btn-tables { border-right: none; }
.ltab-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.ltab-auto-badge {
  font-size: 0.72em;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
  border: none;
  letter-spacing: .03em;
  color: #fff;
}
.ltab-auto-badge-on  { background: #059669; cursor: pointer; }
.ltab-auto-badge-off { background: #6b7280; }
.ltab-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  line-height: 1;
  padding: 2px 4px;
}
#ltab-fullscreen-btn { font-size: 1.15em; }
.ltab-close-btn      { font-size: 1.4em; }
#ltab-toast {
  display: none;
  background: #1e293b;
  color: #fff;
  font-size: 0.82em;
  font-weight: 600;
  padding: 7px 14px;
  border-left: 4px solid #f59e0b;
  flex-shrink: 0;
}
.ltab-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
#ltab-left {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-width: 0;
}
#ltab-right {
  width: 230px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 16px;
  border-left: 1px solid #f1f5f9;
}

/* ── Match cards ─────────────────────────────────────────────────────────── */
.match-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
  padding: 12px;
}
.match-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  background: #fff;
  transition: box-shadow 0.15s, border-color 0.15s;
  user-select: none;
}
.match-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 2px 10px rgba(59,130,246,.12);
}
.match-card.done {
  border-left: 3px solid #16a34a;
  background: #f9fefb;
}
.match-card.forfait { opacity: 0.65; }

.mc-main {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mc-player { flex: 1; min-width: 0; overflow: hidden; }
.mc-right  { text-align: right; }
.mc-winner .mc-name { font-weight: 700; color: #15803d; }
.mc-name { font-size: 0.9em; font-weight: 500; display: block;
           white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-elo  { font-size: 0.75em; color: #9ca3af; }
.mc-trophy { font-size: 0.82em; }

.mc-center {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 48px;
}
.mc-vs    { font-size: 0.75em; color: #9ca3af; }
.mc-score { font-size: 1.05em; font-weight: 700; color: #111827; }
.mc-table-badge {
  font-size: 0.7em;
  background: #f1f5f9;
  color: #475569;
  border-radius: 4px;
  padding: 1px 6px;
  font-weight: 600;
}
.mc-forfait-badge {
  font-size: 0.75em;
  background: #fef2f2;
  color: #dc2626;
  border-radius: 4px;
  padding: 2px 6px;
}
.mc-sets {
  font-size: 0.72em;
  color: #9ca3af;
  text-align: center;
  margin-top: 6px;
  letter-spacing: 0.01em;
}

/* ── Modal saisie score ──────────────────────────────────────────────────── */
.sm-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 2000; display: flex; align-items: center; justify-content: center;
}
.sm-box {
  background: #fff; border-radius: 14px;
  padding: 28px 32px; min-width: 340px; max-width: 480px; width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.sm-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; font-size: 0.9em; color: #6b7280;
}
.sm-close {
  background: none; border: none; font-size: 1.1em; cursor: pointer;
  color: #9ca3af; line-height: 1; padding: 2px 6px; border-radius: 4px;
}
.sm-close:hover { background: #f3f4f6; color: #374151; }
.sm-players {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 24px;
}
.sm-player { font-size: 1.05em; font-weight: 700; color: #111827; flex: 1; }
.sm-player-left  { text-align: left; }
.sm-player-right { text-align: right; }
.sm-vs-big { color: #9ca3af; font-size: 0.85em; font-weight: 500; flex-shrink: 0; }
.sm-sets { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.sm-set-row {
  display: flex; align-items: center; gap: 10px;
}
.sm-set-label { width: 44px; font-size: 0.82em; color: #6b7280; flex-shrink: 0; }
.sm-input {
  width: 64px; padding: 8px 10px; font-size: 1.1em; text-align: center;
  border: 1.5px solid #d1d5db; border-radius: 8px; outline: none;
  transition: border-color 0.15s;
}
.sm-input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.sm-sep { color: #9ca3af; font-size: 1em; flex-shrink: 0; width: 16px; text-align: center; }
.sm-footer {
  display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px;
  border-top: 1px solid #f1f5f9;
}
.sm-forfait-zone {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed #e5e7eb;
}
.sm-forfait-sep {
  font-size: 0.78em;
  color: #9ca3af;
  text-align: center;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.sm-forfait-btns {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn-red-sm {
  background: transparent;
  color: #ef4444;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.82em;
  cursor: pointer;
}
.btn-red-sm:hover { background: #fee2e2; }

/* ── Finals match cards ─────────────────────────────────────────────────── */
.final-card { cursor: pointer; }
.final-card.bye-match { opacity: 0.55; cursor: default; }
.mc-phase-label {
  font-size: 0.68em; color: #9ca3af; text-transform: uppercase;
  letter-spacing: 0.05em; margin-bottom: 5px;
}
.mc-exempt {
  font-size: 0.75em; color: #9ca3af; font-style: italic;
}
.mc-table-select {
  margin-top: 7px; display: flex; justify-content: flex-end;
}
.mc-table-select select {
  font-size: 0.8em; padding: 2px 5px; border-radius: 4px;
  border: 1px solid #d1d5db; color: #374151; cursor: pointer;
  background: #f9fafb;
}

/* ── Tooltips ──────────────────────────────────────────────────────────────── */
.tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 0.78em;
  font-weight: 700;
  cursor: default;
  vertical-align: middle;
  margin-left: 5px;
  flex-shrink: 0;
  user-select: none;
}
.tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f1f5f9;
  font-size: 1em;
  font-weight: 400;
  line-height: 1.5;
  padding: 10px 14px;
  border-radius: 8px;
  white-space: normal;
  width: 260px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s, transform .15s;
  transform: translateX(-50%) translateY(4px);
  z-index: 9999;
}
.tip::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1e293b;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 9999;
}
.tip:hover::after,
.tip:hover::before { opacity: 1; transform: translateX(-50%) translateY(0); }
.tip.tip-left::after { left: auto; right: 0; transform: none; }
.tip.tip-left:hover::after { transform: translateY(0); }
.tip.tip-left::before { left: auto; right: 6px; transform: none; }

/* ── Edit modal (players page) ──────────────────────────────────────────────── */
#editModal .modal-content h3 { margin: 0 0 16px; font-size: 1.05em; }
#editModal .modal-content label {
  display: block;
  font-size: 0.82em;
  font-weight: 600;
  color: #374151;
  margin: 10px 0 3px;
}
#editModal .modal-content input[type="text"],
#editModal .modal-content input[type="number"],
#editModal .modal-content input:not([type="submit"]):not([type="hidden"]) {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.95em;
  box-sizing: border-box;
  margin: 0;
}
#editModal .modal-content button[type="submit"] {
  margin-top: 14px;
  width: 100%;
  padding: 10px;
  background: #1d4ed8;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.95em;
  cursor: pointer;
  font-weight: 600;
}
#editModal .modal-content button[type="button"] {
  margin-top: 6px;
  width: 100%;
  padding: 8px;
  background: #f1f5f9;
  color: #374151;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.9em;
  cursor: pointer;
}

@media (max-width: 767px) {
  /* Score modal : bottom sheet sur mobile */
  .sm-overlay {
    align-items: flex-end !important;
    justify-content: stretch !important;
    padding: 0 !important;
  }
  .sm-overlay .sm-box {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    border-radius: 16px 16px 0 0 !important;
    position: static !important;
    padding: 20px 16px 28px !important;
    max-height: 88vh;
    overflow-y: auto;
    box-sizing: border-box !important;
  }
  /* Drag handle visuel */
  .sm-box::before {
    content: '';
    display: block;
    width: 40px; height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 0 auto 16px;
  }
  /* Inputs plus grands pour le touch */
  .sm-input {
    width: 72px !important;
    font-size: 1.2em !important;
    padding: 10px 8px !important;
    min-height: 44px;
  }
  /* Noms joueurs : pas de débordement */
  .sm-player {
    font-size: 0.95em !important;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* Boutons footer pleine largeur */
  .sm-footer { flex-direction: row; gap: 8px; }
  .sm-footer .btn-action { flex: 1; padding: 12px 8px !important; font-size: 1em !important; min-height: 44px; }

  /* Modale live — bottom sheet sur mobile */
  #modal-live { align-items: flex-end; }
  #modal-live-inner {
    min-width: 0;
    width: 100%;
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
  }
  #ltab-right { display: none; }
  .ltab-btn { padding: 5px 8px; font-size: 0.8em; }
  .ltab-tabbar { padding: 8px 10px; gap: 6px; }

  /* Add bar & inline form */
  .add-bar { flex-direction: column; gap: 8px; }
  .inline-form { flex-direction: column; gap: 6px; width: 100%; }

  /* Grilles matchs : une colonne sur mobile */
  .match-cards-grid { grid-template-columns: 1fr !important; }

  /* Touch targets agrandis */
  .match-card { min-height: 56px; cursor: pointer; }
}
