/*
 * BBS1 Ticketportal - eigenes Stylesheet fuer client/custom/
 * Ersetzt AdminLTE ausschliesslich fuer die Lehrkraft-Oberflaeche.
 *
 * Farben und Schriften angelehnt an die echte Schulwebseite
 * https://www.bbs1-delmenhorst.de/ (WordPress-Theme "bbs1-del"):
 * Marken-Navy #253787 und Akzent-Tuerkis #1cbac8 sind direkt aus deren
 * Stylesheet uebernommen, Montserrat/Open Sans ebenso (dort per Redux-
 * Google-Fonts-Plugin eingebunden). Hier lokal gehostet, damit die
 * eigene CSP (default-src 'self') ohne Ausnahmen auskommt.
 */

@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url("/client/custom/fonts/montserrat-var.woff2") format("woff2");
}
@font-face {
  font-family: "Open Sans";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/client/custom/fonts/opensans-var.woff2") format("woff2");
}

:root {
  /* Neutrale Flaechen - leicht ins Kuehl-Blaue getont, passend zum Navy */
  --paper:     #f5f6fb;
  --surface:   #ffffff;
  --surface-2: #eceef8;
  --ink:       #1c2340;
  --ink-2:     #4a5170;
  --muted:     #767c9a;
  --rule:      #dfe2ee;
  --rule-soft: #ececf5;

  /* Marke: Schul-Navy + Schul-Tuerkis, 1:1 von bbs1-delmenhorst.de */
  --brand:      #253787;
  --brand-ink:  #1a2860;
  --brand-soft: #e7e9f5;
  --accent:     #1cbac8;
  --accent-ink: #148d98;
  --accent-soft:#dff6f8;

  /* Status - eigene Hue je Bedeutung, bewusst ausserhalb von Navy/Tuerkis */
  --st-neu-fg: #2f5fc7;      --st-neu-bg: #e8eefb;
  --st-offen-fg: #3169c9;    --st-offen-bg: #e7edfb;
  --st-wartend-fg: #b8790a;  --st-wartend-bg: #faecd3;
  --st-geloest-fg: #2f7d52;  --st-geloest-bg: #e3f3ea;
  --st-geschlossen-fg: #5b6178; --st-geschlossen-bg: #eceefa;

  --danger:    #a5352f;
  --danger-bg: #fbe9e7;

  --shadow: 0 1px 2px rgba(28, 35, 64, .06), 0 6px 20px -10px rgba(28, 35, 64, .2);

  --sans: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --display: "Montserrat", "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:     #12162a;
    --surface:   #181d35;
    --surface-2: #202544;
    --ink:       #e8eaf7;
    --ink-2:     #b3b8d6;
    --muted:     #8489ac;
    --rule:      #2c3255;
    --rule-soft: #232849;

    --brand:      #8fa0e8;
    --brand-ink:  #b7c2f0;
    --brand-soft: #1f2750;
    --accent:     #3fd6e2;
    --accent-ink: #7de6ee;
    --accent-soft:#123338;

    --st-neu-fg: #93b3f2;      --st-neu-bg: #1c2a4d;
    --st-offen-fg: #93b3f2;    --st-offen-bg: #1c2a4d;
    --st-wartend-fg: #eab975;  --st-wartend-bg: #3a2a10;
    --st-geloest-fg: #86d1a5;  --st-geloest-bg: #163726;
    --st-geschlossen-fg: #a9aed0; --st-geschlossen-bg: #232849;

    --danger:    #e79b96;
    --danger-bg: #3a1c1a;

    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 26px -12px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---------- Topbar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}
