/* =====================================================================
   VATEC Newsletter - Gestaltungsgrundlage.

   Farbwelt und Maße orientieren sich am Vuexy-Erscheinungsbild
   (violette Primärfarbe, helle Arbeitsfläche, weiße Karten mit weichem
   Schatten, 6 px Radius). Umgesetzt ist das hier eigenständig - es sind
   keine Dateien aus der kommerziellen Vorlage übernommen.

   Drei Zustände beim Umschalten:
     - kein data-theme   -> folgt dem Betriebssystem
     - data-theme="light" -> fest hell
     - data-theme="dark"  -> fest dunkel
   assets/js/theme.js setzt das Attribut vor dem ersten Bildaufbau.
   ===================================================================== */

/* --- Schrift (lokal, eine variable Datei je Zeichenbereich) ------------- */
@font-face {
  font-family: "Public Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/public-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
                 U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
                 U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Public Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/public-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
                 U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
                 U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
                 U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light;

  /* Flächen */
  --bg:            #f8f7fa;
  --bg-accent:     #f1f0f4;
  --surface:       #ffffff;
  --surface-2:     #f5f4f7;
  --surface-3:     #eeedf0;
  --border:        #e6e6e8;
  --border-strong: #d1d0d6;

  /* Text */
  --text:          #444050;   /* Überschriften */
  --text-body:     #6d6b77;   /* Fließtext */
  --text-muted:    #6d6b77;
  --text-faint:    #a5a3ae;

  /* Primärfarbe */
  --accent:        #7367f0;
  --accent-hover:  #6254e6;
  --accent-ink:    #ffffff;
  --accent-soft:   #7367f01f;
  --accent-border: #7367f047;
  --accent-grad:   linear-gradient(270deg, #7367f0b3 0%, #7367f0 100%);
  --accent-shadow: 0 2px 6px 0 #7367f04d;

  /* Zustände */
  --ok:            #28c76f;
  --ok-soft:       #28c76f1f;
  --ok-border:     #28c76f3d;
  --warn:          #ff9f43;
  --warn-soft:     #ff9f431f;
  --warn-border:   #ff9f433d;
  --err:           #ff4c51;
  --err-soft:      #ff4c511f;
  --err-border:    #ff4c513d;
  --info:          #00bad1;
  --info-soft:     #00bad11f;

  --ring:          #7367f040;
  --shadow-sm:     0 2px 4px 0 rgba(47, 43, 61, .10);
  --shadow-md:     0 3px 12px 0 rgba(47, 43, 61, .14);
  --shadow-lg:     0 8px 28px 0 rgba(47, 43, 61, .22);
  --shadow-menu:   0 2px 8px 0 rgba(47, 43, 61, .12);

  --radius-sm: 4px;
  --radius:    6px;
  --radius-lg: 8px;

  --font-sans:    "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
                  Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: var(--font-sans);
  --font-mono:    ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas, monospace;

  --display-xl: 1.875rem;
  --display-lg: 1.5rem;
  --display-md: 1.375rem;
  --display-sm: 1.125rem;

  --tracking-display: -.01em;
  --tracking-tight:   0;
  --tracking-wide:    .2px;

  --sidebar-w:  260px;
  --sidebar-sm: 78px;
}

/* Dunkel per Systemeinstellung … */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg:            #25293c;
    --bg-accent:     #2b2f45;
    --surface:       #2f3349;
    --surface-2:     #363b53;
    --surface-3:     #3d4260;
    --border:        #44485e;
    --border-strong: #55596e;

    --text:          #cfcde4;
    --text-body:     #acabc1;
    --text-muted:    #acabc1;
    --text-faint:    #7f7e95;

    --accent-soft:   #7367f029;
    --accent-border: #7367f052;

    --ok-soft:       #28c76f29;
    --warn-soft:     #ff9f4329;
    --err-soft:      #ff4c5129;
    --info-soft:     #00bad129;

    --shadow-sm:     0 2px 4px 0 rgba(19, 17, 32, .18);
    --shadow-md:     0 3px 12px 0 rgba(19, 17, 32, .28);
    --shadow-lg:     0 8px 28px 0 rgba(19, 17, 32, .45);
    --shadow-menu:   0 2px 8px 0 rgba(19, 17, 32, .22);
  }
}

