/* Styles de base de BinDex : couleurs, boutons, champs, cartes, fenêtres, notifications. */
:root {
  --bg: #0c0e13;
  --bg2: #12151c;          /* champs, encarts */
  --panel: #171b24;        /* surfaces */
  --panel2: #1f2430;       /* surfaces en relief, survol */
  --panel3: #282e3c;       /* survol des boutons */
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .16);
  --ink: 255, 255, 255;    /* voiles et survols (blanc sur fond sombre) */
  --shade: 12, 14, 19;     /* barres translucides (couleur du fond) */
  --shade2: 18, 21, 28;
  --accent-rgb: 124, 108, 255;
  --page-a: #1c202b; --page-b: #13161d;   /* pages du classeur */
  --page-c: #20242f; --page-d: #161921;
  --text: #eef0f5;
  --muted: #8b92a5;
  --primary: #7c6cff;
  --primary-2: #9d90ff;
  --gold: var(--primary-2); /* prix, valeurs, mises en avant : couleur du thème choisi */
  --danger: #ff5d6c;
  --success: #34d399;
  --t0: #9aa3b5;
  --t1: #3ecf8e;
  --t2: #4ea8ff;
  --t3: #b07cff;
  --t4: #ff7ad9;
  --t5: #ffc83d;
  --t6: #ff5e5e;
  --t7: #ffffff;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --ring: 0 0 0 3px rgba(var(--accent-rgb), .35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Outfit', system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(1100px 520px at 50% -220px, rgba(var(--accent-rgb), .16), transparent 70%), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
