/* ============================================================================
   Price Agent — Admin-Panel Stylesheet
   Dunkle Seitenleiste + heller Content, System-Font-Stack, keine externen
   Ressourcen (offline-fähig).
   ========================================================================== */

/* ---------- Grundlagen ---------- */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #1f2937;
  background: #f3f5f9;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p {
  margin: 0;
}

a {
  color: #2f6bfd;
}

.hidden {
  display: none !important;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.muted {
  color: #64748b;
}

.small {
  font-size: 12.5px;
}

.nowrap {
  white-space: nowrap;
}

.link {
  color: #2f6bfd;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}

.link:hover {
  text-decoration: underline;
}

/* ---------- App-Shell-Layout ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.content {
  flex: 1;
  min-width: 0;           /* erlaubt Tabellen-Overflow statt Layout-Sprengung */
  padding: 28px 32px 48px;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1240px;
}

.view-head h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.view-sub {
  margin-top: 3px;
  color: #64748b;
  font-size: 13.5px;
}

/* ---------- Seitenleiste ---------- */

.sidebar {
  width: 248px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 14px;
  background: #151c2c;
  color: #cbd5e1;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}

.brand-name {
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}

.brand-sub {
  font-size: 11.5px;
  color: #7c8aa5;
  margin-top: 1px;
}

/* Kleiner Klemmbaustein aus reinem CSS (kein externes Bild nötig) */
.logo-mark {
  width: 30px;
  height: 24px;
  flex: none;
  border-radius: 5px;
  background:
    radial-gradient(circle at 10px 7px, #d9a80f 5px, transparent 6px),
    radial-gradient(circle at 20px 7px, #d9a80f 5px, transparent 6px),
    #f5c518;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.14);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-link {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: #b6c2d6;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-link.active {
  background: #2f6bfd;
  color: #fff;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-name {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  padding: 0 8px;
  overflow-wrap: anywhere;
}

.user-role {
  font-size: 11.5px;
  color: #7c8aa5;
  padding: 0 8px;
}

/* ---------- Buttons ---------- */

.btn {
  border: 0;
  border-radius: 8px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.btn:focus-visible {
  outline: 2px solid #2f6bfd;
  outline-offset: 2px;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}

.btn-primary {
  background: #2f6bfd;
  color: #fff;
}

.btn-primary:hover {
  background: #2657d6;
}

.btn-secondary {
  background: #e8ecf3;
  color: #1f2937;
}

.btn-secondary:hover {
  background: #dbe2ec;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
}

.btn-danger:hover {
  background: #bb1d1d;
}

.btn-ghost {
  background: transparent;
  color: #b6c2d6;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.btn-block {
  width: 100%;
}

.btn-small {
  padding: 6px 12px;
  font-size: 12.5px;
}

/* ---------- Karten ---------- */

.card {
  background: #fff;
  border: 1px solid #e5e9f0;
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.card-head h2 {
  font-size: 15.5px;
  font-weight: 700;
}

.card-head .muted {
  margin-top: 2px;
  font-size: 12.5px;
}

.card-narrow {
  max-width: 460px;
}

/* ---------- Status-Karten (Dashboard) ---------- */

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.stat-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7b8794;
}

.stat-value {
  font-size: 19px;
  font-weight: 650;
  color: #111827;
  overflow-wrap: anywhere;
}

.stat-sub {
  font-size: 12.5px;
  color: #64748b;
  line-height: 1.45;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ok-text {
  color: #15803d;
  font-weight: 600;
}

.warn-text {
  color: #b45309;
  font-weight: 600;
}

/* Meta-Leiste (nächste Ausführung, Version, Laufzeit, ...) */

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px 22px;
}

.meta-value {
  font-weight: 600;
  margin-top: 3px;
  font-size: 13.5px;
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.badge-ok      { color: #15803d; background: #dcfce7; }
.badge-err     { color: #b91c1c; background: #fee2e2; }
.badge-warn    { color: #a16207; background: #fef3c7; }
.badge-run     { color: #1d4ed8; background: #dbeafe; }
.badge-neutral { color: #475569; background: #e2e8f0; }

/* ---------- Tabellen ---------- */

.table-scroll {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

.table td {
  padding: 9px 10px;
  border-bottom: 1px solid #eef1f5;
  vertical-align: top;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: #f8fafc;
}

.table-click tbody tr {
  cursor: pointer;
}

.table-click tbody tr.selected {
  background: #eef4ff;
}

.summ {
  color: #4b5563;
  min-width: 160px;
}

.diff-table td.mono {
  white-space: nowrap;
}

.pct {
  font-weight: 700;
  white-space: nowrap;
}

.pct-up   { color: #dc2626; }   /* Preis steigt -> rot */
.pct-down { color: #16a34a; }   /* Preis sinkt -> grün */

.diff-count {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
}

/* ---------- Formulare ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-weight: 600;
  font-size: 13px;
  color: #374151;
}

.help {
  font-size: 12px;
  color: #7b8794;
  line-height: 1.45;
}

input,
select {
  font: inherit;
  color: #1f2937;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}

input:focus,
select:focus {
  outline: none;
  border-color: #2f6bfd;
  box-shadow: 0 0 0 3px rgba(47, 107, 253, 0.15);
}

input:disabled,
select:disabled {
  background: #f1f5f9;
  color: #94a3b8;
}

.form-stack .field + .field {
  margin-top: 14px;
}

.form-stack .btn {
  margin-top: 18px;
}

#target-currency {
  text-transform: uppercase;
}

/* Konfigurations-Formular */

#config-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px 20px;
}

.field-toggle {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.field-toggle-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 2px;
}

.field-toggle.big .switch {
  transform: scale(1.2);
  transform-origin: left center;
}

/* Sicherheitsmodus (dry run) — bewusst auffällig */

.config-section.highlight {
  background: #fffbeb;
  border-color: #f2d488;
}

.warn-note {
  display: block;
  margin-top: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: #92400e;
  line-height: 1.45;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.form-msg {
  font-size: 13px;
  font-weight: 600;
}

.form-msg.ok  { color: #15803d; }
.form-msg.err { color: #b91c1c; }

/* ---------- Umschalter (Toggle) ---------- */

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex: none;
}

.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid #2f6bfd;
  outline-offset: 2px;
}

.switch-track {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  transition: background 0.15s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: left 0.15s ease;
}

.switch input:checked + .switch-track {
  background: #16a34a;
}

.switch input:checked + .switch-track::after {
  left: 23px;
}

.switch input:disabled {
  cursor: default;
}

.switch input:disabled + .switch-track {
  opacity: 0.6;
}

/* ---------- Hinweis-Boxen ---------- */

.alert {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 14px;
}

.alert-error {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.alert-ok {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}

/* ---------- Login ---------- */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(1000px 520px at 20% 0%, #24304a 0%, #101623 58%) #101623;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 14px;
  padding: 34px 30px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  margin-bottom: 22px;
}

.login-logo .logo-mark {
  width: 44px;
  height: 34px;
  border-radius: 7px;
  background:
    radial-gradient(circle at 15px 10px, #d9a80f 7px, transparent 8px),
    radial-gradient(circle at 29px 10px, #d9a80f 7px, transparent 8px),
    #f5c518;
}

.login-logo h1 {
  font-size: 22px;
  letter-spacing: -0.01em;
}

.login-sub {
  color: #64748b;
  font-size: 13px;
}

.login-card .field {
  margin-bottom: 14px;
}

.login-card .btn {
  margin-top: 8px;
}

/* ---------- Schritte ---------- */

.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.step-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.step-head h2 {
  font-size: 15px;
  font-weight: 700;
}

.step-name {
  font-size: 11px;
  color: #8a94a6;
  white-space: nowrap;
  padding-top: 2px;
}

.step-desc {
  flex: 1;
  font-size: 13px;
  line-height: 1.5;
}

.step-card.accent {
  border-color: #a8c4ff;
  background: linear-gradient(180deg, #f5f8ff 0%, #ffffff 70%);
}

.step-card.accent .step-head h2 {
  color: #1d4ed8;
}

.step-chip {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}

.chip-ok  { background: #dcfce7; color: #15803d; }
.chip-err { background: #fee2e2; color: #b91c1c; }

.step-foot {
  display: flex;
  gap: 8px;
}

/* ---------- Lauf-Panel (Live-Ansicht) ---------- */

.run-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.run-panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.run-panel-title h2 {
  font-size: 16px;
  font-weight: 700;
}

.run-panel-actions {
  display: flex;
  gap: 8px;
}

/* ---------- Protokoll (Log) ---------- */

.log {
  background: #0b1220;
  color: #d5dced;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  line-height: 1.6;
  border-radius: 8px;
  padding: 12px 14px;
  max-height: 360px;
  overflow: auto;
}

.log-line {
  display: flex;
  gap: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-ts {
  color: #64748b;
  flex: none;
}

.log-lvl {
  flex: none;
  width: 46px;
  font-weight: 700;
  color: #7dd3fc;
}

.log-warn {
  color: #fcd34d;
}

.log-warn .log-lvl {
  color: #fcd34d;
}

.log-error {
  color: #fca5a5;
}

.log-error .log-lvl {
  color: #fca5a5;
}

.log-empty {
  color: #64748b;
}

.run-summary {
  margin-top: 12px;
}

.run-summary .stat-title {
  display: block;
  margin-bottom: 3px;
}

.run-diff,
.run-diff-slot {
  margin-top: 14px;
}

.kv-grid {
  display: flex;
  gap: 30px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.run-detail .log {
  max-height: 420px;
}

.run-summary-text {
  margin: 6px 0 12px;
  color: #374151;
}

/* ---------- Toasts ---------- */

.toast-host {
  position: fixed;
  top: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  max-width: min(360px, calc(100vw - 36px));
}

.toast {
  background: #111827;
  color: #f9fafb;
  border-left: 4px solid #64748b;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  animation: toast-in 0.18s ease-out;
}

.toast-ok   { border-left-color: #22c55e; }
.toast-err  { border-left-color: #ef4444; }
.toast-warn { border-left-color: #f59e0b; }

.toast.out {
  opacity: 0;
  transform: translateX(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: auto;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
  }

  .nav-link {
    padding: 7px 11px;
    font-size: 13.5px;
  }

  .sidebar-footer {
    border-top: 0;
    padding-top: 0;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    margin-left: auto;
  }

  .user-box {
    text-align: right;
  }

  .user-name,
  .user-role {
    padding: 0;
  }

  .content {
    padding: 18px 16px 40px;
  }
}
