/* Wiederverwendbare Bausteine */

/* Karten & Kennzahlen */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card > h2, .card > h3 { margin-bottom: 12px; }

.stat .label { color: var(--text-muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; }
.stat .value { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; margin: 2px 0; }
.stat .sub { font-size: 0.85rem; color: var(--text-muted); }

/* Status */
.loading, .error, .empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
}
.error { color: var(--down); }

/* Werkzeugleiste mit Filtern */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar input[type="search"], .toolbar select, .input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  min-width: 0;
}
.toolbar input[type="search"] { flex: 1 1 220px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.88rem;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.chip .count { opacity: 0.7; margin-left: 4px; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  white-space: nowrap;
}
.badge.warn { border-color: var(--tier-a); color: var(--tier-a); }

/* Tabellen */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { background: var(--surface-2); font-weight: 600; white-space: nowrap; position: sticky; top: 0; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent-strong); }
th[aria-sort="ascending"]::after { content: " ▲"; font-size: 0.7em; }
th[aria-sort="descending"]::after { content: " ▼"; font-size: 0.7em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td .icon { width: 40px; height: 40px; object-fit: contain; }

/* Item-Kacheln */
.item-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.item-tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  cursor: pointer;
  min-width: 0;
}
.item-tile:hover { border-color: var(--accent); }
.item-tile img { width: 100%; height: 90px; object-fit: contain; background: var(--surface-2); border-radius: 6px; }
.item-tile .name { font-weight: 600; font-size: 0.92rem; overflow-wrap: anywhere; }
.item-tile .meta { font-size: 0.8rem; color: var(--text-muted); display: flex; justify-content: space-between; gap: 6px; }

/* Detail-Dialog */
.dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
}
.dialog::backdrop { background: rgb(0 0 0 / 0.55); }
.dialog form { position: sticky; top: 0; display: flex; justify-content: flex-end; }
.dialog-close { border: 0; background: transparent; font-size: 1.6rem; line-height: 1; padding: 8px 14px; cursor: pointer; color: var(--text-muted); }
.dialog-body { padding: 0 20px 20px; }
.detail-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.detail-head img { width: 120px; height: 120px; object-fit: contain; background: var(--surface-2); border-radius: 6px; flex-shrink: 0; }
.detail-head .flavor { font-style: italic; color: var(--text-muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 0.9rem; margin: 0 0 16px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.pre-line { white-space: pre-line; }

/* Diagramme */
.chart { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--text-muted); font-size: 11px; }
.chart .line { fill: none; stroke: var(--gold); stroke-width: 2; }
.chart .area { fill: var(--gold); opacity: 0.12; }
.chart .dot { fill: var(--gold); }
.chart .hover-line { stroke: var(--text-muted); stroke-dasharray: 3 3; }
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--text);
  color: var(--bg);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  white-space: nowrap;
  transform: translate(-50%, -110%);
}
.chart-box { position: relative; }

.bar-row { display: grid; grid-template-columns: 140px 1fr 60px; gap: 8px; align-items: center; font-size: 0.85rem; margin: 3px 0; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 5px; }

/* Tierliste */
.tier-row { display: grid; grid-template-columns: 64px 1fr; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 10px; background: var(--surface); }
.tier-label { display: grid; place-items: center; font-size: 1.8rem; font-weight: 800; color: #fff; }
.tier-items { display: grid; gap: 8px; padding: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tier-item { display: flex; gap: 10px; align-items: flex-start; }
.tier-item img { width: 64px; height: 40px; object-fit: contain; flex-shrink: 0; }
.tier-item p { margin: 0; font-size: 0.85rem; color: var(--text-muted); }

/* Legende */
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.85rem; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 6px; }

/* News */

/* Spieler / Profile */
.player { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }
.profile-card .bio { font-size: 0.88rem; color: var(--text-muted); max-height: 7.5em; overflow: hidden; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }

.pagination { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 16px; }
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: default; }

