/* Wiederverwendbare UI-Bausteine: Karten, Buttons, Badges, Formulare, Navigation. */

/* ── Karten ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--sp-5);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: var(--sp-4); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border);
}
.card-title    { font-size: 0.9rem; font-weight: 700; }
.card-subtitle { font-size: var(--text-sm); color: var(--text-2); margin-top: 2px; }

/* ── Statistik-Karten ────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--sp-5);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.stat-label {
  font-size: var(--text-xs);
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
}
.stat-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 9px var(--sp-4);
  border-radius: var(--r-sm);
  border: none;
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  transition: background var(--dur-fast), box-shadow var(--dur-fast),
              transform var(--dur-fast), color var(--dur-fast);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn-sm  { padding: 6px 11px; font-size: var(--text-sm); }
.btn-lg  { padding: 13px var(--sp-6); font-size: var(--text-lg); border-radius: var(--r); }
.btn-block { width: 100%; }

.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: var(--shadow-glow);
}
.btn-primary:hover { background: var(--grad-hover); box-shadow: 0 4px 20px rgba(124,58,237,0.36); }

.btn-ghost {
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-3); }

.btn-soft { background: var(--surface-2); color: var(--accent); }
.btn-soft:hover { background: var(--surface-3); }

.btn-danger  { background: var(--red-bg);   color: var(--red);   border: 1px solid rgba(220,38,38,0.2); }
.btn-danger:hover  { background: rgba(220,38,38,0.17); }
.btn-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(5,150,105,0.2); }
.btn-success:hover { background: rgba(5,150,105,0.18); }

.btn-icon { width: 21px; height: 21px; stroke: currentColor; fill: none;
            stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.btn-icon-sm { width: 16px; height: 16px; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-active, .badge-done, .badge-published { background: var(--green-bg);  color: var(--green); }
.badge-paused, .badge-queued               { background: var(--yellow-bg); color: var(--yellow); }
.badge-pending                             { background: var(--surface-2); color: var(--accent); }
.badge-review, .badge-processing           { background: var(--orange-bg); color: var(--orange); }
.badge-failed, .badge-disconnected         { background: var(--red-bg);    color: var(--red); }

.badge-instagram { background: rgba(225,48,108,0.1); color: #be185d; }
.badge-facebook  { background: rgba(59,89,152,0.1);  color: #1d4ed8; }
.badge-tiktok    { background: rgba(0,0,0,0.07);     color: #374151; }
.badge-youtube   { background: rgba(220,38,38,0.1);  color: #b91c1c; }
.badge-pinterest { background: rgba(230,0,35,0.1);   color: #b91c1c; }
.badge-linkedin  { background: rgba(10,102,194,0.1); color: #1d4ed8; }
.badge-google    { background: rgba(66,133,244,0.1); color: #1d4ed8; }

/* ── Listenzeilen ────────────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: var(--sp-3); }
.list-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--sp-4);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.list-row:hover { border-color: var(--border-3); box-shadow: var(--shadow); }
.list-avatar {
  width: 38px; height: 38px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
}
.list-avatar svg { width: 19px; height: 19px; stroke: currentColor; fill: none;
                   stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.list-title { font-size: var(--text-md); font-weight: 600; }
.list-sub   { font-size: var(--text-sm); color: var(--text-2); margin-top: 1px; }

/* ── Formulare ───────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.form-group > label { font-size: var(--text-sm); color: var(--text-2); font-weight: 600; }
.form-hint  { font-size: var(--text-xs); color: var(--text-3); }

.input, .form-group input:not([type=checkbox]):not([type=radio]):not([type=color]),
.form-group textarea, .form-group select {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  padding: 10px var(--sp-3);
  font-size: var(--text-md);
  width: 100%;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.input:focus, .form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-group textarea { resize: vertical; min-height: 84px; line-height: 1.55; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

/* ── Schalter ────────────────────────────────────────────── */
.toggle {
  width: 42px; height: 24px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  position: relative;
  transition: background var(--dur);
  flex-shrink: 0;
  border: none;
  padding: 0;
}
.toggle::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: var(--r-full);
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform var(--dur) var(--ease);
}
.toggle.on { background: var(--grad); }
.toggle.on::after { transform: translateX(18px); }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row h4 { font-size: var(--text-md); font-weight: 600; }
.toggle-row p  { font-size: var(--text-sm); color: var(--text-2); margin-top: 2px; }

/* ── Navigation ──────────────────────────────────────────── */
.nav-tabs { display: flex; gap: 2px; margin-left: auto; }
.nav-tab {
  padding: 7px var(--sp-4);
  border-radius: var(--r-sm);
  border: none;
  background: none;
  color: var(--text-2);
  font-size: var(--text-md);
  font-weight: 500;
  transition: color var(--dur-fast), background var(--dur-fast);
}
.nav-tab:hover  { color: var(--text); background: var(--surface-2); }
.nav-tab.active { color: var(--accent); background: var(--surface-2); font-weight: 700; }

