/* DE-Domain-Monitor: mobile-first, ohne externe Abhängigkeiten. */

:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1c2433;
  --muted: #5f6b7d;
  --border: #dde3ec;
  --accent: #1d4ed8;
  --accent-text: #ffffff;
  --ok: #15803d;        --ok-bg: #dcfce7;
  --warn: #b45309;      --warn-bg: #fef3c7;
  --err: #b91c1c;       --err-bg: #fee2e2;
  --info: #1e40af;      --info-bg: #dbeafe;
  --gray: #475569;      --gray-bg: #e2e8f0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 2px 8px rgba(15, 23, 42, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1420;
    --card: #182030;
    --text: #e6ebf3;
    --muted: #97a3b6;
    --border: #2a3548;
    --accent: #3b82f6;
    --accent-text: #ffffff;
    --ok: #4ade80;        --ok-bg: #123524;
    --warn: #fbbf24;      --warn-bg: #3b2a10;
    --err: #f87171;       --err-bg: #3d1717;
    --info: #93c5fd;      --info-bg: #15264a;
    --gray: #cbd5e1;      --gray-bg: #293447;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1420;
  --card: #182030;
  --text: #e6ebf3;
  --muted: #97a3b6;
  --border: #2a3548;
  --accent: #3b82f6;
  --ok: #4ade80;        --ok-bg: #123524;
  --warn: #fbbf24;      --warn-bg: #3b2a10;
  --err: #f87171;       --err-bg: #3d1717;
  --info: #93c5fd;      --info-bg: #15264a;
  --gray: #cbd5e1;      --gray-bg: #293447;
  --shadow: none;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}

h1 { font-size: 1.5rem; margin: 0.5rem 0 1rem; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
h3 { font-size: 0.95rem; margin: 1rem 0 0.25rem; color: var(--muted); }
p { margin: 0.5rem 0; }
a { color: var(--accent); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9rem; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.err-text { color: var(--err); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- Kopfzeile und Navigation (mobil unten, Desktop oben) --- */

.topbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.brand { display: none; }
.nav { display: flex; width: 100%; }
.nav a {
  flex: 1;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0 4px;
}
.nav a.active, .nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 16px 96px;  /* Platz für die untere Leiste */
}

/* --- Karten, Raster, Kennzahlen --- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin: 12px 0;
}
.grid-2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
.stats { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); margin: 12px 0; }
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 0.85rem; color: var(--muted); }
.stat-ok .stat-value { color: var(--ok); }
.stat-warn .stat-value { color: var(--warn); }
.stat-muted .stat-value { color: var(--gray); }

.banner {
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 12px 0;
  border: 1px solid transparent;
}
.banner-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.banner-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }

.kv { display: grid; grid-template-columns: 1fr; gap: 2px 12px; margin: 0 0 12px; }
.kv dt { color: var(--muted); font-size: 0.85rem; margin-top: 8px; }
.kv dd { margin: 0; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: middle; background: var(--gray); }
.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-err { background: var(--err); }

/* --- Statuspillen --- */

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--gray-bg);
  color: var(--gray);
}
.pill-verfuegbar { background: var(--ok-bg); color: var(--ok); }
.pill-registriert { background: var(--gray-bg); color: var(--gray); }
.pill-pruefungsfehler { background: var(--warn-bg); color: var(--warn); }
.pill-pruefung_laeuft { background: var(--info-bg); color: var(--info); }
.pill-registrierung_laeuft { background: var(--info-bg); color: var(--info); }
.pill-erfolgreich_registriert { background: var(--ok-bg); color: var(--ok); }
.pill-registrierung_fehlgeschlagen { background: var(--err-bg); color: var(--err); }
.pill-unbekannt { background: var(--gray-bg); color: var(--muted); }

/* --- Domain-Karten (Smartphone) und Tabelle (Desktop) --- */

.cards { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; }
.cards .card { margin: 0; }
.domain-card { padding: 14px; }
.domain-link { display: flex; justify-content: space-between; align-items: center; gap: 8px; text-decoration: none; color: var(--text); min-height: 44px; }
.domain-name { font-size: 1.15rem; font-weight: 700; }
.meta { font-size: 0.85rem; color: var(--muted); }
.table-wrap { display: none; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 0.8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 4px; }
.chip {
  flex: 0 0 auto;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
}
.chip-on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.history-row { display: flex; flex-direction: column; padding: 8px 0; border-bottom: 1px solid var(--border); }
.history-row:last-child { border-bottom: 0; }
.breadcrumb { font-size: 0.9rem; color: var(--muted); margin: 4px 0 0; }
.domain-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.link-list { padding-left: 1.1rem; }
.actions { display: grid; gap: 8px; margin-top: 12px; }
.inline-form { margin-top: 8px; }
.danger-card { border-color: var(--err); }

/* --- Formulare und Schaltflächen --- */

form.stack { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: 0.92rem; color: var(--muted); }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;  /* verhindert Zoom bei iOS */
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}
input:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.add-form summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.add-form form { margin-top: 12px; }

.btn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--err); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--err); border-color: var(--err); }

.flash {
  padding: 12px 14px;
  border-radius: 10px;
  margin: 8px 0;
  border: 1px solid transparent;
}
.flash-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.flash-info { background: var(--info-bg); color: var(--info); border-color: var(--info); }
.flash-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.flash-err { background: var(--err-bg); color: var(--err); border-color: var(--err); }

.auth { max-width: 420px; margin: 24px auto; }
.auth h1 { margin-top: 0; }

/* --- Breitere Bildschirme --- */

@media (min-width: 640px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: 180px 1fr; }
}

@media (min-width: 800px) {
  body { overflow-x: visible; }
  .topbar {
    position: sticky;
    top: 0;
    bottom: auto;
    padding: 0 20px;
    align-items: center;
    gap: 24px;
    border-top: 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
  }
  .brand { display: inline; font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
  .nav { width: auto; }
  .nav a { flex: 0 0 auto; min-height: 56px; padding: 0 12px; font-size: 0.95rem; }
  .nav a.active, .nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--accent); }
  .container { padding-bottom: 24px; }
  .cards { display: none; }
  .table-wrap { display: block; }
  .domain-card { display: none; }
  .actions { grid-template-columns: repeat(3, auto); justify-content: start; }
  .actions .btn, .actions form { width: auto; }
  .actions .btn-block { width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