/* … oder fest gewählt. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg:            #25293c;
  --bg-accent:     #2b2f45;
  --surface:       #2f3349;
  --surface-2:     #363b53;
  --surface-3:     #3d4260;
  --border:        #44485e;
  --border-strong: #55596e;

  --text:          #cfcde4;
  --text-body:     #acabc1;
  --text-muted:    #acabc1;
  --text-faint:    #7f7e95;

  --accent-soft:   #7367f029;
  --accent-border: #7367f052;

  --ok-soft:       #28c76f29;
  --warn-soft:     #ff9f4329;
  --err-soft:      #ff4c5129;
  --info-soft:     #00bad129;

  --shadow-sm:     0 2px 4px 0 rgba(19, 17, 32, .18);
  --shadow-md:     0 3px 12px 0 rgba(19, 17, 32, .28);
  --shadow-lg:     0 8px 28px 0 rgba(19, 17, 32, .45);
  --shadow-menu:   0 2px 8px 0 rgba(19, 17, 32, .22);
}

/* --- Grundlagen ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-body);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.53;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 .5rem;
  color: var(--text);
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: var(--tracking-display);
  text-wrap: balance;
}
h1 { font-size: var(--display-md); font-weight: 500; }
h2 { font-size: var(--display-sm); }
h3 { font-size: 1rem; }
h4 { font-size: .9375rem; }

.display-xl { font-size: var(--display-xl); font-weight: 600; color: var(--text); letter-spacing: var(--tracking-display); }
.display-lg { font-size: var(--display-lg); font-weight: 600; color: var(--text); letter-spacing: var(--tracking-display); }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

code, kbd, pre { font-family: var(--font-mono); font-size: .8125rem; }
code {
  background: var(--surface-3); color: var(--text);
  padding: .1em .4em; border-radius: var(--radius-sm);
}
pre {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; overflow-x: auto; margin: 0;
}
pre code { background: none; padding: 0; }

hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }

::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }

.muted   { color: var(--text-muted); }
.faint   { color: var(--text-faint); }
.small   { font-size: .8125rem; }
.subtitle { color: var(--text-muted); margin: 0 0 1.5rem; font-size: .9375rem; }
.empty   { color: var(--text-muted); text-align: center; padding: 2.5rem 1rem; }
.nowrap  { white-space: nowrap; }
.right   { text-align: right; }
.stack   { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.grow    { flex: 1; }
.tabular { font-variant-numeric: tabular-nums; }
.eyebrow {
  font-size: .8125rem; font-weight: 500; text-transform: uppercase;
  letter-spacing: var(--tracking-wide); color: var(--text-muted);
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Karten -------------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}
.panel-head h2 { margin: 0; font-size: 1.125rem; font-weight: 500; }

/* --- Schaltflächen -------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .42rem .875rem;
  font: inherit; font-size: .8125rem; font-weight: 500; line-height: 1.4;
  color: var(--text-body); background: transparent;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: var(--accent-shadow);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }

.btn-danger { color: var(--err); border-color: var(--err-border); }
.btn-danger:hover { background: var(--err-soft); color: var(--err); }

.btn-ghost { border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: .25rem .625rem; font-size: .75rem; }
.btn-block { width: 100%; padding: .55rem 1rem; font-size: .9375rem; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* --- Formulare ------------------------------------------------------------ */
label { display: block; font-size: .8125rem; font-weight: 500; margin-bottom: .3rem; color: var(--text); }
label .hint { display: block; font-weight: 400; color: var(--text-muted); font-size: .75rem; margin-top: .15rem; }

input[type=text], input[type=email], input[type=password], input[type=url],
input[type=number], input[type=search], input[type=date], input[type=datetime-local],
input[type=file], select, textarea {
  width: 100%;
  padding: .43rem .875rem;
  font: inherit; font-size: .9375rem;
  color: var(--text-body); background: transparent;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring);
}
textarea { min-height: 8rem; resize: vertical; font-family: var(--font-mono); font-size: .8125rem; line-height: 1.6; }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 53%, calc(100% - 11px) 53%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}

input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; }

.check {
  display: flex; align-items: flex-start; gap: .55rem;
  font-size: .9375rem; font-weight: 400; margin-bottom: .4rem; cursor: pointer;
  color: var(--text-body);
}
.check input { margin-top: .2rem; flex: 0 0 auto; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem 1.5rem; }
.form-grid .full { grid-column: 1 / -1; }
/* Felder einer Zeile auf eine Linie bringen: die Beschriftung nimmt die
   überzählige Höhe auf, damit ein zweizeiliger Hinweis das Eingabefeld
   daneben nicht nach unten schiebt. */
.form-grid > div { display: flex; flex-direction: column; }
.form-grid > div > label:first-child:not(.check):nth-last-child(2) { flex: 1 0 auto; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }

