/* ================================================================
   references.css — Pages Mes dossiers et détail dossier
   ================================================================ */

.refs-page {
  max-width: 1100px;
  margin: 0 auto;
}

/* ── En-tête page ──────────────────────────────────────────── */
.refs-header {
  margin-bottom: 28px;
}
.refs-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.refs-subtitle {
  font-size: .875rem;
  color: var(--text-secondary);
}

/* ── En-tête avec bouton nouveau dossier ──────────────────── */
.refs-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.refs-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Bandeau temps réel (GTFS-RT) ─────────────────────────── */
.ticket-rt-container { padding: 12px 20px 0; }
.rt-banner {
  margin: 8px 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: .813rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rt-banner--cancelled { background: #fee2e2; color: #7f1d1d; border-left: 3px solid #dc2626; }
.rt-banner--delay     { background: #fff4e0; color: #8a5a00; border-left: 3px solid #f0a500; }
.rt-banner--ontime    { background: #e6f7e9; color: #1b5e20; border-left: 3px solid #2e7d32; }

.rt-alerts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.rt-alert {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: .813rem;
  background: #fff8e1;
  border-left: 3px solid #f0a500;
  color: #6d4a00;
}
.rt-alert--warning { background: #fff4e0; border-left-color: #f0a500; }
.rt-alert--severe  { background: #fee2e2; border-left-color: #dc2626; color: #7f1d1d; }
.rt-alert--info    { background: #e7f1fb; border-left-color: #2563eb; color: #0b3a78; }

.rt-alert-cause {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.08);
  font-size: .688rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.rt-alert-header { font-weight: 600; }
.rt-alert-details { margin-top: 6px; font-size: .813rem; }
.rt-alert-details summary {
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  opacity: .85;
}
.rt-alert-body {
  margin-top: 6px;
  padding: 6px 0;
  line-height: 1.45;
}
.rt-alert-body p { margin: 6px 0; }
.rt-alert-body a { color: inherit; text-decoration: underline; }

/* ── Modal import e-billet PDF ────────────────────────────── */
.modal-box--wide { max-width: 1040px; }
.modal-box--wide .modal-foot { flex-wrap: wrap; }
.import-pdf-help {
  color: var(--text-secondary);
  font-size: .875rem;
  margin-bottom: 14px;
  line-height: 1.5;
}
.import-pdf-filename {
  margin-top: 10px;
  font-size: .813rem;
  color: var(--text-secondary);
  font-style: italic;
}
.import-pdf-section {
  font-size: .875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-secondary);
  margin: 18px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.import-pdf-section:first-child { margin-top: 0; }
.import-pdf-meta { margin-top: 14px; }
.import-pdf-status {
  display: inline-block;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: .813rem;
  font-weight: 600;
}
.import-pdf-status.ok   { background: #e6f7e9; color: #1b5e20; }
.import-pdf-status.warn { background: #fff4e0; color: #8a5a00; }
.alert-warning {
  background: #fff8e1;
  border-left: 3px solid #f0a500;
  color: #6d4a00;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: 12px;
}
.alert-warning ul { margin: 6px 0 0; padding-left: 20px; }

/* ── Modal générique ───────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
}
.modal-head, .modal-foot { flex: 0 0 auto; }
.modal-body            { flex: 1 1 auto; overflow-y: auto; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 0;
}
.modal-head h3 { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 10px;
  border-radius: var(--radius-sm);
}
.modal-close:hover { color: var(--text-primary); background: var(--bg); }
.modal-body  { padding: 16px 20px; }
.modal-foot  {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 20px 18px;
}

/* ── Section ajout billet (détail) ────────────────────────── */
.add-ticket-section {
  margin-top: 28px;
  padding: 24px;
  background: var(--surface);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-lg);
}

.add-ticket-heading {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.add-ticket-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.add-ticket-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  font-family: inherit;
  text-align: left;
  transition: border-color var(--transition), box-shadow var(--transition),
              background var(--transition);
}
.add-ticket-option:hover {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(155,39,67,.06);
  text-decoration: none;
}
.add-ticket-option.active {
  border-color: var(--primary);
  background: var(--surface);
}

.add-option-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition);
}
.add-ticket-option:hover .add-option-icon,
.add-ticket-option.active .add-option-icon {
  background: rgba(155,39,67,.18);
}

.add-option-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}
.add-option-desc {
  font-size: .78rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.add-manual-form {
  margin-top: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

@media (max-width: 540px) {
  .add-ticket-options { grid-template-columns: 1fr; }
}

/* ── Filtres statut ────────────────────────────────────────── */
.refs-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.filter-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  padding: 5px 16px;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.filter-btn:hover { background: var(--bg); color: var(--text-primary); }
.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ── Pagination ────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 20px 0 8px;
  flex-wrap: wrap;
}
.page-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.page-btn:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); }
.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  cursor: default;
}
.page-ellipsis {
  color: var(--text-secondary);
  font-size: .82rem;
  padding: 0 4px;
  user-select: none;
}
.pagination-info {
  font-size: .78rem;
  color: var(--text-secondary);
  margin-left: 8px;
}

/* ── État vide ─────────────────────────────────────────────── */
.refs-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 48px 20px;
  font-size: .95rem;
}
.refs-empty p { margin-bottom: 16px; }

/* ── Carte dossier (liste) ─────────────────────────────────── */
.ref-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 12px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.ref-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--primary);
}
.ref-card:has(.ref-card-link:hover) {
  box-shadow: var(--shadow);
  border-color: var(--primary);
}

