/* ============================================
   TICKET BORLETTE — Style Reçu Normal
   Clean receipt look
   ============================================ */

:root {
  --tk-text: #222;
  --tk-text-muted: #666;
  --tk-border: #ccc;
}

/* --- Container principal --- */
.ticket-pos-fiche {
  width: 300px;
  /* Taille fixe — ne pas contraindre au viewport pour un rendu identique sur tous les appareils */
  margin: 0 auto;
  background: #fff;
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 14px; /* base fixe en px — tous les em calculés depuis cette valeur */
  padding: 0;
  box-sizing: border-box;
  overflow: hidden;
  color: var(--tk-text);
  border: 1px solid #ddd;
  border-radius: 4px;
}

.ticket-pos-fiche::before { display: none; }

/* --- En-tête --- */
.ticket-header {
  background: #fff;
  text-align: center;
  padding: 10px 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-bottom: 2px solid #222;
}
.ticket-header::after { display: none; }
.ticket-logo {
  font-size: 1.3em;
  line-height: 1;
}
.ticket-brand {
  font-size: 1.4em;
  font-weight: 900;
  letter-spacing: 3px;
  color: #111;
  text-transform: uppercase;
}
.ticket-subtitle {
  font-size: 0.65em;
  color: #666;
  letter-spacing: 1px;
  text-transform: uppercase;
  display: block;
}

/* --- Tear edge --- */
.ticket-tear-edge {
  display: block;
  width: 100%;
  height: 2px;
  background: #ddd;
  border: none;
}

/* --- Statut du ticket --- */
.ticket-status {
  margin: 6px 10px 0;
  padding: 5px 8px;
  text-align: center;
  font-weight: 700;
  font-size: 0.8em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}
.ticket-status.status-won {
  background: #e6f4ea;
  color: #1a7431;
  border: 1px solid #b7dfc3;
}
.ticket-status.status-lost {
  background: #fde8e8;
  color: #a12020;
  border: 1px solid #f0b8b8;
}
.ticket-status.status-pending {
  background: #fff8e1;
  color: #8a6d00;
  border: 1px solid #e6d27a;
}
.ticket-status .status-gain {
  font-size: 1.05em;
  font-weight: 800;
  display: block;
  width: 100%;
  margin-top: 2px;
}

/* --- Bloc info --- */
.ticket-info {
  padding: 8px 12px 4px;
}
.ticket-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 0.9em;
  line-height: 1.5;
  border-bottom: 1px dashed #e5e5e5;
}
.ticket-info-row:last-child {
  border-bottom: none;
}
.ticket-info-label {
  color: var(--tk-text-muted);
  font-weight: 500;
  flex-shrink: 0;
}
.ticket-info-value {
  font-weight: 700;
  text-align: right;
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 65%;
  color: var(--tk-text);
}

/* Ligne double */
.ticket-info-double {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.9em;
  line-height: 1.5;
  border-bottom: 1px dashed #e5e5e5;
  gap: 8px;
}
.ticket-info-half {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ticket-info-half + .ticket-info-half {
  border-left: 1px solid #ddd;
  padding-left: 8px;
}

/* --- Separator --- */
.ticket-separator {
  height: 1px;
  margin: 4px 12px;
  border-top: 1px dashed #ccc;
  background: none;
}

/* --- Section numéros joués --- */
.ticket-games {
  padding: 4px 12px 6px;
}
.ticket-games-title {
  font-size: 0.7em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--tk-text-muted);
  margin-bottom: 6px;
  text-align: center;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ticket-games-title::before,
.ticket-games-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #ccc;
}

.ticket-game-group {
  margin-bottom: 6px;
  background: #fafafa;
  border-radius: 3px;
  padding: 5px 8px 4px;
  border: 1px solid #eee;
}
.ticket-game-group:last-child {
  margin-bottom: 0;
}
.ticket-game-type {
  font-size: 0.68em;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #111;
  padding: 0;
  background: none;
  border-radius: 0;
  margin-bottom: 4px;
  display: block;
  border-bottom: 1px solid #ccc;
  padding-bottom: 2px;
}