.form-actions {
  display: flex; gap: .75rem; align-items: center; flex-wrap: wrap;
  margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
}

.filters { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1.25rem; }
.filters > div { min-width: 10rem; }

.checkbox-list {
  max-height: 17rem; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .75rem; background: var(--surface-2);
}
.checkbox-list .depth-1 { padding-left: 1.25rem; }
.checkbox-list .depth-2 { padding-left: 2.5rem; }
.checkbox-list .depth-3 { padding-left: 3.75rem; }
.checkbox-list .depth-4 { padding-left: 5rem; }

.inline-form { display: inline; margin: 0; }

/* --- Tabellen ------------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 0 -1.5rem; }
.panel > .table-wrap:last-child { margin-bottom: -1.5rem; }
table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
thead th {
  background: var(--surface-2); color: var(--text);
  font-size: .8125rem; font-weight: 500; text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  text-align: left; padding: .7rem 1.5rem;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: .8rem 1.5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn, td.actions .btn + form, td.actions form + form { margin-left: .25rem; }

/* --- Rückmeldungen --------------------------------------------------------- */
.flash, .notice {
  display: flex; gap: .6rem; align-items: flex-start;
  padding: .8rem 1rem; margin-bottom: 1.25rem;
  border: 0; border-radius: var(--radius); font-size: .9375rem;
}
.flash-success, .notice-success { background: var(--ok-soft);     color: var(--ok); }
.flash-error,   .notice-error   { background: var(--err-soft);    color: var(--err); }
.flash-info,    .notice-info    { background: var(--accent-soft); color: var(--accent); }
.flash-warning, .notice-warning { background: var(--warn-soft);   color: var(--warn); }

.badge {
  display: inline-block; padding: .25rem .6rem;
  font-size: .75rem; font-weight: 500; letter-spacing: .02em;
  border-radius: 999px; border: 0; white-space: nowrap; line-height: 1.2;
}
.badge-active, .badge-sent, .badge-live      { background: var(--ok-soft);     color: var(--ok); }
.badge-pending, .badge-scheduled, .badge-paused { background: var(--warn-soft); color: var(--warn); }
.badge-draft, .badge-hidden, .badge-neutral  { background: var(--surface-3);   color: var(--text-muted); }
.badge-sending                               { background: var(--info-soft);   color: var(--info); }
.badge-unsubscribed, .badge-bounced, .badge-failed, .badge-cancelled,
.badge-blocked, .badge-disabled              { background: var(--err-soft);    color: var(--err); }

/* --- Kennzahlen ------------------------------------------------------------ */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1.5rem; margin-bottom: 1.5rem;
}
.stat {
  background: var(--surface); border: 0; border-radius: var(--radius);
  padding: 1.25rem 1.5rem; box-shadow: var(--shadow-md);
}
.stat .value {
  font-size: 1.5rem; font-weight: 500; line-height: 1.2;
  color: var(--text); font-variant-numeric: tabular-nums;
}
.stat .label { color: var(--text-muted); font-size: .8125rem; margin-top: .15rem; }

/* --- Seitennummerierung ----------------------------------------------------- */
.pagination { display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; margin-top: 1.25rem; font-variant-numeric: tabular-nums; }
.pagination a, .pagination .current {
  padding: .3rem .7rem; font-size: .8125rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-body); text-decoration: none;
}
.pagination a:hover { background: var(--surface-2); }
.pagination .current { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: var(--accent-shadow); }
.pagination .sep, .pagination .count { color: var(--text-muted); font-size: .8125rem; padding: .3rem .25rem; }

/* --- Design-Umschalter ------------------------------------------------------ */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; padding: 0;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--text-body);
  cursor: pointer; font-size: 1rem; line-height: 1;
}
.theme-toggle:hover { background: var(--accent-soft); color: var(--accent); }
.theme-toggle .icon-light,
.theme-toggle .icon-dark,
.theme-toggle .icon-system { display: none; }
:root:not([data-theme]) .theme-toggle .icon-system { display: inline; }
:root[data-theme="light"] .theme-toggle .icon-light { display: inline; }
:root[data-theme="dark"]  .theme-toggle .icon-dark  { display: inline; }

/* --- Geheimnisse / Schlüssel ------------------------------------------------- */
.keyout {
  background: var(--surface-2); border: 1px dashed var(--border-strong);
  color: var(--text); border-radius: var(--radius);
  padding: .8rem 1rem; font-family: var(--font-mono); font-size: .8125rem;
  word-break: break-all;
}

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