/*
 * Handgeschriebenes CSS fuer alle PHP-gerenderten Seiten (oeffentliche /domains/-Seite
 * und das komplette /admin/-Backend). Nutzt bewusst dieselben CSS-Variablen-Werte wie
 * web/src/styles/global.css (Astro/Tailwind), damit beide Welten visuell zusammenpassen -
 * kann aber nicht von dort importiert werden, weil Astros kompilierte CSS-Datei einen
 * bei jedem Build wechselnden Hash-Dateinamen hat. Bei Design-Aenderungen an den
 * Farb-Tokens in global.css bitte hier mitziehen.
 */

:root {
  color-scheme: light;
  --bg: #f8fafc;
  --bg-elevated: #ffffff;
  --bg-muted: #eef2f7;
  --text: #0f172a;
  --text-muted: #47536b;
  --border: #e2e8f0;
  --accent: #d97e06;
  --accent-contrast: #1a1206;
  --focus-ring: #f59e0b;
  --ok: #16a34a;
  --fail: #dc2626;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120;
  --bg-elevated: #131c30;
  --bg-muted: #1a2438;
  --text: #eef2f8;
  --text-muted: #9aa7bd;
  --border: #263248;
  --accent: #fbb524;
  --accent-contrast: #1a1206;
  --focus-ring: #fbb524;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1120;
    --bg-elevated: #131c30;
    --bg-muted: #1a2438;
    --text: #eef2f8;
    --text-muted: #9aa7bd;
    --border: #263248;
    --accent: #fbb524;
    --accent-contrast: #1a1206;
    --focus-ring: #fbb524;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; }
img { max-width: 100%; }
.container { max-width: 64rem; margin: 0 auto; padding: 0 1rem; }
.container-narrow { max-width: 40rem; margin: 0 auto; padding: 0 1rem; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
}
.site-header-inner {
  max-width: 64rem;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.site-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.125rem;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}
.site-logo img { border-radius: 0.25rem; }
.site-logo .accent { color: var(--accent); }
.site-logo .muted { opacity: 0.6; font-weight: 400; }
.site-nav { display: flex; align-items: center; gap: 0.25rem; margin-left: 0.5rem; flex-wrap: wrap; overflow-x: auto; }
.site-nav a {
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  color: var(--text-muted);
}
.site-nav a:hover, .site-nav a.active { color: var(--text); background: var(--bg-muted); }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.icon-btn {
  padding: 0.5rem;
  border-radius: 0.5rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.icon-btn:hover { color: var(--text); background: var(--bg-muted); }
.nav-toggle-btn { display: none; }

.mobile-nav {
  display: none;
  flex-direction: column;
  border-top: 1px solid var(--border);
  padding: 0.5rem 1rem;
}
.mobile-nav.open { display: flex; }
.mobile-nav a {
  padding: 0.6rem 0.5rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--text-muted);
}
.mobile-nav a.active { color: var(--accent); }

@media (max-width: 640px) {
  .site-nav { display: none; }
  .nav-toggle-btn { display: inline-flex; }
}

.hidden { display: none !important; }

.site-footer { border-top: 1px solid var(--border); margin-top: 4rem; }
.site-footer-inner {
  max-width: 64rem;
  margin: 0 auto;
  padding: 2rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 0 1rem; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--text); }

main { flex: 1; width: 100%; }

h1, h2, h3 { line-height: 1.3; }
.page-title { font-size: 1.5rem; font-weight: 800; margin: 0 0 0.75rem; }
.page-lead { color: var(--text-muted); margin: 0 0 2rem; }

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 1.25rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.badge-ok { color: var(--ok); border-color: color-mix(in oklab, var(--ok) 40%, var(--border)); }
.badge-fail { color: var(--fail); border-color: color-mix(in oklab, var(--fail) 40%, var(--border)); }
.badge-unknown { color: var(--text-muted); }

.chip {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--text);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: 0.6rem;
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--fail); border-color: color-mix(in oklab, var(--fail) 40%, var(--border)); }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }

.form-field { margin-bottom: 1rem; }
.form-field label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; }
.form-field input[type="text"],
.form-field input[type="url"],
.form-field input[type="password"],
.form-field input[type="search"],
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
}
.form-field textarea { min-height: 5rem; }
.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.25rem; }
.checkbox-field { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 0.9rem; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data-table th, table.data-table td {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data-table th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: var(--bg-muted); }

.flash { border-radius: 0.7rem; border: 1px solid var(--border); padding: 0.75rem 1rem; margin-bottom: 1.5rem; font-size: 0.9rem; }
.flash-ok { border-color: color-mix(in oklab, var(--ok) 40%, var(--border)); background: color-mix(in oklab, var(--ok) 10%, transparent); }
.flash-error { border-color: color-mix(in oklab, var(--fail) 40%, var(--border)); background: color-mix(in oklab, var(--fail) 10%, transparent); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.75rem; margin-bottom: 2rem; }
.stat-tile { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 0.9rem; padding: 1rem; }
.stat-tile .value { font-size: 1.6rem; font-weight: 800; }
.stat-tile .label { font-size: 0.8rem; color: var(--text-muted); }

.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 1.25rem; }
.toolbar .spacer { flex: 1; }

.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 14rem;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
}
.admin-sidebar nav a {
  display: block;
  padding: 0.5rem 0.6rem;
  border-radius: 0.5rem;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.15rem;
}
.admin-sidebar nav a:hover, .admin-sidebar nav a.active { color: var(--text); background: var(--bg-muted); }
.admin-main { flex: 1; padding: 1.5rem 2rem; min-width: 0; }

@media (max-width: 720px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .admin-main { padding: 1.25rem 1rem; }
}
