/* =========================================================================
   Stile del gestionale — palette e tipografia di trentinovolley.it
   (Oswald per i titoli, Open Sans per il testo, blu navy + giallo)
   ========================================================================= */

:root {
  --navy: #0d1f4f;
  --navy-deep: #081e67;
  --navy-dark: #080d33;
  --blue: #0043c9;
  --blue-hi: #0045cf;
  --yellow: #ffce0a;
  --red: #a60000;
  --green: #1a8f4c;
  --ink: #171717;
  --muted: #6f6f6f;
  --line: #dfe3ee;
  --bg: #f2f4f9;
  --card: #ffffff;

  --radius: 4px;
  --shadow: 0 1px 3px rgba(8, 13, 51, 0.12), 0 8px 24px rgba(8, 13, 51, 0.06);
}

* {
  box-sizing: border-box;
}

/* Un `display` dichiarato in una classe batte la regola `[hidden]` del browser:
   senza questa riga, nascondere un elemento da JS non funziona. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Open Sans', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

h1,
h2,
h3,
h4,
.font-title {
  font-family: 'Oswald', sans-serif;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 0;
}

a {
  color: var(--blue);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* -------------------------------------------------------------------------
   testata
   ------------------------------------------------------------------------- */

.topbar {
  background: var(--navy);
  color: #fff;
  border-bottom: 4px solid var(--yellow);
}

.topbar-inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 24px;
  height: 68px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: #fff;
  border-radius: 2px;
}

.brand-mark svg {
  width: 26px;
  height: 26px;
}

.brand-text {
  font-family: 'Oswald', sans-serif;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.05;
}

.brand-text small {
  display: block;
  font-size: 11px;
  font-weight: 300;
  letter-spacing: 0.22em;
  color: var(--yellow);
}

.topnav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  align-items: center;
}

.topnav a {
  color: #fff;
  font-family: 'Oswald', sans-serif;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 14px;
  border-radius: 2px;
}

.topnav a:hover {
  background: rgba(255, 255, 255, 0.1);
  text-decoration: none;
}

.topnav a.active {
  background: var(--yellow);
  color: var(--navy);
  font-weight: 500;
}

.topnav .user {
  font-size: 13px;
  color: #c9cee6;
  padding-left: 12px;
  margin-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
}

/* -------------------------------------------------------------------------
   impaginazione
   ------------------------------------------------------------------------- */

.wrap {
  max-width: 1360px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-head h1 {
  font-size: 30px;
}

.page-head .sub {
  color: var(--muted);
  font-size: 14px;
}

.page-head .spacer {
  margin-left: auto;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-head h2 {
  font-size: 17px;
}

.card-body {
  padding: 18px;
}

.grid {
  display: grid;
  gap: 18px;
}

/* -------------------------------------------------------------------------
   controlli
   ------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Oswald', sans-serif;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 2px;
  background: var(--navy);
  color: #fff;
  cursor: pointer;
  transition: filter 120ms ease, background-color 120ms ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.15);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-yellow {
  background: var(--yellow);
  color: var(--navy);
  font-weight: 500;
}

.btn-ghost {
  background: transparent;
  color: var(--navy);
  border-color: var(--line);
}

.btn-ghost:hover:not(:disabled) {
  background: #eef1f8;
}

.btn-danger {
  background: var(--red);
}

.btn-sm {
  padding: 5px 11px;
  font-size: 12.5px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

input[type='text'],
input[type='password'],
input[type='number'],
input[type='datetime-local'],
select,
textarea {
  font-family: 'Open Sans', sans-serif;
  font-size: 15px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--blue);
  outline-offset: -1px;
}

.form-row {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

/* -------------------------------------------------------------------------
   tabelle e liste
   ------------------------------------------------------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr:hover {
  background: #f7f9fd;
}

.team-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.team-logo {
  width: 30px;
  height: 30px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 2px;
  flex: 0 0 auto;
}

/* senza logo caricato non si mostra il segnaposto vuoto */
img.team-logo:not([src]),
span.team-logo {
  display: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Oswald', sans-serif;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 20px;
  background: #eceff7;
  color: var(--muted);
}

.badge.on {
  background: #e3f6ea;
  color: var(--green);
}

.badge.live {
  background: var(--red);
  color: #fff;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.badge.on .dot {
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.25;
  }
}

.empty {
  padding: 44px 18px;
  text-align: center;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 7px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* -------------------------------------------------------------------------
   switch attiva/disattiva
   ------------------------------------------------------------------------- */

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 25px;
  flex: 0 0 auto;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  background: #c8cddd;
  border-radius: 25px;
  cursor: pointer;
  transition: background-color 140ms ease;
}

.switch span::before {
  content: '';
  position: absolute;
  width: 19px;
  height: 19px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 140ms ease;
}

.switch input:checked + span {
  background: var(--green);
}

.switch input:checked + span::before {
  transform: translateX(21px);
}

/* -------------------------------------------------------------------------
   login
   ------------------------------------------------------------------------- */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, var(--navy-dark), var(--navy) 55%, var(--navy-deep));
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.login-card header {
  background: var(--navy);
  color: #fff;
  padding: 26px 28px;
  border-bottom: 4px solid var(--yellow);
  text-align: center;
}