.topbar-inner {
  max-width: 1040px; margin: 0 auto;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 20px;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-logo { height: 30px; width: auto; display: block; border-radius: 2px; }
.brand-name {
  font-family: var(--display); font-weight: 600; font-size: 15px;
  color: var(--brand); letter-spacing: .01em;
  padding-left: 12px; border-left: 1px solid var(--rule);
}

.toplinks { display: flex; gap: 26px; flex: 1; }
.toplinks a {
  font-family: var(--display);
  color: var(--ink-2); font-weight: 600; font-size: 14px;
  padding: 8px 4px; border-bottom: 2px solid transparent;
}
.toplinks a:hover { color: var(--brand); text-decoration: none; }
.toplinks a.is-active { color: var(--brand); border-bottom-color: var(--accent); }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.user-menu { position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: none; border: 1px solid transparent; border-radius: 999px;
  padding: 4px 10px 4px 4px; cursor: pointer; color: var(--ink);
  font: inherit;
}
.user-chip:hover { background: var(--surface-2); }
.avatar {
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-ink);
  font-size: 12px; font-weight: 700;
}
.user-name { font-size: 14px; font-weight: 500; max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--rule); border-radius: 10px;
  box-shadow: var(--shadow); padding: 6px; min-width: 170px;
}
.user-dropdown a {
  display: block; padding: 8px 10px; border-radius: 6px;
  color: var(--ink); font-size: 14px;
}
.user-dropdown a:hover { background: var(--surface-2); text-decoration: none; }
.user-dropdown-signout { color: var(--danger) !important; }

/* ---------- Grundlayout ---------- */

.shell { max-width: 1040px; margin: 0 auto; padding: 28px 20px 64px; }

.footer {
  max-width: 1040px; margin: 0 auto; padding: 0 20px 40px;
  color: var(--muted); font-size: 13px;
}

/*
 * Balken-Motiv unter Ueberschriften: direkt von bbs1-delmenhorst.de
 * uebernommen (dort z.B. ".ansprechpartner h3::after" - ein 5px hoher
 * Navy-Balken unter Zwischenueberschriften).
 */
h1, h2 {
  font-family: var(--display); color: var(--ink);
  letter-spacing: -.01em; text-wrap: balance;
}
h1 { font-size: 25px; font-weight: 700; margin: 0 0 12px; }
h1::after { content: ""; display: block; width: 46px; height: 4px; margin-top: 10px; background: var(--accent); border-radius: 2px; }
h2 { font-size: 18px; font-weight: 700; margin: 0 0 4px; }
.lede { color: var(--muted); font-size: 15px; margin: 0 0 24px; }

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

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; font-size: 14.5px;
  padding: 10px 16px; border-radius: 8px; cursor: pointer;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-sm { padding: 7px 12px; font-size: 13.5px; }
.btn-lg { padding: 12px 20px; font-size: 15.5px; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn-danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

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

.card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 12px;
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px 22px; }

/* ---------- Dashboard: Begruessung + Kennzahlen ---------- */

.greeting-row {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}

.stat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
  margin-bottom: 32px;
}
.stat-tile {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 18px 20px; border-left: 4px solid var(--rule);
  display: block; color: var(--ink);
}
.stat-tile:hover { text-decoration: none; border-color: var(--rule); background: var(--surface-2); }
.stat-tile.st-neu, .stat-tile.st-offen { border-left-color: var(--st-offen-fg); }
.stat-tile.st-wartend { border-left-color: var(--st-wartend-fg); }
.stat-tile.st-geloest { border-left-color: var(--st-geloest-fg); }
.stat-num {
  font-family: var(--display);
  font-size: 32px; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums; margin-bottom: 6px;
}
.stat-label { color: var(--muted); font-size: 14px; font-weight: 500; }

/* ---------- Status-Pille ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; font-weight: 600; letter-spacing: .01em;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.st-neu        { color: var(--st-neu-fg);        background: var(--st-neu-bg); }
.pill.st-offen      { color: var(--st-offen-fg);      background: var(--st-offen-bg); }
.pill.st-wartend    { color: var(--st-wartend-fg);    background: var(--st-wartend-bg); }
.pill.st-geloest    { color: var(--st-geloest-fg);    background: var(--st-geloest-bg); }
.pill.st-geschlossen{ color: var(--st-geschlossen-fg);background: var(--st-geschlossen-bg); }

.chip {
  display: inline-block; font-size: 12.5px; font-weight: 500;
  color: var(--ink-2); background: var(--surface-2);
  padding: 3px 9px; border-radius: 999px;
}

/* ---------- Reiter (Tickets-Seite) ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 20px; }
.tabs a {
  font-family: var(--display);
  padding: 10px 4px; margin-right: 22px;
  color: var(--muted); font-weight: 600; font-size: 14.5px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.is-active { color: var(--brand); border-bottom-color: var(--accent); }
.tabs a .count {
  display: inline-block; margin-left: 6px; font-size: 12px; font-weight: 700;
  color: var(--muted); background: var(--surface-2); border-radius: 999px;
  padding: 1px 7px; font-variant-numeric: tabular-nums;
}
.tabs a.is-active .count { color: var(--brand-ink); background: var(--brand-soft); }

/* ---------- Ticketliste ---------- */

