/* ================================================================
   Fantametrica — css/components.css
   Componenti riutilizzabili: bottoni e chip, card giocatore,
   tabella, empty state, modal con asta e toast.
   ================================================================ */

/* ---------- Bottoni / chip ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 10px;
  font-weight: 600; font-size: .95rem; font-family: inherit;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: transform .2s ease, border-color .2s ease, color .2s ease, box-shadow .2s ease;
}
.btn:active { transform: scale(.98); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 25%, transparent);
}
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 40%, transparent); }
.btn.primary svg { transition: transform .2s ease; }
.btn.primary:hover svg { transform: translateX(3px); }
.btn.ghost { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); transform: translateY(-1px); }
.btn.sm { padding: 8px 14px; font-size: .85rem; border-radius: 9px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 10px;
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); cursor: pointer;
  transition: color .2s ease, border-color .2s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.95); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .72rem; font-weight: 600;
  padding: .28em .62em; border-radius: 7px;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid transparent;
  white-space: nowrap;
  transition: color .25s ease;
}
.chip svg { width: .95em; height: .95em; flex: none; }
.chip.role-chip { color: var(--role, var(--role-c)); background: color-mix(in srgb, var(--role, var(--role-c)) 10%, transparent); }
.chip.id-chip { opacity: .62; font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.chip.inj { color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); }
.chip.bonus { color: var(--lime); background: color-mix(in srgb, var(--lime) 10%, transparent); }
.chip.acc { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.chip.bought {
  color: #15803d; background: color-mix(in srgb, #22c55e 14%, transparent);
  border: 1px solid color-mix(in srgb, #22c55e 35%, transparent);
  font-weight: 700;
}
[data-theme="dark"] .chip.bought { color: #4ade80; background: color-mix(in srgb, #22c55e 18%, transparent); }

.team-chip { display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; font-weight: 600; color: var(--text); white-space: nowrap; }
.team-logo { width: 20px; height: 20px; object-fit: contain; border-radius: 4px; flex: none; vertical-align: middle; }
.team-chip .team-logo { width: 17px; height: 17px; }
.hl-sub .team-logo, .hc-sub .team-logo { width: 15px; height: 15px; margin-right: 3px; border-radius: 3px; }
.td-team .team-logo { width: 13px; height: 13px; border-radius: 3px; }

/* ---------- Card giocatore ---------- */
.pcard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 14px; contain: layout paint; }
.pcard {
  --role: var(--role-c);
  position: relative;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px;
  cursor: pointer;
  transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
}
/* Linea colorata in alto: identifica subito il ruolo del giocatore */
.pcard::before {
  content: '';
  position: absolute; top: 0; left: 14px; right: 14px; height: 3px;
  border-radius: 0 0 4px 4px;
  background: var(--role, var(--role-c));
  opacity: .85;
}
.pcard.bought::before { background: linear-gradient(90deg, #16a34a, #22c55e); }
/* Hover contenuto: la card NON si muove (niente translateY) così non sfora
   mai dai suoi bordi — cambiano solo bordo e ombra, soft. */
.pcard:hover { border-color: color-mix(in srgb, var(--role) 45%, var(--border-strong)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--role) 30%, transparent), var(--shadow-sm); }
.pcard:active { transform: scale(.995); }
/* Card di un giocatore acquistato in asta: bordo verde PIENO con alone
   pulsante "a led" — a prima vista si capisce chi è stato preso.
   L'animazione tocca SOLO box-shadow (nessun layout, nessuna ridipintura
   di area) e viene spenta da prefers-reduced-motion in responsive.css. */
.pcard.bought {
  border-color: #22c55e;
  box-shadow: 0 0 0 1px color-mix(in srgb, #22c55e 32%, transparent), 0 0 10px color-mix(in srgb, #22c55e 28%, transparent), var(--shadow-sm);
  animation: buyLed 2.2s ease-in-out infinite;
}
@keyframes buyLed {
  0%, 100% { box-shadow: 0 0 0 1px color-mix(in srgb, #22c55e 26%, transparent), 0 0 5px color-mix(in srgb, #22c55e 20%, transparent), var(--shadow-sm); }
  50% { box-shadow: 0 0 0 1.5px #22c55e, 0 0 16px color-mix(in srgb, #22c55e 55%, transparent), var(--shadow-sm); }
}
/* Il badge verde sta in cima: spingi il contenuto sotto di esso */
.pcard.bought { padding-top: 38px; }
.pcard.bought::before { display: none; }
.pcard-bought {
  /* Posizionato DENTRO i bordi della card: non esce mai dal riquadro */
  position: absolute; top: 0; left: 1px; right: 1px;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  font-size: .64rem; font-weight: 800; letter-spacing: .04em;
  color: #fff; background: linear-gradient(90deg, #16a34a, #22c55e);
  padding: 2px 10px; border-radius: 13px 13px 0 0;
}
.pcard-bought svg { width: .85em; height: .85em; }
[data-theme="dark"] .pcard-bought { background: linear-gradient(90deg, #15803d, #22c55e); }
.buy-dot {
  display: inline-grid; place-items: center;
  width: 16px; height: 16px; margin-left: 4px; flex: none;
  border-radius: 50%; color: #fff; background: #16a34a;
  vertical-align: middle;
}
.buy-dot svg { width: 9px; height: 9px; }
.pcard { padding-bottom: 16px; }
.pcard-top { display: flex; align-items: flex-start; justify-content: space-between; }

.overall {
  /* Cerchio vero: niente più ovale "storpiato" in verticale */
  display: inline-grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  font-weight: 800; font-size: .9rem; line-height: 1;
}
.overall.ov-high { color: var(--ov-high); background: color-mix(in srgb, var(--ov-high) 12%, transparent); }
.overall.ov-mid { color: var(--ov-mid); background: color-mix(in srgb, var(--ov-mid) 12%, transparent); }
.overall.ov-low { color: var(--ov-low); background: color-mix(in srgb, var(--ov-low) 12%, transparent); }
.overall.ov-none { color: var(--muted); background: var(--surface-2); }

.fav-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border); background: transparent;
  color: var(--muted); cursor: pointer;
  transition: color .18s ease, border-color .18s ease, transform .18s ease;
}
.fav-btn svg { width: 18px; height: 18px; }
.fav-btn:hover { color: var(--red); border-color: var(--red); transform: scale(1.12); }
.fav-btn:active { transform: scale(.9); }
.fav-btn.on { color: var(--red); border-color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }
.fav-btn.on svg { fill: currentColor; }
/* L'animazione agisce sull'ICONA, non sul bottone: il cuore "pop" resta
   dentro i suoi margini anche nel bottone grande della scheda giocatore. */
.fav-btn.pop svg { animation: heartPop .45s cubic-bezier(.2, .8, .3, 1.2); }
@keyframes heartPop {
  0% { transform: scale(1); }
  30% { transform: scale(1.28); }
  55% { transform: scale(.9); }
  100% { transform: scale(1); }
}
.fav-btn.big.pop svg { animation-name: heartPopBig; }
@keyframes heartPopBig {
  0% { transform: scale(1); }
  30% { transform: scale(1.16); }
  55% { transform: scale(.94); }
  100% { transform: scale(1); }
}
.fav-btn.sm { width: 30px; height: 30px; }
.fav-btn.sm svg { width: 15px; height: 15px; }
.fav-btn.big { width: auto; border-radius: 999px; padding: 8px 15px; display: inline-flex; gap: 7px; font: inherit; font-weight: 600; font-size: .85rem; }
.fav-btn.big svg { width: 16px; height: 16px; }

.pcard-name { font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.3; }
.pcard-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 22px; }

.pcard-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 2px; overflow: hidden; }
.stat {
  background: var(--surface-2); border-radius: 9px; padding: 6px 8px;
  display: flex; flex-direction: column; gap: 1px;
  min-width: 0; overflow: hidden;
  transition: transform .2s ease;
}
.stat b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat:hover { background: color-mix(in srgb, var(--accent) 7%, var(--surface-2)); }
.stat span { font-size: .58rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.stat b { font-size: .92rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.pcard-foot {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin-top: auto; padding-top: 10px; border-top: 1px dashed var(--border);
  font-size: .76rem; font-weight: 600;
}
.pcard-foot .flabel {
  font-size: .62rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted);
}
.pcard-foot .pr { color: var(--accent); font-weight: 800; font-size: .95rem; font-variant-numeric: tabular-nums; }

/* ---------- Tabella ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); transition: border-color .25s ease; }
.table-wrap, .rose-teams, .dropdown-menu, .nav-links { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.ptable { width: 100%; min-width: 780px; border-collapse: collapse; font-size: .9rem; }
.ptable th {
  text-align: left; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: color .15s ease;
}
.ptable th:hover { color: var(--text); background: var(--glass); }
.ptable th.sorted { color: var(--accent); }
.ptable td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ptable tbody tr { cursor: pointer; transition: none; }
.ptable tbody tr:hover { background: var(--glass); }
.ptable tbody tr:active { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.ptable tbody tr:last-child td { border-bottom: none; }
.td-name { font-weight: 600; }
.td-team { display: flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 500; color: var(--muted); }
.r-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; background: var(--role, var(--role-c)); vertical-align: 1px; }
.ov-dot { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-weight: 700; font-size: .76rem; line-height: 1; }
.ov-dot.ov-high { color: var(--ov-high); background: color-mix(in srgb, var(--ov-high) 12%, transparent); }
.ov-dot.ov-mid { color: var(--ov-mid); background: color-mix(in srgb, var(--ov-mid) 12%, transparent); }
.ov-dot.ov-low { color: var(--ov-low); background: color-mix(in srgb, var(--ov-low) 12%, transparent); }
.inj-dot { margin-left: 6px; font-size: .9rem; }
.th-fav, .td-fav { width: 42px; text-align: center !important; }
.td-fav { padding: 4px 10px; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center; padding: 56px 20px;
  background: var(--surface); border: 1px dashed var(--border-strong);
  border-radius: 14px;
  transition: border-color .25s ease;
}
.empty-icon {
  display: inline-grid; place-items: center;
  width: 56px; height: 56px; border-radius: 16px;
  margin-bottom: 12px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.empty-icon svg { width: 26px; height: 26px; }
.empty { text-align: center; padding: 44px 16px; }
.empty h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: 4px; }
.empty p { color: var(--muted); margin-bottom: 16px; }
.empty code { background: var(--surface-2); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { -webkit-backdrop-filter: blur(3px); }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 11, 14, .5); backdrop-filter: blur(3px); opacity: 0; transition: opacity .25s ease; }
.modal.open .modal-backdrop { opacity: 1; }
.modal-panel {
  position: relative; z-index: 1;
  width: min(620px, 100%); max-height: 88dvh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 16px; padding: 28px 26px 24px;
  box-shadow: var(--shadow);
  opacity: 0; transform: translateY(16px) scale(.98);
  transition: opacity .25s cubic-bezier(.2, .8, .3, 1), transform .25s cubic-bezier(.2, .8, .3, 1), border-color .25s ease;
}
.modal.open .modal-panel { opacity: 1; transform: translateY(0) scale(1); }
.modal-close { position: absolute; top: 14px; right: 14px; z-index: 2; }

.m-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-right: 40px; }
.m-title h2 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.m-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.m-role {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  font-weight: 800; font-size: .9rem;
  color: #fff; margin-bottom: 8px;
  background: var(--role, var(--role-c));
  box-shadow: 0 3px 8px color-mix(in srgb, var(--role, var(--role-c)) 35%, transparent);
}

.m-grid { display: grid; grid-template-columns: 190px 1fr; gap: 20px; margin: 20px 0; }
.m-ring { display: flex; flex-direction: column; gap: 14px; align-items: center; }
/* Anello di progresso dell'overall: cerchio perfetto su ogni dispositivo
   (aspect-ratio 1/1) e contorno che si riempie quanto l'overall, come una
   barra di progresso circolare. Il colore segue il livello (verde/ambra/rosso). */
.ring {
  --ring-c: var(--ov-mid);
  position: relative;
  width: 120px; aspect-ratio: 1 / 1; flex: none;
  border-radius: 50%;
  display: grid; place-items: center; align-content: center; gap: 0;
  background:
    conic-gradient(var(--ring-c) calc(var(--ov, 0) * 1%), color-mix(in srgb, var(--ring-c) 22%, var(--surface-2)) 0);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ring-c) 22%, transparent);
}
.ring::before {
  content: "";
  position: absolute; inset: 9px;
  border-radius: 50%;
  background: var(--surface-2);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .16);
}
.ring.ov-high { --ring-c: var(--ov-high); }
.ring.ov-mid { --ring-c: var(--ov-mid); }
.ring.ov-low { --ring-c: var(--ov-low); }
.ring b, .ring span { position: relative; z-index: 1; }
.ring b { font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.ring span { font-size: .66rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }

.m-ind { width: 100%; }
.m-ind > span { font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.m-ind .bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin: 5px 0 3px; }
.m-ind .bar i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.m-ind b { font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.m-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; align-content: start; }
.ms { background: var(--surface-2); border-radius: 10px; padding: 9px 12px; display: flex; flex-direction: column; gap: 1px; transition: none; }
.ms span { font-size: .64rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ms b { font-size: 1.02rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.m-row { border-top: 1px solid var(--border); padding: 13px 0; }
.m-label { display: block; font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 7px; }
.m-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.m-text { color: var(--text); font-size: .93rem; }

/* ---------- Asta (acquisti) nella scheda ---------- */
.m-asta {
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 15px 16px;
  background: var(--surface-2);
  transition: border-color .2s ease, background-color .2s ease;
}
.m-asta.done {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border-color: color-mix(in srgb, #22c55e 40%, var(--border));
  background: color-mix(in srgb, #22c55e 8%, var(--surface));
}
.m-asta-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 11px; }
.m-asta-title { font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.m-asta-ref { display: inline-flex; align-items: center; gap: 5px; font-size: .76rem; font-weight: 600; color: var(--muted); }
.m-asta-ref b { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.m-asta-badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .85rem; font-weight: 800; color: #15803d;
}
[data-theme="dark"] .m-asta-badge { color: #4ade80; }
.m-asta-badge svg { width: 15px; height: 15px; }
.m-asta-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.buy-input {
  display: inline-flex; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 3px 4px 3px 12px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.buy-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.buy-input input {
  width: 64px; padding: 7px 4px;
  border: none; background: transparent;
  font: inherit; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
  outline: none;
}
.buy-input span {
  font-size: .78rem; font-weight: 700; color: var(--accent);
  padding: 7px 10px; border-radius: 7px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  white-space: nowrap;
}
.m-hint { font-size: .72rem; color: var(--muted); margin-top: 10px; line-height: 1.45; }

/* ---------- Account / profilo condiviso ---------- */
/* Bottone nella navbar: si colora di verde quando il profilo è attivo */
.auth-btn.logged {
  color: #16a34a;
  border-color: color-mix(in srgb, #16a34a 45%, var(--border));
}
[data-theme="dark"] .auth-btn.logged { color: #4ade80; border-color: color-mix(in srgb, #4ade80 40%, var(--border)); }
.auth-btn svg { transition: transform .3s cubic-bezier(.2, .8, .3, 1.2); }
.auth-btn:hover svg { transform: scale(1.1); }
.auth-btn.logged svg { fill: color-mix(in srgb, #16a34a 18%, transparent); }
[data-theme="dark"] .auth-btn.logged svg { fill: color-mix(in srgb, #4ade80 18%, transparent); }

.auth-panel { width: min(400px, 100%); }
.auth-title { font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; margin-bottom: 6px; }
.auth-sub { color: var(--muted); font-size: .9rem; margin-bottom: 16px; line-height: 1.5; }
.auth-tabs { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.auth-tab {
  flex: 1; padding: 8px 10px; border: none; background: transparent; border-radius: 8px;
  font: inherit; font-weight: 600; font-size: .85rem; color: var(--muted); cursor: pointer;
  transition: color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.auth-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.auth-field { display: block; margin-bottom: 12px; }
.auth-field > span { display: block; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.auth-field input {
  width: 100%; height: 42px; padding: 0 12px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font: inherit; font-size: .95rem; outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.auth-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.auth-err { color: var(--red); font-size: .84rem; line-height: 1.45; margin: 8px 0 10px; }
.auth-submit { width: 100%; justify-content: center; }
.auth-note { color: var(--muted); font-size: .78rem; margin-top: 12px; line-height: 1.45; }
.auth-email { font-size: 1.02rem; font-weight: 700; word-break: break-all; margin-bottom: 2px; }
.auth-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 200;
  transform: translate(-50%, 14px);
  display: flex; align-items: center; gap: 8px;
  max-width: min(92vw, 560px);
  background: var(--text); color: var(--bg);
  padding: 11px 18px; border-radius: 999px;
  font-weight: 600; font-size: .88rem;
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease, color .25s ease;
}
.toast svg { width: 15px; height: 15px; flex: none; color: var(--bg); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }