/* ============================================================
   Backstage · complementa css/style.css
   Barra lateral, tema e topo vêm de css/layout.css.
   ============================================================ */

.page .state-card {
  margin: 0 auto;
}

/* ---------- Formulários ---------- */


.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

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

.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(145, 95, 242, 0.18);
}

textarea.input {
  resize: vertical;
  line-height: 1.5;
}

select.input {
  appearance: none;
  background: var(--surface-2)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%2366666c' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")
    no-repeat right 12px center;
  padding-right: 34px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  color: var(--danger);
  font-size: 14px;
}

/* ---------- Login ---------- */

.login-screen {
  display: grid;
  place-items: center;
  min-height: 60vh;
}

.login-card {
  width: min(420px, 100%);
  padding: 32px;
}

.login-title {
  font-size: 34px;
}

.login-lede {
  margin: 10px 0 24px;
  color: var(--muted);
}

.login-note {
  margin: 18px 0 0;
  font-size: 13px;
  color: var(--faint);
  text-align: center;
}

/* ---------- Login ---------- */

.login-logo {
  width: 120px;
  height: auto;
  margin-bottom: 16px;
}

/* ---------- Avisos ---------- */

.alerts {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.alerts:not(:has(.alert:not([hidden]))) {
  display: none;
}

.alert {
  --tone: var(--warn);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--tone) 45%, var(--surface));
  background: color-mix(in srgb, var(--tone) 9%, var(--surface));
}

.alert-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 12px;
  background: color-mix(in srgb, var(--tone) 18%, var(--surface));
  color: var(--tone);
}

.alert-icon svg {
  width: 20px;
  height: 20px;
}

.alert-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
  font-size: 14.5px;
  color: var(--muted);
}

.alert-text strong {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.alert-action {
  flex-shrink: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--tone);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.alert-action:hover {
  text-decoration: underline;
}

/* ---------- Início: listas ---------- */

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.dash-card {
  padding: 24px 26px;
  border-radius: 24px;
  box-shadow: none;
}

.dash-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.dash-card-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.top-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.top-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 4px;
}

.top-row + .top-row {
  border-top: 1px solid var(--line);
}

.top-rank {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.top-rank.is-first {
  background: var(--brand-soft);
  border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
  color: var(--brand);
}

.top-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.top-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-meta {
  font-size: 13px;
  color: var(--muted);
}

.top-row.is-contested .top-meta {
  color: var(--warn);
}

.top-points {
  font-weight: 600;
  white-space: nowrap;
}

.top-empty {
  padding: 24px 0;
  text-align: center;
  color: var(--muted);
}

.kv-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.kv-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  font-size: 14.5px;
}

.kv-list li + li {
  border-top: 1px solid var(--line);
}

.kv-list span {
  color: var(--muted);
}

.kv-list strong {
  font-weight: 600;
  text-align: right;
}

.titles-box {
  margin-top: 16px;
  padding: 14px 16px 6px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.titles-box-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
}

.badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 14%, var(--surface));
}

.badge-ok {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 14%, var(--surface));
}

.award-field {
  margin-top: 4px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

/* ---------- Diálogo "Nova temporada" ---------- */

.season-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 80px -30px rgba(31, 6, 62, 0.5);
}

.season-dialog::backdrop {
  background: rgba(31, 6, 62, 0.45);
  backdrop-filter: blur(3px);
}

.season-dialog .settings-card {
  padding: 28px 28px 24px;
}

.dialog-head {
  margin: -28px -28px 0;
  padding: 28px;
  background: var(--brand-gradient);
  color: #fff;
}

.dialog-head .eyebrow {
  color: rgba(255, 255, 255, 0.75);
}

.dialog-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.dialog-text {
  margin: 10px 0 0;
  max-width: 600px;
  font-size: 14.5px;
  color: rgba(255, 255, 255, 0.82);
}

.check-field {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}

.check-field input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--brand-mid);
}

.check-field span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 15px;
}

.check-field strong {
  font-weight: 600;
}

.check-field small {
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Lista de jogadores ---------- */

.players-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.players-toolbar .search-input {
  margin-left: auto;
}

.players-count {
  font-size: 13.5px;
  color: var(--muted);
}

.players-hint {
  margin: 12px 0 18px;
  max-width: 720px;
  font-size: 13.5px;
  color: var(--muted);
}

.players-empty {
  padding: 32px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-row {
  border-radius: 16px;
  box-shadow: none;
}

.player-row[open] {
  box-shadow: var(--shadow);
  border-color: var(--line-strong);
}

.player-row-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
}

.player-row-summary::-webkit-details-marker {
  display: none;
}

.row-thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 600;
}

