/* ── Tanzfieber Design System ──────────────────────────────────────────────── */

/* ── CSS Variablen (Tokens) ─────────────────────────────────────────────── */
:root {
  --brand:          #be1558;
  --brand-hover:    #d4186a;
  --brand-muted:    rgba(190, 21, 88, 0.15);
  --brand-border:   rgba(190, 21, 88, 0.4);

  /* Light Mode (Standard) */
  --bg:             #f0f0f4;
  --surface:        #ffffff;
  --surface-2:      #f7f7fa;
  --border:         #e2e2e8;
  --border-2:       #d0d0d8;
  --text-1:         #111116;
  --text-2:         #55555f;
  --text-3:         #909099;
  --nav-bg:         #ffffff;
  --nav-border:     #e2e2e8;
  --input-bg:       #f7f7fa;
  --shadow:         0 1px 4px rgba(0,0,0,0.08);
  --shadow-md:      0 4px 16px rgba(0,0,0,0.10);
}

[data-theme="dark"] {
  --bg:             #0c0c0f;
  --surface:        #18181d;
  --surface-2:      #212128;
  --border:         #2c2c38;
  --border-2:       #3a3a48;
  --text-1:         #f0f0f4;
  --text-2:         #9090a0;
  --text-3:         #606070;
  --nav-bg:         #111116;
  --nav-border:     #2c2c38;
  --input-bg:       #212128;
  --shadow:         0 1px 4px rgba(0,0,0,0.4);
  --shadow-md:      0 4px 16px rgba(0,0,0,0.5);
}

/* ── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text-1);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

html { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

/* ── Navigation Desktop ─────────────────────────────────────────────────── */
.nav-bar {
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow);
}

.nav-inner {
  max-width: 80rem;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  gap: 0.5rem;
}

@media (max-width: 767px) {
  .nav-inner { height: 52px; padding: 0 1rem; }
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-1);
}

.nav-brand span { color: var(--brand); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-link {
  padding: 6px 11px;
  border-radius: 9px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.nav-link:hover { background: var(--surface-2); color: var(--text-1); }
.nav-link.active { background: var(--brand-muted); color: var(--brand); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-size: 1.1rem;
}

.theme-btn:hover { background: var(--surface); color: var(--text-1); }

.nav-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.nav-icon-btn:hover { background: var(--surface-2); color: var(--text-1); }
.nav-icon-btn.active { color: var(--brand); background: var(--brand-muted); }

.nav-profile-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 8px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}

.nav-profile-chip:hover {
  background: var(--surface);
  border-color: var(--brand-border);
  color: var(--text-1);
}

.nav-profile-chip.active {
  background: var(--brand-muted);
  border-color: var(--brand-border);
  color: var(--brand);
}

/* Auf Mobile: nur Icon, kein Text */
@media (max-width: 767px) {
  .nav-profile-chip {
    padding: 6px 8px;
    border-radius: 10px;
  }
}

/* ── Mobile Bottom Nav ──────────────────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--nav-bg);
  border-top: 1px solid var(--nav-border);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
}

.bottom-nav-inner {
  display: flex;
  align-items: stretch;
  height: 68px;
  width: 100%;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-3);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  transition: color 0.15s;
  cursor: pointer;
  padding: 8px 2px 6px;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item svg { width: 23px; height: 23px; }

.bottom-nav-item:hover { color: var(--brand); }

.bottom-nav-item.active {
  color: var(--brand);
}

/* Aktiver Indikator-Strich oben */
.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 3px;
  background: var(--brand);
  border-radius: 0 0 3px 3px;
}

@media (max-width: 767px) {
  .bottom-nav { display: flex; }
  .desktop-nav-links { display: none !important; }
}

@media (min-width: 768px) {
  .bottom-nav { display: none !important; }
}

/* ── Main Layout ────────────────────────────────────────────────────────── */
main {
  max-width: 56rem;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

@media (max-width: 767px) {
  /* padding-bottom muss nach dem Bottom-Nav (68px) + Safe Area kommen */
  main { padding: 1.25rem 0.875rem calc(88px + env(safe-area-inset-bottom)); }
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
}

.card-link {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem 1.25rem;
  display: block;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.card-link:hover {
  border-color: var(--brand-border);
  box-shadow: 0 4px 16px rgba(190,21,88,0.1);
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  padding: 0.65rem 1.35rem;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  min-height: 46px;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary:hover { background: var(--brand-hover); }
.btn-primary:active { transform: scale(0.97); }

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  color: var(--text-2);
  font-weight: 500;
  font-size: 1rem;
  padding: 0.65rem 1.35rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 46px;
  -webkit-tap-highlight-color: transparent;
}

.btn-outline:hover { background: var(--surface-2); color: var(--text-1); }

.btn-danger {
  background: transparent;
  color: #ef4444;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.15s;
  min-height: 36px;
  -webkit-tap-highlight-color: transparent;
}

.btn-danger:hover { background: rgba(239,68,68,0.1); }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  color: var(--text-1);
  font-size: 16px; /* verhindert iOS-Zoom */
  line-height: 1.4;
  transition: border-color 0.15s;
  outline: none;
  min-height: 50px;
}

.input:focus { border-color: var(--brand); }
.input::placeholder { color: var(--text-3); }

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23909099'%3E%3Cpath d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  background-size: 1.1rem;
  padding-right: 2.75rem;
  cursor: pointer;
}

textarea.input { min-height: auto; }

/* ── Text Utilities ─────────────────────────────────────────────────────── */
.text-muted { color: var(--text-2); }
.text-faint { color: var(--text-3); }
.text-brand { color: var(--brand); }