.login-card header h1 {
  font-size: 22px;
  letter-spacing: 0.08em;
}

.login-card header p {
  margin: 6px 0 0;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--yellow);
}

.login-card form {
  padding: 26px 28px 30px;
  display: grid;
  gap: 16px;
}

.alert {
  background: #fdeaea;
  border-left: 3px solid var(--red);
  color: #7a1414;
  padding: 9px 12px;
  font-size: 13.5px;
  border-radius: 2px;
}

.alert.ok {
  background: #e6f6ec;
  border-left-color: var(--green);
  color: #125c31;
}

/* -------------------------------------------------------------------------
   toast
   ------------------------------------------------------------------------- */

.toast-host {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}

.toast {
  background: var(--navy);
  color: #fff;
  padding: 10px 16px;
  border-radius: 2px;
  border-left: 3px solid var(--yellow);
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: toast-in 160ms ease;
}

.toast.err {
  border-left-color: var(--red);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* -------------------------------------------------------------------------
   dialog
   ------------------------------------------------------------------------- */

dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: 640px;
  width: calc(100vw - 40px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
}

dialog::backdrop {
  background: rgba(8, 13, 51, 0.55);
}

dialog header {
  padding: 16px 20px;
  background: var(--navy);
  color: #fff;
  border-bottom: 3px solid var(--yellow);
}

dialog header h2 {
  font-size: 17px;
}

dialog .body {
  padding: 20px;
  display: grid;
  gap: 14px;
  max-height: 70vh;
  overflow: auto;
}

dialog footer {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
}

/* -------------------------------------------------------------------------
   editor distinta
   ------------------------------------------------------------------------- */

dialog.wide {
  max-width: 880px;
}

dialog header p {
  margin: 4px 0 0;
  font-size: 12.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--yellow);
}

.roster-body {
  gap: 12px;
}

.roster-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.roster-toolbar .count {
  font-family: 'Oswald', sans-serif;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.roster-toolbar .warn {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--red);
  background: #fdeaea;
  padding: 2px 9px;
  border-radius: 20px;
}