.backstage-body .row-thumb {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: color-mix(in srgb, var(--accent) 70%, var(--text));
}

.row-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.row-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.row-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta {
  font-size: 13px;
  color: var(--muted);
}

.row-points {
  font-weight: 500;
  white-space: nowrap;
}

.row-chevron {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  border-right: 2px solid var(--faint);
  border-bottom: 2px solid var(--faint);
  margin-top: -4px;
  transform: rotate(45deg);
  transition: transform 0.2s, margin 0.2s;
}

.player-row[open] .row-chevron {
  margin-top: 4px;
  transform: rotate(225deg);
}

.player-row-body {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 24px;
  padding: 20px 16px 16px;
  border-top: 1px solid var(--line);
}

.photo-picker {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  padding: 0;
  overflow: hidden;
  border-radius: 16px;
  border: 1px dashed var(--line-strong);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.photo-picker:hover {
  border-color: var(--text);
}

.photo-picker img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.row-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.row-score {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--accent-line);
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}

.quick-btn small {
  font-size: 12px;
  font-weight: 400;
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
}

.quick-btn:hover {
  background: color-mix(in srgb, var(--accent) 22%, var(--surface));
}

.quick-btn:active {
  transform: scale(0.98);
}

.quick-btn:disabled,
.stepper-btn:disabled {
  opacity: 0.5;
  cursor: progress;
}

.totals {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 12px;
  margin-top: 8px;
}

.stepper {
  display: flex;
  gap: 6px;
}

.stepper .input {
  text-align: center;
  min-width: 0;
}

.stepper-btn {
  width: 40px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 18px;
  cursor: pointer;
}

.stepper-btn:hover {
  border-color: var(--text);
}

.row-footer {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.row-status {
  font-size: 13.5px;
}

.row-status.is-ok {
  color: var(--ok);
}

.row-status.is-error {
  color: var(--danger);
}

.row-status.is-info {
  color: var(--muted);
}

.undo-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.remove-btn {
  margin-left: auto;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--danger);
  font-size: 13.5px;
  cursor: pointer;
}

.remove-btn:hover {
  text-decoration: underline;
}

/* ---------- Definições ---------- */

.settings-card {
  padding: 8px 28px 24px;
}

.settings-group {
  margin: 0;
  padding: 22px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-group legend {
  float: left;
  width: 100%;
  padding: 0;
  margin-bottom: 14px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.grid-2,
.grid-3 {
  display: grid;
  gap: 14px;
  clear: both;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  display: grid;
  gap: 14px;
  clear: both;
  grid-template-columns: 0.7fr repeat(3, minmax(0, 1fr));
}

.color-field {
  display: flex;
  gap: 8px;
}

.color-field input[type="color"] {
  width: 46px;
  height: 42px;
  flex-shrink: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 22px;
}

.form-footer .form-error {
  margin-right: auto;
}

.saved-flag {
  font-size: 14px;
  color: var(--ok);
}

/* ---------- Ecrãs médios e telemóvel ---------- */

@media (max-width: 1100px) {
  .dash-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- Telemóvel ---------- */

@media (max-width: 860px) {
  .player-row-body {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .photo-picker {
    width: 96px;
    height: 96px;
  }

  .row-score {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .player-row-summary {
    gap: 10px;
    padding: 10px 12px;
  }

  .player-row-body {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 16px 12px 12px;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .totals {
    grid-template-columns: 1fr;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .season-dialog .settings-card {
    padding: 22px 18px 18px;
  }

  .dialog-head {
    margin: -22px -18px 0;
    padding: 22px 18px;
  }

  .settings-card {
    padding: 4px 18px 18px;
  }

  .players-toolbar .search-input {
    width: 100%;
    margin-left: 0;
  }

  .dash-card {
    padding: 20px 18px;
    border-radius: 20px;
  }

  .alert {
    flex-wrap: wrap;
    padding: 14px 16px;
  }

  .alert-text {
    flex-basis: calc(100% - 58px);
  }

  .alert-action {
    margin-left: 58px;
  }
}