.sub-tabs {
  display: flex;
  gap: var(--sp-1);
  margin-bottom: var(--sp-5);
  overflow-x: auto;
  scrollbar-width: none;
}
.sub-tabs::-webkit-scrollbar { display: none; }
.sub-tab {
  padding: 7px var(--sp-4);
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: none;
  color: var(--text-2);
  font-size: 0.84rem;
  font-weight: 500;
  flex-shrink: 0;
  transition: all var(--dur-fast);
}
.sub-tab:hover  { color: var(--text); background: var(--surface-2); }
.sub-tab.active { color: var(--accent); background: var(--surface-2);
                  border-color: var(--border-2); font-weight: 700; }

/* Mobile Bottom-Navigation */
.bottom-nav { display: none; }
@media (max-width: 780px) {
  .nav-tabs { display: none; }
  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 200;
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 16px rgba(124,58,237,0.08);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .bnav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 9px 2px 10px;
    border: none;
    background: none;
    color: var(--text-2);
    font-family: inherit;
    font-size: 0.66rem;
    font-weight: 600;
    position: relative;
    transition: color var(--dur-fast);
  }
  .bnav-btn svg {
    width: 21px; height: 21px;
    stroke: currentColor; fill: none;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  }
  .bnav-btn.active { color: var(--accent); }
  .bnav-btn.active::before {
    content: '';
    position: absolute; top: 0; left: 24%; right: 24%;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--grad);
  }
}

/* ── Zustände: leer, laden ───────────────────────────────── */
.empty {
  text-align: center;
  padding: var(--sp-8) var(--sp-6);
  color: var(--text-2);
  font-size: var(--text-md);
}
.empty svg {
  width: 40px; height: 40px;
  margin: 0 auto var(--sp-3);
  stroke: var(--text-3); fill: none;
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}

.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border-2);
  border-top-color: var(--accent);
  border-radius: var(--r-full);
  animation: spin 0.7s linear infinite;
}
.spinner-lg { width: 28px; height: 28px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Ladeplatzhalter — verhindert Layout-Sprünge (CLS). */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Toast ───────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: var(--sp-6);
  left: 50%;
  transform: translateX(-50%) translateY(90px);
  background: #fff;
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-lg);
  padding: 11px var(--sp-5);
  border-radius: var(--r-sm);
  font-size: var(--text-md);
  font-weight: 600;
  transition: transform var(--dur) var(--ease), opacity var(--dur);
  opacity: 0;
  z-index: 999;
  max-width: calc(100vw - 32px);
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.ok  { border-color: rgba(5,150,105,0.35); color: var(--green); }
#toast.err { border-color: rgba(220,38,38,0.35); color: var(--red); }
@media (max-width: 780px) { #toast { bottom: calc(var(--bottomnav-h) + 16px); } }

/* ── Mobile Anpassungen ──────────────────────────────────── */
@media (max-width: 780px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--sp-3); }
  .stat-card { padding: var(--sp-4); }
  .stat-value { font-size: 1.6rem; }
  .stat-label { font-size: 0.66rem; letter-spacing: 0.04em; }
  .card { padding: var(--sp-4); }
  .list-row { padding: var(--sp-3) var(--sp-4); gap: var(--sp-3); }
}

/* ── Funnel: Trigger-Wörter und DM-Vorschau ──────────────── */
.trigger-list {
  display: flex; flex-wrap: wrap; gap: var(--sp-2);
  min-height: 26px; align-items: center;
}
.trigger-chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  padding: 4px 6px 4px 11px;
  font-size: var(--text-sm);
  font-weight: 500;
}
.trigger-del {
  border: none; background: none; color: var(--text-3);
  font-size: 1.05rem; line-height: 1; padding: 0 3px;
  transition: color var(--dur-fast);
}
.trigger-del:hover { color: var(--red); }

.dm-preview {
  font-size: var(--text-sm);
  color: var(--text-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2);
  border-radius: var(--r-sm);
  border-left: 3px solid var(--border-3);
  line-height: 1.55;
}

/* ── Platzhalter für Bereiche in Portierung ──────────────── */
.pending-card { text-align: left; }
.pending-badge {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  background: var(--grad-soft);
  color: var(--accent);
  border-radius: var(--r-full);
  padding: 5px var(--sp-3);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pending-title {
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: var(--sp-3) 0 var(--sp-2);
}
.pending-text { color: var(--text-2); font-size: var(--text-md); max-width: 60ch; }
.pending-list { list-style: none; display: flex; flex-direction: column; gap: var(--sp-2); }
.pending-list li {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  font-size: var(--text-md);
  color: var(--text-2);
}
.pending-list li svg { color: var(--green); flex-shrink: 0; margin-top: 3px; }
