/* ============================================================
   Crossfire CRM — Layout & Komponenten (nutzt Tokens aus style.css)
   ============================================================ */

.crm-body {
  display: block;
  background: var(--bg);
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.crm-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 230px;
  background: var(--dark);
  color: var(--text-inv);
  display: flex;
  flex-direction: column;
  z-index: 100;
}
.crm-brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1.3rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.crm-brand img { width: 46px; }
.crm-brand span {
  font-family: var(--font-display);
  text-transform: uppercase;
  font-size: 1.05rem;
  line-height: 1.15;
  letter-spacing: 0.05em;
}
.crm-nav { flex: 1; padding: 1rem 0; display: flex; flex-direction: column; overflow-y: auto; }
.crm-nav-group {
  padding: 1rem 1.4rem 0.35rem;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
}
.crm-nav a {
  padding: 0.75rem 1.4rem;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-inv-muted);
  border-left: 3px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.crm-nav a:hover { color: #fff; background: rgba(255,255,255,0.05); }
.crm-nav a.active { color: #fff; border-left-color: var(--accent); background: rgba(228,23,59,0.12); }
.crm-user {
  padding: 1rem 1.4rem 1.2rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.8rem;
  display: grid;
  gap: 0.3rem;
}
.crm-user .who { font-weight: 700; color: #fff; }
.crm-user a { color: var(--text-inv-muted); text-decoration: underline; }
.crm-user a:hover { color: #fff; }

.crm-burger {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 200;
  width: 44px; height: 44px;
  border: 0;
  border-radius: var(--radius-s);
  background: var(--dark);
  color: #fff;
  font-size: 1.2rem;
}

/* ---------- Main ---------- */
.crm-main {
  margin-left: 230px;
  padding: 2.2rem 2.4rem 5rem;
  max-width: 1200px;
}
.crm-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.6rem; }
.crm-head h1 { font-size: clamp(1.8rem, 3vw, 2.4rem); }
.crm-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; }

@media (max-width: 900px) {
  .crm-sidebar { transform: translateX(-100%); transition: transform 0.3s var(--ease); }
  .crm-nav-open .crm-sidebar { transform: none; }
  .crm-burger { display: block; }
  .crm-main { margin-left: 0; padding: 4.5rem 1.2rem 4rem; }
}

/* ---------- Alerts ---------- */
.crm-alert {
  padding: 0.9rem 1.2rem;
  border-radius: var(--radius-s);
  font-weight: 500;
  font-size: 0.92rem;
  margin-bottom: 1.4rem;
}
.crm-alert.ok { background: #e7f6ec; color: #14683a; border: 1px solid #bfe6cd; }
.crm-alert.err { background: #fdeaee; color: #9c1029; border: 1px solid #f6c3cd; }

/* ---------- Cards / Listen ---------- */
.crm-card {
  background: var(--surface);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-s);
  padding: 1.4rem 1.6rem;
  margin-bottom: 1.4rem;
}
.crm-card h2 { font-size: 1.15rem; font-family: var(--font-body); font-weight: 700; text-transform: none; letter-spacing: 0; margin-bottom: 1rem; }

.crm-list { display: grid; gap: 0.8rem; }
.crm-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow-s);
  padding: 0.9rem 1.2rem;
  flex-wrap: wrap;
}
.crm-row .grow { flex: 1; min-width: 160px; }
.crm-row .title { font-weight: 700; }
.crm-row .meta { font-size: 0.8rem; color: var(--text-muted); }
.crm-row .row-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Team-Logo */
.team-logo { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; background: var(--dark-2); flex: none; }
.team-logo-fallback {
  display: inline-grid;
  place-items: center;
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.1rem;
  background: var(--accent);
}

/* Flags (Season/Division) */
.flag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  margin: 0.15rem 0.25rem 0.15rem 0;
  white-space: nowrap;
}
.flag-season { background: var(--dark); color: #fff; }
.flag-division { background: var(--accent); color: #fff; }

/* ---------- Buttons (klein) ---------- */
.btn-s { padding: 0.5rem 0.95rem; font-size: 0.82rem; }
.btn-danger { background: #fff; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-danger:hover { background: var(--accent); color: #fff; }

/* ---------- Formulare ---------- */
.crm-form .form-grid { margin-top: 0.4rem; }
.crm-form .field { margin-bottom: 0.2rem; }
.upload-box {
  border: 2px dashed rgba(12,12,14,0.2);
  border-radius: var(--radius-s);
  padding: 1rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--bg-soft);
}
.upload-box input { margin-top: 0.5rem; width: 100%; }
.upload-box img.preview { max-height: 90px; margin: 0 auto 0.6rem; border-radius: 6px; }

/* ---------- Filterleiste ---------- */
.filter-bar { display: flex; gap: 0.7rem; flex-wrap: wrap; margin-bottom: 1.4rem; align-items: flex-end; }
.filter-bar .field { min-width: 170px; margin: 0; }
.filter-bar select, .filter-bar input {
  width: 100%;
  border: 1.5px solid rgba(12,12,14,0.14);
  border-radius: var(--radius-s);
  background: var(--surface);
  padding: 0.6rem 0.8rem;
  font-family: inherit;
  font-size: 0.88rem;
}
.filter-bar label { display: block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 0.3rem; }

/* Suchfeld mit Dropdown */
.search-wrap { position: relative; min-width: 240px; }
.search-results {
  position: absolute;
  top: 100%; left: 0; right: 0;
  z-index: 50;
  background: var(--surface);
  border-radius: 0 0 var(--radius-s) var(--radius-s);
  box-shadow: var(--shadow-m);
  max-height: 260px;
  overflow-y: auto;
  display: none;
}
.search-results.open { display: block; }
.search-results a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  font-size: 0.88rem;
  border-bottom: 1px solid rgba(12,12,14,0.06);
}
.search-results a:hover { background: var(--bg-soft); }

/* ---------- Match-Kacheln ---------- */
.match-card {
  background: var(--surface);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow-s);
  padding: 1rem 1.2rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.9rem;
}
.match-side { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.match-side.right { flex-direction: row-reverse; text-align: right; }
.match-side .tname { font-weight: 700; font-size: 0.95rem; overflow-wrap: anywhere; }
.match-side .surrender-btn {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: none;
  border: 1px solid rgba(228,23,59,0.4);
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
}
.match-side .surrender-btn.active { background: var(--accent); color: #fff; }
.match-mid { text-align: center; }
.match-mid .score-inputs { display: flex; align-items: center; gap: 0.4rem; justify-content: center; }
.match-mid input[type="number"] {
  width: 56px;
  text-align: center;
  font-weight: 700;
  font-size: 1.05rem;
  border: 1.5px solid rgba(12,12,14,0.14);
  border-radius: var(--radius-s);
  padding: 0.45rem 0.3rem;
  background: var(--bg-soft);
}
.match-mid input[type="date"] {
  margin-top: 0.5rem;
  border: 1.5px solid rgba(12,12,14,0.14);
  border-radius: var(--radius-s);
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  background: var(--bg-soft);
}
.match-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.3rem; }
@media (max-width: 760px) {
  .match-card { grid-template-columns: 1fr; text-align: center; }
  .match-side, .match-side.right { flex-direction: column; text-align: center; }
}

/* ---------- Standings ---------- */
.standings-wrap { overflow-x: auto; }
.standings-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius-s);
  overflow: hidden;
  box-shadow: var(--shadow-s);
  font-size: 0.92rem;
}
.standings-table thead th {
  background: var(--dark);
  color: #fff;
  text-align: left;
  font-family: var(--font-display);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  padding: 0.7rem 0.9rem;
}
.standings-table td { padding: 0.6rem 0.9rem; border-bottom: 1px solid rgba(12,12,14,0.06); }
.standings-table tbody tr:nth-child(even) { background: var(--bg-soft); }
.standings-table .col-rank { width: 60px; text-align: center; font-weight: 700; }
.standings-table .col-team { display: flex; align-items: center; gap: 0.7rem; }
.standings-table .empty { text-align: center; color: var(--text-muted); padding: 1.4rem; }
.standings-table a { text-decoration: underline; }

