/* ==========================================================================
   FantaPalio UI – Responsive Template
   Palette dark + components (cards, slots, table, progress-bar, buttons)
   Include bottoni primary con colore #F2D43D
   ========================================================================== */

/* ---------- CSS Variables (tema) ---------- */
:root {
  /* Base */
  --bg: #0f1115;
  --ink: #e6e9ef;
  --muted: #9aa4b2;
  --line: #222;

  /* Surfaces */
  --card: #161a22;
  --surface: #0f131a;

  /* Accenti */
  --accent: #5eead4;
  --info: #2196f3;
  --danger: #f43f5e;
  --warning: #f2d43d;
  --success: #22c55e;
  --highlight: #3b82f6;
  --highlight-2: #2563eb;
  --progress: #d9aa52;

  /* Primary (richiesta) */
  --btn-primary: #F2D43D;   /* colore fornito */
  --btn-primary-ink: #0f1115; /* testo scuro su giallo */
  --btn-primary-hover: #e5c92f; /* hover leggermente più scuro */
  --btn-primary-active: #dcbc2f;
  --focus: #F2D43D;
  --danger-hover: #e53950;

  /* Radius & sizing */
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 12px;

  --container-max: 1000px;
}

/* ---------- Reset essenziale ---------- */
* { box-sizing: border-box; }
html, body { margin:0; padding:0; }
img, svg { max-width: 100%; display: block; }

/* ---------- Base ---------- */
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.pill {
  display:inline-block; padding:2px 8px; border-radius:999px;
  border:1px solid #2a3344; font-size:12px; color:var(--muted);
}

/* ---------- Layout ---------- */
.container { max-width: var(--container-max); margin: 24px auto; padding: 0 16px; }
.app-header, .app-footer {
  padding: 18px 16px; border-bottom: 1px solid var(--line);
}
.app-footer { border-top: 1px solid var(--line); border-bottom: 0; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 16px;
}

/* ---------- Griglie / Responsività ---------- */
.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(12, 1fr);
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---------- Form controls ---------- */
input, select, textarea, button {
  font: inherit;
}
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid #2a2f3a;
  background: var(--surface);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items:center; justify-content:center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: var(--r-md);
  border: 1px solid #2a3344;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  transition: transform .04s ease, filter .2s ease, background-color .2s ease, border-color .2s ease;
  text-align: center;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* Primary giallo richiesto */
.btn-primary {
  background: var(--btn-primary);
  border-color: #d3bc37;
  color: var(--btn-primary-ink);
}
.btn-primary:hover { background: var(--btn-primary-hover); }
.btn-primary:active { background: var(--btn-primary-active); }

/* Varianti utili */
.btn-outline {
  background: transparent;
  border-color: var(--muted);
  color: var(--ink);
}
.btn-danger {
  background: var(--danger);
  border-color: #b42b41;
  color: #fff;
}

/* Accessibilità focus */
.btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Tabelle ---------- */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--r-md);
  overflow: hidden;
}
.table th, .table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
}
.table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
}
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Progress Bar (0..50) ---------- */
.progress {
  width: 100%; height: 30px; position: relative; overflow: hidden;
  background: #222836; border-radius: var(--r-md);
}
.progress__bar {
  height: 100%; width: 0%;
  background: var(--progress);
  transition: width .3s ease, background-color .2s ease;
}
.progress__label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--ink);
}

/* ---------- Slots Cast (3 posti) ---------- */
.slots {
  display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr);
  margin-bottom: 12px;
}
.slot {
  position: relative;
  min-height: 72px;
  border: 2px dashed #2b3240;
  border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  padding: 10px; background: var(--surface);
}
.slot--filled { border-style: solid; border-color: var(--accent); background: #101522; }
.slot__empty { color: #54607a; }

.slot__tag {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 600;
  padding: 10px 12px; border-radius: var(--r-md);
  background: #121a26; border: 1px solid #2a3344;
  max-width: 90%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.slot__remove {
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid #2a3344; background:#1a2230; color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; line-height: 1; cursor: pointer;
  z-index: 2; pointer-events: auto; /* migliora la cliccabilità della X */
}
.slot__remove:hover { background:#2a3344; }
.slot__remove:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }


/* Responsività slots: 3→2→1 colonne */
@media (max-width: 900px) { .slots { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .slots { grid-template-columns: 1fr; } }

/* ---------- Helper di stato testo ---------- */
.text-ok    { color: var(--accent); font-weight: 700; }
.text-error { color: var(--danger); font-weight: 700; }
.text-center{ text-align: center; }
.text-white { color: #fff; }
.text-warn { color: var(--warning); font-weight: 700; }
.text-success { color: var(--success); font-weight: 700; }
.text-highlight { color: var(--highlight); font-weight: 700; }
.text-highlight-2 { color: var(--highlight-2); font-weight: 700; }
.text-progress { color: var(--progress); font-weight: 700; }

/* ---------- Spaziature utili ---------- */
.mt-0 { margin-top: 0 !important; }
.mt-8 { margin-top: 8px !important; }
.mt-12{ margin-top: 12px !important; }
.mt-16{ margin-top: 16px !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-8 { margin-bottom: 8px !important; }
.mb-12{ margin-bottom: 12px !important; }
.mb-16{ margin-bottom: 16px !important; }

/* ---------- Header / Footer demo ---------- */
.brand { display:flex; align-items:center; gap:12px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }

/* ---------- Stili di messaggistica inline ---------- */
.notice {
  padding: 10px 12px; border: 1px solid #2a3344; border-radius: var(--r-md);
  background: #121a26; color: var(--ink);
}
.notice--warn {
  border-color: #544b20; background: #2a250e; color: #ffe58a;
}

/* Icona costo accanto al valore */
.cost-cell { display:inline-flex; align-items:middle; gap:6px; justify-content:flex-end; }
.cost-cell .cost-value { font-size: 1.2em; }
.cost-cell .coin { height:2em; width:auto; vertical-align:middle; }

/* Riga cliccabile (cast) */
.table tr.cast-row { cursor: pointer; transition: background-color .15s ease, border-color .15s ease; }
.table tr.cast-row:hover { background: #162034; }       /* hover blu tenue */
.table tr.cast-row.selected { background:#10221d; border-left:4px solid #5eead4; }

/* Media item nella tabella: immagine + testo */
.team-media { display:flex; align-items:center; gap:10px; }
.team-media__img { width: 48px; height: 48px; object-fit: contain; }
.team-media__name { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* Slot: immagine + due righe (nome + costo) affiancati */
.slot__media { display:flex; align-items:center; gap:12px; width:100%; justify-content:flex-start; }
.slot__img { width: 64px; height: 64px; object-fit: contain; }
.slot__text { display:flex; flex-direction:column; min-width:0; }
.slot__name { font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.slot__cost { color:#9aa4b2; display:inline-flex; align-items:middle; gap:6px; }
.slot__cost .coin { height:1.4em; width:auto; vertical-align:middle; }
.slot__remove { z-index: 2; pointer-events: auto; background-color: var(--danger); }
.slot__remove:hover { background-color: #d62e44; }

/* ---------- Navbar ---------- */
.app-nav {
  display: flex;
  justify-content: space-around;
  background: var(--card);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--ink);
  font-size: 13px;
  text-decoration: none;
  gap: 4px;
}
.nav-item:hover {
  color: var(--accent);
}
.nav-icon {
  width: 64px;
  height: 64px;
  object-fit: cover;
}

.nav-text {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
}

.app-header { position: sticky; top: 0; backdrop-filter: blur(8px); background: rgba(15,17,21,.75); z-index: 50; }