.roster-editor {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

/* le colonne dell'intestazione e delle righe devono coincidere */
.roster-head,
.roster-row {
  display: grid;
  grid-template-columns: 30px 62px minmax(0, 1.5fr) minmax(0, 1.2fr) 132px 38px;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
}

.roster-head {
  background: #f4f6fb;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

#r-rows {
  max-height: 46vh;
  overflow-y: auto;
}

.roster-row {
  border-bottom: 1px solid #eef1f7;
  background: #fff;
  transition: background-color 120ms ease;
}

.roster-row:last-child {
  border-bottom: none;
}

.roster-row:hover {
  background: #f9fbff;
}

.roster-row.dragging {
  opacity: 0.4;
}

.roster-row.drop-target {
  box-shadow: inset 0 2px 0 var(--yellow);
}

.roster-row.duplicate .num input {
  border-color: var(--red);
  background: #fdeaea;
}

.roster-row .grip {
  cursor: grab;
  color: #b9c0d4;
  text-align: center;
  font-size: 15px;
  line-height: 1;
  user-select: none;
}

.roster-row .grip:active {
  cursor: grabbing;
}

.roster-row input,
.roster-row select {
  padding: 6px 8px;
  font-size: 14px;
}

.roster-row .num input {
  text-align: center;
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  /* le frecce del number rubano spazio a due cifre */
  -moz-appearance: textfield;
  appearance: textfield;
}

.roster-row .num input::-webkit-outer-spin-button,
.roster-row .num input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.roster-row .surname input {
  font-weight: 700;
  text-transform: uppercase;
}

.roster-row .kill {
  border: none;
  background: transparent;
  color: #8a93ad;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  border-radius: 3px;
  padding: 3px 6px;
  transition: color 120ms ease, background-color 120ms ease;
}

.roster-row .kill:hover {
  color: #fff;
  background: var(--red);
}

.roster-empty {
  padding: 34px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 2.2;
}

.roster-hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

.grip-demo {
  color: #b9c0d4;
}

.staff-box {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.staff-box summary {
  cursor: pointer;
  font-family: 'Oswald', sans-serif;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.staff-box ul {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 4px 18px;
  font-size: 13.5px;
}

.staff-box li {
  color: var(--ink);
}

.staff-box li span {
  color: var(--muted);
}

/* -------------------------------------------------------------------------
   editor logo
   ------------------------------------------------------------------------- */

/* il logo in elenco e' cliccabile: apre l'editor */
.logo-cell {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #b9c0d4;
  font-size: 17px;
  line-height: 1;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.logo-cell img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-cell:hover {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 67, 201, 0.14);
}

.logo-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-chip {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #b9c0d4;
  font-size: 11px;
}

.logo-chip img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-editor {
  display: grid;
  grid-template-columns: 256px 1fr;
  gap: 22px;
  align-items: start;
}

@media (max-width: 640px) {
  .logo-editor {
    grid-template-columns: 1fr;
  }
}

.logo-stage {
  position: relative;
  width: 256px;
  height: 256px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.logo-stage canvas {
  display: block;
  width: 256px;
  height: 256px;
  cursor: grab;
  touch-action: none;
}

.logo-stage canvas:active {
  cursor: grabbing;
}

.logo-stage.dragover {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 2px var(--blue);
}

.logo-drop {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 7px;
  background: #f7f9fd;
  text-align: center;
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
}

.logo-drop b {
  color: var(--ink);
  font-size: 14px;
}

.logo-drop small {
  font-size: 11.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.logo-controls {
  display: grid;
  gap: 14px;
  align-content: start;
}

.logo-controls input[type='range'] {
  width: 100%;
  accent-color: var(--navy);
}

.logo-hint {
  margin: -4px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.logo-realsize {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

/* riproduzione fedele della testata del pannello squadra (62 px come sulla grafica) */
.header-mock {
  display: flex;
  align-items: stretch;
  width: 320px;
  max-width: 100%;
  height: 62px;
  background: #101c46;
  margin-top: 8px;
}

.header-mock .mock-logo {
  width: 62px;
  flex: 0 0 62px;
  background: #fff;
  display: grid;
  place-items: center;
  padding: 4px;
}

.header-mock .mock-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.header-mock .mock-logo img:not([src]) {
  display: none;
}

.header-mock .mock-plate {
  flex: 1 1 auto;
  min-width: 0;
  background: #dfe2f4;
  display: flex;
  align-items: center;
  padding: 2px 8px;
}

.header-mock .mock-plate span {
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  font-size: 22px;
  line-height: 1.06;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: #101c46;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
