/* ============================================================
   KonfiCastle – Stylesheet
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #2563eb;
  --primary-dk: #1d4ed8;
  --danger:     #dc2626;
  --warn:       #d97706;
  --success:    #16a34a;
  --bg:         #f8fafc;
  --surface:    #ffffff;
  --border:     #e2e8f0;
  --text:       #1e293b;
  --muted:      #64748b;
  --sidebar-w:  240px;
  --radius:     6px;
  --shadow:     0 1px 3px rgba(0,0,0,.1);
}

body { font-family: system-ui, sans-serif; color: var(--text); background: var(--bg); font-size: 15px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Auth-Seiten ─────────────────────────────────────────── */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; width: 100%; max-width: 400px; }
.auth-card-wide { max-width: 520px; }
.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo h1 { font-size: 1.6rem; color: var(--primary); }
.auth-hint { text-align: center; margin-top: 1rem; font-size: 0.85rem; color: var(--muted); }

/* ── Admin-Layout ────────────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: #1e293b; color: #cbd5e1; display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-brand { padding: 1.25rem 1rem; font-size: 1.1rem; font-weight: 700; color: #fff; border-bottom: 1px solid #334155; text-decoration: none !important; }
.sidebar-brand:hover { background: #334155; }
.brand-icon { margin-right: .4rem; }
.sidebar-nav { list-style: none; padding: .5rem 0; flex: 1; }
.sidebar-nav li { }
.nav-link { display: block; padding: .55rem 1rem; color: #94a3b8; transition: background .15s; border-radius: 0; }
.nav-link:hover, .nav-link.active { background: #334155; color: #fff; text-decoration: none; }
.nav-section { padding: .75rem 1rem .25rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #475569; }
.sidebar-saison { padding: .5rem .75rem; border-bottom: 1px solid #334155; }
.saison-select { background: #334155; color: #e2e8f0; border: 1px solid #475569; border-radius: var(--radius); padding: .35rem .5rem; font-size: .8rem; width: 100%; }
.sidebar-footer { padding: 1rem; border-top: 1px solid #334155; font-size: .85rem; }
.sidebar-user { display: block; color: #e2e8f0; font-weight: 600; }
.sidebar-role { display: inline-block; margin: .25rem 0 .5rem; }
.btn-link { background: none; border: none; cursor: pointer; color: #94a3b8; font-size: .85rem; padding: 0; }
.btn-link:hover { color: #fff; }

.main-content { flex: 1; padding: 1.5rem 2rem; overflow-y: auto; max-width: 1200px; }
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header .subtitle { color: var(--muted); }

/* ── Gast-Layout ──────────────────────────────────────────── */
.gast-layout { min-height: 100vh; background: var(--bg); }
.gast-header { background: #1e293b; color: #fff; display: flex; align-items: center; justify-content: space-between; padding: .75rem 1.5rem; }
.gast-brand { font-size: 1.1rem; font-weight: 700; }
.gast-user { display: flex; align-items: center; gap: 1rem; font-size: .9rem; color: #94a3b8; }
.gast-main { padding: 1.5rem; max-width: 1100px; margin: 0 auto; }

/* ── Karten ───────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.5rem; box-shadow: var(--shadow); }
.card h2 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }

/* ── Tabellen ─────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; margin-bottom: 1.5rem; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th { background: #f1f5f9; text-align: left; padding: .6rem .85rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--border); }
td { padding: .65rem .85rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
.row-inactive td { opacity: .6; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); font-size: .85rem; }
.text-red { color: var(--danger); }

/* ── Formulare ────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .3rem; }
.form-group label { font-size: .85rem; font-weight: 500; }
.form-group small { color: var(--muted); font-size: .78rem; }
.hint { color: var(--muted); font-size: .82rem; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], select, textarea {
  border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem;
  font-size: .9rem; width: 100%; background: var(--surface); color: var(--text);
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }
.form-row-inline { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.form-row-inline .form-group { min-width: 160px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; align-items: flex-end; }
.form-group-action { display: flex; align-items: flex-end; }
.form-actions { display: flex; gap: .75rem; margin-top: .75rem; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; padding: .5rem 1rem; border-radius: var(--radius); border: 1px solid transparent; font-size: .875rem; font-weight: 500; cursor: pointer; text-decoration: none !important; transition: background .15s, box-shadow .15s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dk); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #f1f5f9; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warn { background: var(--warn); color: #fff; }
.btn-warn:hover { background: #b45309; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-xs { padding: .15rem .5rem; font-size: .75rem; }
.btn-full { width: 100%; justify-content: center; }
button.btn { font-family: inherit; }

/* ── Badges ───────────────────────────────────────────────── */
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-admin      { background: #ede9fe; color: #7c3aed; }
.badge-benutzer   { background: #dbeafe; color: #1d4ed8; }
.badge-kc-leitung { background: #fce7f3; color: #9d174d; }
.badge-ok      { background: #dcfce7; color: #166534; }
.badge-warn    { background: #fef3c7; color: #92400e; }
.badge-error   { background: #fee2e2; color: #991b1b; }
.badge-offen        { background: #dbeafe; color: #1d4ed8; }
.badge-eingereicht  { background: #fef3c7; color: #92400e; }
.badge-bestaetigt   { background: #dcfce7; color: #166534; }
.badge-storniert    { background: #f1f5f9; color: #64748b; }
.badge-geaendert    { background: #fff7ed; color: #c2410c; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert { padding: .85rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .9rem; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-warn    { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Fortschrittsbalken ───────────────────────────────────── */
.progress-bar { height: 6px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin: .25rem 0; }
.progress-fill { height: 100%; border-radius: 999px; transition: width .3s; }
.fill-green  { background: var(--success); }
.fill-yellow { background: var(--warn); }
.fill-red    { background: var(--danger); }

/* ── Stats ────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; text-align: center; box-shadow: var(--shadow); }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: .8rem; color: var(--muted); margin-top: .25rem; }

/* ── Castle-Karten (Gast + User) ─────────────────────────── */
.castle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.25rem; }
.castle-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.castle-card.castle-full { opacity: .75; border-color: #fca5a5; }
.castle-card-header { padding: 1rem 1.25rem .75rem; border-bottom: 1px solid var(--border); }
.castle-card-header h2 { font-size: 1.1rem; font-weight: 700; }
.castle-ort { color: var(--muted); font-size: .85rem; margin-top: .2rem; }
.castle-card-body { padding: 1rem 1.25rem; flex: 1; }
.castle-card-footer { padding: .75rem 1.25rem; border-top: 1px solid var(--border); }
.capacity-info, .capacity-bar { margin-bottom: .75rem; }
.tn-count { font-size: 1.4rem; font-weight: 700; color: var(--primary); }
.anmelde-form { margin-top: .75rem; }
.teilnehmer-grid fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; margin-bottom: .75rem; }
.teilnehmer-grid legend { font-size: .85rem; font-weight: 600; padding: 0 .4rem; color: var(--muted); }
.status-info { font-size: .82rem; color: var(--muted); margin: .5rem 0; }
.gemeinde-list { list-style: none; margin-top: .5rem; font-size: .85rem; }
.gemeinde-list li { padding: .3rem 0; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .5rem; }
.gemeinde-list li:last-child { border-bottom: none; }

/* ── TOTP ─────────────────────────────────────────────────── */
.totp-qr { text-align: center; margin: 1.25rem 0; }
.totp-qr img { border: 1px solid var(--border); border-radius: var(--radius); }
.totp-secret-details { margin: .75rem 0; }
.totp-secret { display: block; background: #f1f5f9; padding: .5rem; border-radius: var(--radius); font-size: .9rem; letter-spacing: .1em; margin-top: .5rem; word-break: break-all; }

/* ── Code-Anzeige ─────────────────────────────────────────── */
.code-display { display: block; font-size: 1.2rem; background: #f1f5f9; padding: .75rem 1rem; border-radius: var(--radius); margin: .5rem 0; letter-spacing: .15em; word-break: break-all; }
.code-small { font-family: monospace; font-size: .8rem; background: #f1f5f9; padding: .15rem .4rem; border-radius: 3px; word-break: break-all; }

/* ── Inline-Edit ──────────────────────────────────────────── */
.inline-edit { display: inline-block; }
.inline-edit summary { list-style: none; }
.inline-edit summary::-webkit-details-marker { display: none; }
.edit-form { position: absolute; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: 0 4px 12px rgba(0,0,0,.1); z-index: 100; display: flex; flex-direction: column; gap: .5rem; min-width: 250px; margin-top: .25rem; }
.actions { white-space: nowrap; display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }

/* ── Kompakte Tabelle ─────────────────────────────────────── */
.table-compact { border-collapse: collapse; font-size: .85rem; }
.table-compact td { padding: .25rem .5rem; border: none; }

/* ── Utility ──────────────────────────────────────────────── */
.mt-2 { margin-top: 1rem; }
h2 { font-size: 1.15rem; font-weight: 700; margin: 1.5rem 0 .75rem; }
details > summary { cursor: pointer; color: var(--primary); font-size: .85rem; }
small { font-size: .8rem; }