.ref-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.ref-card-route {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.ref-card-name {
  font-size: .95rem;
  font-weight: 700;
  color: var(--primary);
  font-family: monospace;
  letter-spacing: .04em;
  flex-shrink: 0;
}
.ref-card-date {
  font-size: .82rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.ref-card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ref-tag {
  font-size: .72rem;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
  color: var(--text-secondary);
}
.ref-tag-pdf {
  background: var(--primary-light);
  border-color: var(--primary-light);
  color: var(--primary);
}
.ref-tag-pending {
  background: #fef3c7;
  border-color: #fde68a;
  color: #92400e;
}

/* ── Carte en attente de confirmation ──────────────────────── */
.ref-card--pending {
  border-style: dashed;
  opacity: .85;
}

/* ── Carte voyage passé ────────────────────────────────────── */
.ref-card--past {
  opacity: .6;
}

/* ── Section voyages passés ────────────────────────────────── */
.refs-past-section {
  margin-top: 24px;
}
.refs-past-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 6px 0;
  width: 100%;
  text-align: left;
  margin-bottom: 12px;
}
.refs-past-toggle:hover { color: var(--text-primary); }
.past-chevron {
  flex-shrink: 0;
  transition: transform .2s ease;
}
.refs-past-count {
  font-size: .72rem;
  font-weight: 700;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1px 8px;
  color: var(--text-secondary);
}
.refs-past-list { margin-top: 4px; }

/* ── Carte dossier ─────────────────────────────────────────── */
.ref-delete-btn { margin-left: auto; }

/* ── Détail dossier ────────────────────────────────────────── */
.ref-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.ref-detail-title {
  font-size: 1.3rem;
  font-weight: 700;
  font-family: monospace;
  letter-spacing: .05em;
  color: var(--primary);
  margin-bottom: 4px;
}
.ref-detail-sub {
  font-size: .875rem;
  color: var(--text-secondary);
}
.ref-detail-title--pending {
  color: #92400e;
  font-style: italic;
}
.ref-detail-actions {
  flex-shrink: 0;
}

/* ── Liste des tickets ─────────────────────────────────────── */
.tickets-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Ticket card ───────────────────────────────────────────── */
.ticket-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.ticket-card--cancelled { opacity: .65; }
.ticket-card--exchanged { opacity: .65; }
.ticket-card--past      { opacity: .6; }

/* ── Barre supérieure ──────────────────────────────────────── */
.tk-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tk-seq {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  flex-shrink: 0;
}
/* .train-type-badge et .train-num-main viennent de results.css */
.tk-topbar .train-num-main {
  flex: 1;        /* pousse la date + badge à droite */
}
.tk-date-badge {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Status badges ─────────────────────────────────────────── */
.status-badge {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-pending   { background: #fef3c7; color: #92400e; }
.badge-confirmed { background: #d1fae5; color: #065f46; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-exchanged { background: #ede9fe; color: #5b21b6; }
.badge-past      { background: #f1f5f9; color: #64748b; }

/* ── Grille de détails ─────────────────────────────────────── */
.tk-details {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  border-top: 1px dashed var(--border);
  padding: 0 20px;
}
.tk-detail-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 16px;
  border-right: 1px dashed var(--border);
}
.tk-detail-item:first-child { padding-left: 0; }
.tk-detail-item:last-child  { border-right: none; padding-right: 0; }
.tk-detail-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
}
.tk-detail-value {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-primary);
}
.tk-detail-price {
  color: var(--primary);
  font-size: .95rem;
  font-weight: 700;
}

/* ── Formulaire confirmation ────────────────────────────────── */
.ticket-confirm-form {
  margin: 0 20px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.ticket-confirm-form h4 {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.confirm-fields {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.confirm-fields .field { flex: 1; min-width: 130px; }
.confirm-fields label {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.confirm-fields input,
.confirm-fields select,
.confirm-fields .custom-select-trigger {
  padding: 7px 10px;
  font-size: .875rem;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  font-family: inherit;
  box-sizing: border-box;
}
.confirm-fields select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}
.confirm-fields input:focus,
.confirm-fields select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,87,184,.12);
}

/* ── Actions internes du formulaire d'édition ───────────────── */
.ticket-edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ── Champs requis ──────────────────────────────────────────── */
.field-required { color: #b91c1c; font-size: .75em; }

/* ── Actions ticket ─────────────────────────────────────────── */
.ticket-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* ── Boutons petits ─────────────────────────────────────────── */
.btn-sm {
  padding: 7px 16px;
  font-size: .8rem;
}
.btn-danger-ghost {
  background: transparent;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.btn-danger-ghost:hover { background: #fef2f2; }

.btn-delete {
  background: transparent;
  color: #991b1b;
  border: 1px solid #fca5a5;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
}
.btn-delete:hover { background: #fee2e2; border-color: #f87171; }
.btn-delete svg { flex-shrink: 0; }

.confirm-refname { text-transform: uppercase; }
.input-uppercase  { text-transform: uppercase; }

.confirm-fields--col { flex-direction: column; }

.ticket-actions-spacer { flex: 1; }

.btn-exchange {
  background: transparent;
  color: #5b21b6;
  border: 1px solid #c4b5fd;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.btn-exchange:hover { background: #ede9fe; }

.btn-edit {
  background: transparent;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}
.btn-edit:hover { background: #eff6ff; }

.btn-calendar {
  background: #047857;
  color: #fff;
  border: 1px solid #047857;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.btn-calendar:hover { background: #065f46; border-color: #065f46; }
.btn-calendar svg { flex-shrink: 0; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .ref-detail-head { flex-direction: column; }
  .confirm-fields  { flex-direction: column; }
  .tk-details      { grid-template-columns: repeat(2, 1fr); }
  .tk-detail-item:nth-child(2) { border-right: none; padding-right: 0; }
  .tk-detail-item:nth-child(3) { padding-left: 0; border-right: none; }
}