/* ---------- Changelog / Collapsible ---------- */
.log-list { display: grid; gap: 0.5rem; max-height: 380px; overflow-y: auto; }
.log-item {
  font-size: 0.84rem;
  padding: 0.55rem 0.8rem;
  background: var(--bg-soft);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}
.log-item .who { font-weight: 700; }
.log-item .when { color: var(--text-muted); font-size: 0.72rem; margin-left: 0.4rem; }

details.collapse-3 summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent);
  padding: 0.4rem 0;
  list-style: none;
}
details.collapse-3 summary::-webkit-details-marker { display: none; }

.crm-grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.4rem; align-items: start; }
@media (max-width: 1000px) { .crm-grid-2 { grid-template-columns: 1fr; } }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--dark) url('../img/CFL.webp') center / cover no-repeat;
  padding: 1.5rem;
}
.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-l);
  padding: 2.4rem 2.2rem;
  text-align: center;
}
.login-card img.badge { width: 90px; margin: 0 auto 1rem; }
.login-card h1 { font-size: 1.6rem; margin-bottom: 1.4rem; }
.login-card .field { text-align: left; margin-bottom: 1rem; }
.login-card .btn { width: 100%; justify-content: center; }
.login-note { font-size: 0.78rem; color: var(--text-muted); margin-top: 1rem; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 0.4rem; justify-content: center; margin-top: 1.4rem; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-s);
  background: var(--surface);
  box-shadow: var(--shadow-s);
  font-size: 0.85rem;
  font-weight: 600;
}
.pagination .current { background: var(--accent); color: #fff; }