.ticket-list { display: flex; flex-direction: column; gap: 10px; }

.ticket-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 10px;
  padding: 14px 16px; color: var(--ink);
}
.ticket-row:hover { border-color: var(--brand); background: var(--surface-2); text-decoration: none; }
.ticket-num { font-family: var(--mono); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.ticket-main { flex: 1; min-width: 0; }
.ticket-subject { font-weight: 600; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }
.ticket-chevron { color: var(--muted); font-size: 18px; flex-shrink: 0; }

.empty-state {
  text-align: center; padding: 48px 20px; color: var(--muted);
  border: 1px dashed var(--rule); border-radius: 12px;
}
.empty-state .emoji { font-size: 30px; display: block; margin-bottom: 10px; }

/* ---------- Formular: neues Ticket ---------- */

.form-grid { display: grid; gap: 18px; }
.field label {
  display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px;
}
.field .hint { color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.field input[type="text"],
.field select,
.field textarea {
  width: 100%; font: inherit; font-size: 15px;
  padding: 10px 12px; border: 1px solid var(--rule); border-radius: 8px;
  background: var(--surface); color: var(--ink);
}
.field textarea { min-height: 140px; resize: vertical; }
.field input[type="file"] { font-size: 13.5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }

/* ---------- Ticketansicht ---------- */

.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; margin-bottom: 16px; }

.ticket-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 6px; }
.ticket-head h1 { font-size: 21px; }
.ticket-id-line { color: var(--muted); font-family: var(--mono); font-size: 13px; margin-bottom: 6px; }

.meta-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px; margin: 18px 0 20px;
}
.meta-item .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin-bottom: 3px; }
.meta-item .v { font-size: 14.5px; font-weight: 500; }

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: 10px; padding: 14px 16px; margin: 18px 0;
  font-size: 14.5px;
}
.notice-info { background: var(--brand-soft); color: var(--brand-ink); }
.notice-muted { background: var(--surface-2); color: var(--ink-2); }

.attachment-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.attachment-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface-2); border-radius: 8px; padding: 8px 12px; font-size: 14px;
}
.attachment-list a { font-size: 13px; }

.reply-thread { display: flex; flex-direction: column; gap: 14px; margin: 22px 0; }
.reply {
  max-width: 78%; padding: 12px 16px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--rule);
}
.reply-it { align-self: flex-start; border-top: 3px solid var(--brand); }
.reply-mir { align-self: flex-end; background: var(--brand-soft); border-color: transparent; }
.reply-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.reply-head strong { color: var(--ink); font-size: 13.5px; }
.reply-body { font-size: 14.5px; white-space: pre-wrap; word-wrap: break-word; }
.reply-body p:first-child { margin-top: 0; }
.reply-body p:last-child { margin-bottom: 0; }

.reply-form textarea { min-height: 110px; }

.action-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 20px 0; }

.feedback-row { display: flex; gap: 10px; }

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