h2, h3 { margin: 0 0 6px; letter-spacing: -.01em; }
h2 { font-size: 1.5rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }
::selection { background: rgba(var(--accent-rgb), .4); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ---------- Boutons ---------- */
.btn {
  font: inherit; font-weight: 600; font-size: .95rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border-strong);
  background: var(--panel2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .1s, background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover:not(:disabled) { background: var(--panel3); border-color: rgba(var(--ink), .24); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-small { padding: 7px 12px; font-size: .86rem; border-radius: 10px; }
.btn-primary { background: var(--primary); border-color: transparent; color: #fff; box-shadow: 0 6px 18px rgba(var(--accent-rgb), .3); }
.btn-primary:hover:not(:disabled) { background: var(--primary-2); border-color: transparent; }
.btn-gold { background: var(--primary); border-color: transparent; color: #fff; }
.btn-danger { background: transparent; border-color: rgba(255, 93, 108, .5); color: #ff8b96; }
.btn-danger:hover:not(:disabled) { background: rgba(255, 93, 108, .12); border-color: var(--danger); }

/* ---------- Champs ---------- */
input, select, textarea { font: inherit; }
.toolbar input, .toolbar select, .tools-row select, .real-form select, .real-form input, .auth-form input, .bulk-box select,
.opening-box input, .opening-box select, .op-pq, .scan-fields select {
  font: inherit; font-size: .95rem; background: var(--bg2); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 12px; padding: 10px 12px;
  transition: border-color .15s, box-shadow .15s;
}
:is(.toolbar, .tools-row, .real-form, .auth-form, .bulk-box, .opening-box, .scan-box) :is(input, select):focus, .op-pq:focus {
  outline: none; border-color: var(--primary); box-shadow: var(--ring);
}
/* Quantité : − [champ] + (dans un div .field et non un label : un clic sur l'intitulé déclencherait le bouton −) */
.qty-step { display: flex; align-items: stretch; gap: 6px; }
.qty-step input { flex: 1; min-width: 0; width: 100%; text-align: center; -moz-appearance: textfield; appearance: textfield; }
.qty-step input::-webkit-inner-spin-button, .qty-step input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.qty-btn {
  flex: 0 0 auto; width: 42px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--panel2); color: var(--text); font: inherit; font-size: 1.2rem; font-weight: 700; line-height: 1;
  cursor: pointer; user-select: none; touch-action: manipulation; transition: border-color .15s, background .15s;
}
.qty-btn:hover { border-color: var(--primary); }
.qty-btn:active { background: var(--bg2); }
input[type="search"] {
  padding-left: 38px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%238b92a5' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 12px center;
}
select { cursor: pointer; }

/* ---------- En-tête et navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 24px;
  background: rgba(var(--shade), .78);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.35rem; font-weight: 800; letter-spacing: -.01em; color: var(--text); text-decoration: none; flex: none; }
.brand b { color: var(--gold); }
.tab {
  font: inherit; font-weight: 600; cursor: pointer;
  background: transparent; color: var(--muted); border: 1px solid transparent;
  padding: 8px 14px; border-radius: 10px; transition: color .15s, background .15s;
}
.tab:hover { color: var(--text); background: rgba(var(--ink), .05); }
.tab.active { color: var(--text); background: var(--panel2); border-color: var(--border); }
main { padding: 24px 24px 100px; max-width: 1480px; margin: 0 auto; }
.panel-head { margin-bottom: 18px; }
.panel-head h2 { font-size: 1.75rem; }
.panel-head p { margin: 0; max-width: 760px; }
.series-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.series-tabs .tab { padding: 7px 12px; font-size: .9rem; }

/* ---------- Cartes ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 18px; }
/* Collection : en-têtes de série et doubles regroupés */
.set-header {
  grid-column: 1 / -1; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 12px 0 8px; margin-top: 10px; border-bottom: 1px solid var(--border);
}
.set-header:first-child { margin-top: 0; }
.set-header b { font-size: 1.15rem; }
.set-header span { font-size: .85rem; }
.set-progress { margin-left: auto; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.set-progress.done { color: var(--gold); }
.set-bar { flex-basis: 100%; height: 6px; }
.set-bar .bar-fill { background: linear-gradient(90deg, var(--primary), #5ee7ff); }
.set-bar.done .bar-fill { background: linear-gradient(90deg, var(--primary), var(--primary-2)); }
/* Carte manquante d'un set : grisée et estompée (filtre fixe, pas d'animation : léger sur téléphone) */
.pcard-missing { display: flex; flex-direction: column; gap: 4px; min-width: 0; opacity: .45; }
.pcard-missing .miss-art {
  aspect-ratio: .718; border-radius: 4.55% / 3.5%; overflow: hidden;
  background: var(--bg2); border: 1px dashed var(--border-strong);
}
.pcard-missing .miss-art img { width: 100%; height: 100%; object-fit: cover; display: block; filter: grayscale(1) brightness(.6); }
.pcard-missing .pcard-name { font-weight: 600; }
.dup-badge {
  position: absolute; top: -8px; right: -8px; z-index: 5;
  min-width: 30px; padding: 3px 8px; border-radius: 20px; text-align: center;
  font-weight: 800; font-size: .82rem; font-variant-numeric: tabular-nums;
  background: var(--primary); color: #fff; border: 2px solid var(--bg);
  box-shadow: 0 3px 10px rgba(0,0,0,.5);
  pointer-events: none;
}
.pcard-name { font-weight: 700; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard-price { font-weight: 800; color: var(--gold); font-size: .88rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Prix d'un seul exemplaire, à côté du total (passe à la ligne si la carte est étroite) */
.pcard-price:has(.pcard-unit) { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; row-gap: 1px; line-height: 1.25; white-space: normal; }
.pcard-unit { font-weight: 500; font-size: .74rem; color: var(--muted); white-space: nowrap; }
.rarity-pill {
  display: inline-block; font-size: .68rem; font-weight: 700; padding: 2px 8px; border-radius: 20px;
  background: color-mix(in srgb, var(--glow, #667) 22%, transparent);
  color: color-mix(in srgb, var(--glow, #b4b8c8) 85%, white);
  border: 1px solid color-mix(in srgb, var(--glow, #667) 40%, transparent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Fenêtres ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5, 6, 10, .7);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  overflow-y: auto; padding: 30px 16px; overscroll-behavior: contain; /* le défilement ne passe pas à la page */
  animation: fade .15s;
}
#modal { z-index: 60; }
.modal-box {
  position: relative; width: 100%; max-width: 900px; margin: auto;
  background: var(--panel);
  border: 1px solid var(--border-strong); border-radius: 22px; padding: 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
  animation: rise .2s ease-out;
}
.modal-close {
  position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--panel2); border: 1px solid var(--border); color: var(--muted); font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; z-index: 2;
}
.modal-close:hover { color: var(--text); border-color: var(--border-strong); }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.99); } }
@keyframes toastin { from { opacity: 0; transform: translateY(12px); } }

/* ---------- Barres d'outils, résumé, vide ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.toolbar-spacer { flex: 1; }
.toolbar input { min-width: 220px; }
.summary-line { color: var(--muted); margin-bottom: 16px; }
.summary-line b { color: var(--text); }
.empty {
  grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 64px 20px; line-height: 1.6;
  background: var(--panel); border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.empty .btn { margin: 4px; }
.bar { height: 10px; background: rgba(var(--ink), .06); border-radius: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--primary-2)); transition: width .3s; }

/* ---------- Notifications ---------- */
#toasts { position: fixed; bottom: 24px; right: 24px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast {
  background: var(--panel2); border: 1px solid var(--border-strong); border-left: 4px solid var(--primary);
  padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow);
  animation: toastin .25s ease-out; transition: opacity .4s, transform .4s;
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast.out { opacity: 0; transform: translateY(10px); }

/* ---------- Mes vraies cartes ---------- */
.real-addbox h2 { margin: 0 0 14px; padding-right: 40px; }
.real-addbox .real-langs { margin-bottom: 12px; }
.real-addbox .toolbar { margin-bottom: 8px; }
.real-addbox .add-q { flex: 1; min-width: 200px; }
.real-addbox .add-set { max-width: 100%; }
.real-addbox .add-results { max-height: min(60vh, 560px); }
.real-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 10px; margin-top: 12px; max-height: 420px; overflow-y: auto; padding: 2px; }
.real-results:empty { display: none; }
.real-result {
  font: inherit; color: var(--text); text-align: left; cursor: pointer; min-width: 0;
  display: flex; flex-direction: column; gap: 3px; padding: 7px; border-radius: 12px;
  background: var(--bg2); border: 1px solid var(--border); transition: border-color .15s, transform .15s;
}
.real-result:hover { border-color: var(--primary); transform: translateY(-2px); }
.real-result img, .real-noimg { width: 100%; aspect-ratio: .718; object-fit: cover; border-radius: 6px; background: var(--panel2); }
.real-result b { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.real-result small { font-size: .7rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.real-card { display: flex; flex-direction: column; gap: 4px; cursor: pointer; min-width: 0; position: relative; }
.real-art {
  position: relative; aspect-ratio: .718; border-radius: 4.55% / 3.5%; background: var(--panel2);
  box-shadow: 0 6px 16px rgba(0,0,0,.4); transition: transform .18s ease, box-shadow .18s ease;
}
.real-card:hover .real-art, .real-card:hover .sealed-art { transform: translateY(-4px); box-shadow: 0 14px 28px rgba(0,0,0,.55); }
.real-art img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }

/* Reflets des cartes (reverses, raretés) : css/fx.css */
.real-grade {
  position: absolute; left: 6px; bottom: 6px; z-index: 2; padding: 2px 7px; border-radius: 20px; font-size: .72rem; font-weight: 800;
  background: rgba(var(--shade), .9); color: var(--gold); border: 1px solid var(--gold);
}
.real-tags { display: flex; gap: 4px; flex-wrap: wrap; }
/* Carte chinoise montrée avec le visuel de sa version anglaise */
.art-note { position: absolute; left: 6px; bottom: 6px; z-index: 2; padding: 1px 6px; border-radius: 6px; font-size: .62rem; font-weight: 700;
  color: #fff; background: rgba(0, 0, 0, .62); pointer-events: none; }
.real-tags .rarity-pill { font-size: .62rem; }
.real-form { display: grid; grid-template-columns: 240px 1fr; gap: 28px; }
.real-form-art img { width: 100%; border-radius: 4.55% / 3.5%; display: block; box-shadow: var(--shadow); }
.real-form form { display: flex; flex-direction: column; gap: 14px; }
.real-form h2 { margin: 0; padding-right: 40px; }
.real-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.real-fields label, .real-fields .field, .real-note { display: flex; flex-direction: column; gap: 6px; font-size: .82rem; font-weight: 600; color: var(--muted); }
.real-blank {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 10px;
  text-align: center; border-radius: inherit; border: 1px dashed var(--border-strong); background: linear-gradient(160deg, var(--panel2), var(--bg2));
}
.real-blank b { font-size: .9rem; overflow-wrap: anywhere; }
.real-blank small { font-size: .7rem; color: var(--muted); }
.real-more { grid-column: 1 / -1; justify-self: center; }
.real-missing { cursor: pointer; transition: opacity .15s; }
.real-missing:hover { opacity: .8; }
.real-art img.real-over, .real-form-art img.real-over { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 4.55% / 3.5%; }
.real-import-box h2 { padding-right: 40px; }
.real-import-box ul { padding-left: 20px; }
.real-import-list { max-height: 260px; overflow-y: auto; margin-top: 8px; font-size: .85rem; columns: 2; }

/* ---------- Compte ---------- */
.account-box { max-width: 420px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.account-box h2 { margin: 0; }
.account-box p { margin: 0; }
.auth-tabs { display: flex; gap: 6px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--muted); }
.auth-error { color: var(--danger); min-height: 1.2em; font-size: .9rem; }
/* Carte manquante d'une extension : la vignette d'une carte possédée, grisée */
.real-card.is-missing .real-art { filter: grayscale(1) brightness(.6); opacity: .55; box-shadow: none; }
.real-card.is-missing > :not(.real-art) { opacity: .5; }
.real-card.is-missing .pcard-price { color: var(--muted); }
.real-card.is-missing:hover .real-art { opacity: .8; filter: grayscale(.4) brightness(.8); }
.real-card.is-missing:hover > :not(.real-art) { opacity: .8; }
#real-reset[hidden] { display: none; }
#real-view[hidden] { display: none; }
/* Image d'une fiche en plein écran (UI.lightbox) */
.real-form-art img { cursor: zoom-in; }
.lightbox { position: fixed; inset: 0; z-index: 90; overscroll-behavior: contain; touch-action: none; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(6, 7, 12, .88); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); cursor: zoom-out; }
.lightbox img { max-width: min(92vw, 640px); max-height: 90vh; width: auto; height: auto; aspect-ratio: auto; border-radius: 4.55% / 3.5%; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
.lightbox-close { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 14px; width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .2);
  background: rgba(255, 255, 255, .08); color: #fff; font-size: 1.1rem; cursor: pointer; }
.lightbox-close:focus-visible { outline: none; box-shadow: var(--ring); }
/* Fenêtre ouverte : la page derrière ne défile pas (UI.openModal) */
html { scrollbar-gutter: stable; }
html.modal-open, html.modal-open body { overflow: hidden; }