/* ── RSVP Buttons ───────────────────────────────────────────────────────── */
.rsvp-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.rsvp-btn:hover { border-color: var(--border-2); color: var(--text-1); }
.rsvp-btn.active-green { background: rgba(34,197,94,0.15); border-color: rgba(34,197,94,0.4); color: #22c55e; }
.rsvp-btn.active-yellow { background: rgba(234,179,8,0.15); border-color: rgba(234,179,8,0.4); color: #eab308; }
.rsvp-btn.active-red { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.4); color: #ef4444; }

.rsvp-btn-lg {
  flex: 1;
  padding: 0.75rem 0.5rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  min-height: 50px;
  -webkit-tap-highlight-color: transparent;
}

.rsvp-btn-lg:hover { background: var(--surface); color: var(--text-1); }
.rsvp-btn-lg.active-green { background: rgba(34,197,94,0.12); border-color: rgba(34,197,94,0.4); color: #22c55e; }
.rsvp-btn-lg.active-yellow { background: rgba(234,179,8,0.12); border-color: rgba(234,179,8,0.4); color: #eab308; }
.rsvp-btn-lg.active-red { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.4); color: #ef4444; }

/* ── Status Badges ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 99px;
}

.badge-green { background: rgba(34,197,94,0.12); color: #22c55e; }
.badge-red   { background: rgba(239,68,68,0.12);  color: #ef4444; }
.badge-yellow{ background: rgba(234,179,8,0.12);  color: #eab308; }
.badge-gray  { background: var(--surface-2); color: var(--text-3); }
.badge-brand { background: var(--brand-muted); color: var(--brand); }

/* ── Alert Boxes ────────────────────────────────────────────────────────── */
.alert-error {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.3);
  color: #ef4444;
  border-radius: 12px;
  padding: 0.875rem 1.1rem;
  font-size: 0.95rem;
}

.alert-success {
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.3);
  color: #22c55e;
  border-radius: 12px;
  padding: 0.875rem 1.1rem;
  font-size: 0.95rem;
}

/* ── Section Header ─────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.875rem;
}

.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}

/* ── Page Header ────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-1);
  line-height: 1.2;
}

@media (max-width: 767px) {
  .page-title { font-size: 1.5rem; }
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-2, rgba(0,0,0,0.05));
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 0.25rem 0.75rem 0.25rem 0.5rem;
  text-decoration: none;
  margin-bottom: 0.75rem;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.back-link::before {
  content: '';
  display: block;
  width: 7px;
  height: 7px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  flex-shrink: 0;
}

.back-link:hover {
  color: var(--brand);
  border-color: var(--brand-border, var(--brand));
  background: var(--brand-muted, rgba(190,21,88,0.06));
}

/* ── Divider ────────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 1.5rem 0;
}

/* ── Member Chip ────────────────────────────────────────────────────────── */
.member-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
  font-size: 0.925rem;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.member-chip:hover { border-color: var(--border-2); }
.member-chip.selected { border-color: var(--brand); background: var(--brand-muted); }
.member-chip.placed { opacity: 0.35; cursor: not-allowed; }

/* ── Formations Stage ───────────────────────────────────────────────────── */
.stage-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Vorne / Hinten Labels */
.stage-direction {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-align: center;
  padding: 7px 12px;
  border-radius: 10px;
  min-width: 480px;
}

.stage-hinten {
  background: #1e293b;
  color: #94a3b8;
  border-radius: 12px 12px 0 0;
}

[data-theme="light"] .stage-hinten {
  background: #334155;
  color: #cbd5e1;
}

.stage-vorne {
  background: var(--brand);
  color: rgba(255,255,255,0.92);
  border-radius: 0 0 12px 12px;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: 4px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 8px;
  user-select: none;
  min-width: 480px;
}

.stage-cell {
  aspect-ratio: 1;
  min-width: 40px;
  min-height: 40px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.1s, background 0.1s;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.stage-cell.droppable { cursor: pointer; }
.stage-cell.droppable:hover { border-color: var(--brand); background: var(--brand-muted); }
.stage-cell.occupied { background: var(--brand-muted); border-color: var(--brand-border); cursor: pointer; }
.stage-cell.occupied:hover { background: rgba(190,21,88,0.25); }

.dancer-label {
  font-size: 9px;
  color: var(--brand);
  font-weight: 700;
  text-align: center;
  line-height: 1.15;
  padding: 2px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.75rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}

@media (max-width: 767px) {
  .modal {
    border-radius: 20px 20px 16px 16px;
    padding: 1.5rem;
  }
}

/* ── Auth Pages ─────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 2.25rem;
  box-shadow: var(--shadow-md);
}

/* ── Invite Link Box ────────────────────────────────────────────────────── */
.invite-box {
  background: var(--brand-muted);
  border: 1px solid var(--brand-border);
  border-radius: 14px;
  padding: 1.1rem;
}

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

/* ── List Card Row (responsive member/item rows) ────────────────────────── */
.list-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.list-card-row-info {
  flex: 1;
  min-width: 0;
}

.list-card-row-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

@media (max-width: 480px) {
  .list-card-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .list-card-row-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

/* ── Formation Save Bar ─────────────────────────────────────────────────── */
.formation-save-bar {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  align-items: center;
}

/* ── Mobile Overrides ───────────────────────────────────────────────────── */
@media (max-width: 767px) {
  /* Tighter cards save vertical space */
  .card        { padding: 0.875rem 1rem; border-radius: 14px; }
  .card-link   { padding: 0.875rem 1rem; border-radius: 14px; }

  /* Bigger tap target for back navigation */
  .back-link { padding: 0.3rem 0.75rem 0.3rem 0.5rem; }

  /* Meet Apple HIG 44pt minimum */
  .rsvp-btn { width: 44px; height: 44px; }

  /* Modals slide up from bottom */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal {
    border-radius: 24px 24px 0 0;
    max-width: 100%;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  }
}