/* Anmeldung / Admin */
.login-form, .admin-form { display: flex; flex-direction: column; gap: 10px; max-width: 520px; }
.login-form { padding: 4px 0 8px; }
.login-form .btn, .admin-form .btn { align-self: flex-start; }
.admin-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.admin-row .tactic-field { flex: 1 1 180px; }
.tactic-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--text-muted); }

.screens { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.screens img { height: 140px; width: auto; border-radius: 6px; }

@media (max-width: 760px) {
  .detail-head { flex-direction: column; }
  .bar-row { grid-template-columns: 100px 1fr 50px; }
  .tier-row { grid-template-columns: 44px 1fr; }
}

/* Konten */
.invite-code { font-family: ui-monospace, Consolas, monospace; font-size: 0.9rem; padding: 3px 8px; border: 1px dashed var(--border); border-radius: 6px; user-select: all; white-space: nowrap; }
.login-switch { font-size: 0.85rem; margin: 4px 0 0; }
.auth-account { display: inline-flex; align-items: center; gap: 2px; }
@media (max-width: 700px) { .auth-team-name { display: none; } }
.account-more > summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; }
.api-scopes { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 10px; }
.api-key-new { border-color: var(--accent); display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.api-key-value { white-space: normal; overflow-wrap: anywhere; }
.muted-badge { opacity: 0.6; }

/* Anmeldung mit Steam (Dialog, Kopfzeile) */
.btn.steam-login { display: inline-flex; align-items: center; justify-content: center; gap: 10px; background: linear-gradient(180deg, #1f3a57 0%, #171a21 100%); color: #fff; border-color: #2a475e; text-decoration: none; padding: 9px 16px; font-weight: 600; }
.btn.steam-login:hover { border-color: #66c0f4; color: #fff; }
.steam-logo { color: #66c0f4; font-size: 1.1rem; line-height: 1; }
.login-or { margin: 6px 0 0; font-size: 0.85rem; }
.auth-avatar { width: 20px; height: 20px; border-radius: 4px; margin-right: 6px; object-fit: cover; }

/* Administration */
.admin-tabs { margin: 0 0 16px; flex-wrap: wrap; }
.admin-tabs a.chip { text-decoration: none; }
.admin-tile { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; }
.admin-tile strong { font-size: 1.6rem; }
.admin-emergency { margin-top: 12px; }
.admin-emergency > summary { cursor: pointer; color: var(--text-muted); margin-bottom: 8px; }
.role-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; border: 1px solid var(--c); color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); white-space: nowrap; }
.role-list { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.role-pick > summary { cursor: pointer; list-style: none; }
.role-pick > summary::-webkit-details-marker { display: none; }
.role-pick-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.color-pick { position: relative; overflow: hidden; }
.color-pick input[type=color] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.auth-admin { text-decoration: none; }
/* Rechte-Matrix (auch ohne Squad-Modul) */
.rank-matrix table { min-width: 600px; }
.rank-matrix th.rank-head { vertical-align: top; text-align: center; min-width: 110px; }
.rank-matrix td.rank-cell { text-align: center; }
.rank-matrix tr.rank-group td { font-weight: 600; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.06em; color: var(--text-muted); padding-top: 14px; }
.rank-actions { display: flex; gap: 2px; justify-content: center; margin-top: 4px; flex-wrap: wrap; }
.btn-mini { padding: 1px 6px; font-size: 0.75rem; min-width: 0; }

/* Ankreuz-Zeile (Kästchen + Text), unabhängig von der Kartenformatierung */
.check-row { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; font-size: 0.9rem; line-height: 1.4; }
.check-row input { margin-top: 3px; flex: none; }
.admin-form.wide { max-width: none; }
.api-scopes { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px 18px; }
.api-scopes legend { padding: 0 6px; font-size: 0.8rem; color: var(--text-muted); }
.api-scope > span { display: flex; flex-direction: column; gap: 2px; }
.api-scope code { font-size: 0.85rem; }