.ticket-nums-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95em;
}
.ticket-nums-table th {
  text-align: left;
  padding: 2px 4px;
  font-size: 0.72em;
  font-weight: 600;
  color: var(--tk-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #ddd;
}
.ticket-nums-table th:last-child {
  text-align: right;
}
.ticket-nums-table td {
  padding: 3px 4px;
}
.ticket-nums-table td:last-child {
  text-align: right;
  font-weight: 600;
  color: #444;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.9em;
}
.ticket-nums-table tr + tr td {
  border-top: 1px solid #f0f0f0;
}
.ticket-num-cell {
  font-weight: 800;
  font-size: 1.1em;
  letter-spacing: 1px;
  color: #111;
  font-family: 'Consolas', 'Courier New', monospace;
}

/* --- Total --- */
.ticket-total-section {
  margin: 6px 12px;
  padding: 6px 10px;
  background: #fff;
  border-radius: 0;
  border-top: 2px solid #111;
  border-bottom: 2px solid #111;
  text-align: left;
}
.ticket-total-section::before { display: none; }
.ticket-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ticket-total-label {
  font-size: 0.82em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #111;
}
.ticket-total-value {
  font-size: 1.3em;
  font-weight: 900;
  color: #111;
  font-family: 'Consolas', 'Courier New', monospace;
}
.ticket-plays-count {
  font-size: 0.68em;
  color: #666;
  margin-top: 2px;
  font-weight: 500;
}

/* --- QR Code --- */
.ticket-barcode {
  padding: 10px 12px 6px;
  text-align: center;
}
.ticket-barcode canvas,
.ticket-barcode img {
  width: 140px !important;
  height: 140px !important;
  display: block;
  margin: 0 auto;
  image-rendering: pixelated;
}
.ticket-barcode svg {
  max-width: 140px;
  height: 140px;
}
.ticket-barcode-hint {
  font-size: 0.65em;
  color: var(--tk-text-muted);
  margin-top: 4px;
  font-weight: 500;
}

/* --- Footer --- */
.ticket-footer {
  padding: 6px 12px 8px;
  text-align: center;
  background: #f8f8f8;
  border-top: 1px dashed #ccc;
}
.ticket-footer-msg {
  font-size: 0.75em;
  color: var(--tk-text);
  font-weight: 600;
}
.ticket-footer-luck {
  font-size: 0.75em;
  color: #1a7431;
  font-weight: 700;
  display: inline;
  margin-left: 4px;
}
.ticket-footer-date {
  font-size: 0.6em;
  color: #999;
  margin-top: 3px;
  font-weight: 400;
}

/* --- Boutons d'action (hors impression) --- */
.ticket-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 16px 20px 20px;
  flex-wrap: wrap;
}
.ticket-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  border: none;
  border-radius: 10px;
  font-size: 0.88em;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  color: #fff;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.3px;
  position: relative;
  overflow: hidden;
}
.ticket-action-btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0);
  transition: background 0.2s;
}
.ticket-action-btn:hover::after {
  background: rgba(255,255,255,0.12);
}
.ticket-action-btn:active {
  transform: scale(0.96);
}
.ticket-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
}
.ticket-action-btn.btn-print {
  background: #222;
  flex: 1;
  min-width: 100px;
}
.ticket-action-btn.btn-download {
  background: #0984e3;
  flex: 1;
  min-width: 100px;
}
.ticket-action-btn.btn-share {
  background: #27ae60;
  flex: 1;
  min-width: 100px;
}
.ticket-action-btn.btn-close {
  background: #bbb;
  color: #333;
  min-width: 60px;
}
.ticket-action-btn.btn-close:hover {
  background: #888;
  color: #fff;
}

/* ============================================
   IMPRESSION — @media print
   ============================================ */
@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  body {
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .ticket-pos-fiche {
    width: 100% !important;
    max-width: 80mm !important;
    margin: 0 auto !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    overflow: visible !important;
  }
  .ticket-pos-fiche::before { display: none !important; }
  .ticket-header { padding: 6px 4px !important; gap: 2px !important; background: #fff !important; border-bottom: 1px solid #111 !important; }
  .ticket-total-section { margin: 2px 4px !important; background: #fff !important; border-top: 1px solid #111 !important; border-bottom: 1px solid #111 !important; }
  .ticket-actions, .no-print { display: none !important; }
  @page { margin: 0; }
}

/* ============================================
   APERÇU MODAL (dans index.html)
   ============================================ */
.ticket-preview-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  overflow-y: auto;
  animation: overlayFadeIn 0.3s ease;
}
.ticket-preview-overlay .ticket-pos-fiche {
  animation: ticketSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes overlayFadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes ticketSlideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 400px) {
  /* Sur petits écrans : on garde 300px fixe et on permet le scroll horizontal.
     Toutes les tailles de police restent identiques (font-size:14px sur le container).
     Seul l'overlay scrolle pour afficher le ticket entier. */
  .ticket-preview-overlay {
    align-items: flex-start;
    padding: 12px 8px;
  }
}