@media (max-width: 720px) {
  .topbar-inner { gap: 10px; padding: 10px 14px; }
  .brand-name { display: none; }
  .toplinks a { padding: 8px; font-size: 13.5px; }
  .user-name { display: none; }
  .shell { padding: 20px 14px 48px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-grid .stat-tile:last-child { grid-column: 1 / -1; }
  .field-row { grid-template-columns: 1fr; }
  .reply { max-width: 92%; }
  .ticket-row { flex-wrap: wrap; }
  .ticket-num { order: 3; width: 100%; }
}

@media (max-width: 460px) {
  .stat-grid { grid-template-columns: 1fr; }
  .stat-grid .stat-tile:last-child { grid-column: auto; }
}

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

/* Apple-inspired portal: system typography, soft surfaces and clear controls. */
:root, :root[data-theme="light"] {
  --paper: #f5f5f7; --surface: #fff; --surface-2: #eeeef0;
  --ink: #1d1d1f; --ink-2: #515154; --muted: #66666b;
  --rule: #dedee3; --rule-soft: #ebebef;
  --brand: #253787; --brand-ink: #1a2860; --brand-soft: #e9edf8;
  --accent: #0071e3; --accent-ink: #005bb8; --accent-soft: #e5f1ff;
  --shadow: 0 4px 24px rgba(0,0,0,.035);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #101012; --surface: #1c1c1e; --surface-2: #2c2c2e;
  --ink: #f5f5f7; --ink-2: #c5c5cb; --muted: #a1a1aa;
  --rule: #3a3a3c; --rule-soft: #2c2c2e;
  --brand: #a8b8ff; --brand-ink: #c9d2ff; --brand-soft: #252c48;
  --accent: #0071e3; --accent-ink: #005bb8; --accent-soft: #182d46;
  --st-neu-fg: #9bbfff; --st-neu-bg: #1d304d;
  --st-offen-fg: #9bbfff; --st-offen-bg: #1d304d;
  --st-wartend-fg: #f1c078; --st-wartend-bg: #392c19;
  --st-geloest-fg: #8bd5a6; --st-geloest-bg: #1b3426;
  --st-geschlossen-fg: #bcbcc7; --st-geschlossen-bg: #303036;
  --danger: #ffa49c; --danger-bg: #402422;
  --shadow: 0 4px 24px rgba(0,0,0,.16);
  color-scheme: dark;
}
.topbar { background: var(--surface); background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); }
.topbar-inner { max-width: 1120px; min-height: 76px; flex-wrap: wrap; }
.brand-logo { background: white; border-radius: 6px; }
.brand-name { letter-spacing: -.025em; }
.toplinks { gap: 6px; }
.toplinks a { border: 0; border-radius: 10px; padding: 9px 15px; }
.toplinks a.is-active { background: var(--brand-soft); }
.shell { max-width: 1120px; width: 100%; padding-top: 48px; }
h1 { font-size: clamp(28px, 4vw, 38px); letter-spacing: -.045em; line-height: 1.15; font-weight: 700; }
h1::after { display: none; }
h2 { letter-spacing: -.025em; }
.lede { line-height: 1.65; color: var(--ink-2); }
.greeting-row { margin-bottom: 30px; }
.card, .stat-tile { border-radius: 20px; }
.card-pad { padding: 26px; }
.stat-grid { gap: 20px; }
.stat-tile { padding: 25px; border-left-width: 1px; border-top: 3px solid var(--rule); }
.stat-tile.st-offen, .stat-tile.st-neu { border-top-color: var(--st-offen-fg); }
.stat-tile.st-wartend { border-top-color: var(--st-wartend-fg); }
.stat-tile.st-geloest { border-top-color: var(--st-geloest-fg); }
.stat-num { font-size: 42px; letter-spacing: -.04em; font-weight: 600; }
.btn { border-radius: 12px; min-height: 42px; justify-content: center; }
.btn-brand { background: #253787; border-color: #253787; color: #fff; }
.btn-brand:hover { background: #1a2860; border-color: #1a2860; }
.ticket-row { padding: 19px 20px; border-radius: 16px; }
.user-dropdown { border-radius: 16px; padding: 8px; }
.theme-switch { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--rule); border-radius: 12px; }
.theme-switch button { border: 0; background: transparent; color: var(--ink-2); font: inherit; font-size: 13px; padding: 7px 9px; min-height: 34px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
@media (max-width: 720px) {
  .topbar-inner { gap: 12px; }
  .toplinks { margin-left: auto; flex: 0 1 auto; }
  .topbar-right { width: 100%; justify-content: flex-end; flex-wrap: wrap; }
  .theme-switch { margin-right: auto; }
  .shell { padding-top: 28px; }
  .card-pad { padding: 20px; }
  .stat-grid { gap: 12px; }
}

/* Server-rendered search works without JavaScript in either theme. */
.ticket-search { margin: 0 0 24px; }
.ticket-search label { display: block; font-weight: 600; margin-bottom: 8px; }
.ticket-search-controls { display: flex; align-items: stretch; gap: 10px; flex-wrap: wrap; }
.ticket-search input[type="search"] { flex: 1 1 280px; min-width: 0; padding: 12px 16px; border: 1px solid var(--rule); border-radius: 12px; background: var(--surface); color: var(--ink); font: inherit; }
.ticket-search input::placeholder { color: var(--muted); opacity: 1; }
.ticket-search-hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.search-result-count { color: var(--ink-2); font-size: 14px; }
@media (max-width: 720px) { .tabs { overflow-x: auto; } .tabs a { flex-shrink: 0; } }
