/* ================================================================
   cart.css — Panneau panier + modal fichet
   ================================================================ */

/* ── Bouton panier dans la nav ─────────────────────────────── */
.cart-nav-btn {
  position: relative;
  /* resets navigateur bouton */
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 500;
  line-height: 1.55;
  /* style identique btn-ghost */
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  background: transparent;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: var(--radius);
  color: rgba(255,255,255,.9);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition);
}
.cart-nav-btn:hover { background: rgba(255,255,255,.1); color: #fff; }

.cart-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #fff;
  color: var(--primary);
  font-size: .65rem;
  font-weight: 700;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ── Overlay ───────────────────────────────────────────────── */
.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 399;
}

/* ── Panneau latéral ───────────────────────────────────────── */
.cart-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 100vw;
  background: var(--surface);
  box-shadow: -4px 0 24px rgba(0,0,0,.15);
  z-index: 400;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .25s ease;
}
.cart-panel.open { transform: translateX(0); }

.cart-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cart-panel-head h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.cart-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  min-width: 44px;
  min-height: 44px;
  padding: 10px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cart-close:hover { color: var(--text-primary); background: var(--bg); }

/* ── Corps du panneau ──────────────────────────────────────── */
.cart-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.cart-empty-msg {
  text-align: center;
  color: var(--text-secondary);
  font-size: .9rem;
  padding: 40px 0;
}

/* ── Item panier ───────────────────────────────────────────── */
.cart-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* topbar : badge type + numéro + date + durée + bouton suppr */
.cart-item-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.cart-item-num {
  font-size: .7rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  flex-shrink: 0;
}
.cart-train-type-badge {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  color: #fff;
  white-space: nowrap;
  flex-shrink: 0;
}
.cart-train-num {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}
.cart-item-date {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}
.cart-item-duration {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 8px;
  white-space: nowrap;
}
.cart-item-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-disabled);
  padding: 3px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  margin-left: auto;
  flex-shrink: 0;
}
.cart-item-remove:hover { color: #b91c1c; background: #fef2f2; }

/* corps : même grid que train-body de results.css */
.cart-train-body {
  display: grid;
  grid-template-columns: max-content 1fr max-content;
  grid-template-rows: auto auto;
  row-gap: 4px;
  padding: 14px 16px;
  align-items: center;
}
.cart-trip-time {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
  color: var(--text-primary);
  white-space: nowrap;
}
.cart-trip-time.dep { grid-column: 1; grid-row: 1; }
.cart-trip-time.arr { grid-column: 3; grid-row: 1; text-align: right; }

.cart-trip-station {
  font-size: .78rem;
  color: var(--text-secondary);
  line-height: 1.3;
  word-break: break-word;
}
.cart-trip-station.dep { grid-column: 1; grid-row: 2; }
.cart-trip-station.arr { grid-column: 3; grid-row: 2; text-align: right; }

.cart-trip-deco {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 72px;
  z-index: 1;
}
.cart-deco-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--train-color, var(--primary));
  flex-shrink: 0;
}
.cart-deco-bar {
  flex-grow: 1;
  height: 2px;
  background: var(--train-color, var(--primary));
}

/* ── Footer panneau ────────────────────────────────────────── */
.cart-footer {
  border-top: 1px solid var(--border);
  padding: 14px 16px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-danger-ghost {
  background: transparent;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.btn-danger-ghost:hover { background: #fef2f2; }

/* ── Bannière mode échange ─────────────────────────────────── */
.exchange-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #ede9fe;
  border: 1px solid #c4b5fd;
  border-radius: var(--radius);
  color: #5b21b6;
  font-size: .875rem;
  font-weight: 600;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.exchange-banner-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Bouton "Utiliser ce train" ────────────────────────────── */
.btn-use-exchange {
  background: transparent;
  color: #5b21b6;
  border: 1.5px solid #c4b5fd;
  font-size: .8rem;
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  font-family: inherit;
}
.btn-use-exchange:hover { background: #ede9fe; }

/* ── Modal confirmation échange ────────────────────────────── */
.exchange-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.exchange-modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  padding: 24px 24px 20px;
}

.exchange-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.exchange-modal-head h3 {
  font-size: 1rem;
  font-weight: 700;
}

.exch-train-recap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 14px;
  background: #ede9fe;
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.exch-train-route {
  font-weight: 700;
  font-size: .95rem;
  color: #5b21b6;
}
.exch-train-meta {
  font-size: .8rem;
  color: #7c3aed;
}

.exchange-modal-body { display: flex; flex-direction: column; gap: 12px; }
.exchange-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ── Bouton "Ajouter au panier" sur les cartes train ───────── */
.btn-add-cart {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  font-size: .8rem;
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.btn-add-cart:hover  { background: var(--primary); color: #fff; }
.btn-add-cart.added  { background: var(--primary-light); color: var(--primary); border-color: var(--primary-light); cursor: default; }

/* ── Bouton "Ajouter au dossier" (mode add_to_ref) ─────────── */
.btn-add-ref {
  background: transparent;
  color: #065f46;
  border: 1.5px solid #6ee7b7;
  font-size: .8rem;
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.btn-add-ref:hover { background: #d1fae5; }
.btn-add-ref.added { background: #d1fae5; color: #065f46; border-color: #6ee7b7; cursor: default; }

/* ── Liens retour dans les bannières (couleur héritée) ─────── */
.add-to-ref-banner .btn-outline,
.exchange-banner .btn-outline {
  color: inherit;
  border-color: currentColor;
}

/* ── Bannière mode ajout au dossier ────────────────────────── */
.add-to-ref-banner {
  background: #d1fae5;
  border: 1px solid #6ee7b7;
  border-radius: var(--radius);
  color: #065f46;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  font-size: .875rem;
  font-weight: 600;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ── Modal génération fichet ───────────────────────────────── */
.fichet-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.fichet-modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  padding: 28px 28px 24px;
}

.fichet-modal h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.fichet-modal p {
  font-size: .85rem;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

.fichet-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* .btn-outline déplacé dans components.css */

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 520px) {
  .cart-panel { width: 100vw; }
  .cart-trip-time { font-size: 1.2rem; }
}
