/* =========================================================
   evengreenTMS – Stylesheet
   Design-Tokens abgeleitet aus dem Ebengrün-Markendesign
   (Logo-Farben: Grün #42f62e, Dunkelblau #2e3a51).
   ========================================================= */

/* ── Light-Mode (Standard) ────────────────────────────────── */
:root {
  --bg:          #e9edf3;
  --surface:     #ffffff;
  --surface2:    #eef1f6;
  --border:      #cbd3e0;
  --accent:      #2e3a51;
  --accent-hover:#1f2937;
  --accent-glow: rgba(46,58,81,0.12);
  --brand-green: #2fae1f;
  --brand-green-bg: rgba(66,246,46,0.12);
  --text:        #1a2233;
  --text-dim:    #667085;
  --green:       #16a34a;
  --green-bg:    rgba(22,163,74,0.10);
  --yellow:      #b45309;
  --yellow-bg:   rgba(180,83,9,0.10);
  --red:         #dc2626;
  --red-bg:      rgba(220,38,38,0.08);
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 2px 10px rgba(20,25,40,0.08);
  --shadow-card: 0 1px 3px rgba(20,25,40,0.07), 0 1px 2px rgba(20,25,40,0.05);
  --row-hover:   rgba(46,58,81,0.05);
  --thead-bg:    #f4f6fa;
}

/* ── Dark-Mode (per Umschalter) ───────────────────────────── */
body.dark {
  --bg:          #0a0d14;
  --surface:     #1a2030;
  --surface2:    #222a3d;
  --border:      #313a52;
  --accent:      #4f7cff;
  --accent-hover:#3a63e0;
  --accent-glow: rgba(79,124,255,0.18);
  --brand-green: #42f62e;
  --brand-green-bg: rgba(66,246,46,0.14);
  --text:        #e8eaf2;
  --text-dim:    #8a91ac;
  --green:       #2dce7c;
  --green-bg:    rgba(45,206,124,0.12);
  --yellow:      #d99a1f;
  --yellow-bg:   rgba(217,154,31,0.14);
  --red:         #ff5c6a;
  --red-bg:      rgba(255,92,106,0.12);
  --shadow:      0 2px 10px rgba(0,0,0,0.45);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.35), 0 1px 2px rgba(0,0,0,0.3);
  --row-hover:   rgba(79,124,255,0.07);
  --thead-bg:    #15192580;
}

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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
  transition: background .2s, color .2s;
}

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

/* Sichtbarer Fokusring fuer Tastaturbedienung (Tab-Taste) --
   bewusst kraeftig, nie per outline:none entfernt. */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Kopfbereich ───────────────────────────────────────────── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo img { height: 40px; display: block; }
img.logo-dark { display: none; }
body.dark img.logo-light { display: none; }
body.dark img.logo-dark { display: block; }
.logo-text { font-size: 18px; font-weight: 700; letter-spacing: -0.2px; color: var(--text); }
.header-nav { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.header-user { font-size: 13px; color: var(--text-dim); white-space: nowrap; }
.header-user strong { color: var(--text); }

.nav-btn, .btn, button, input[type="submit"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nav-btn:hover, .btn:hover, button:hover, input[type="submit"]:hover {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
a.nav-btn, a.btn { text-decoration: none; }

.btn-primary, button[type="submit"], input[type="submit"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover, button[type="submit"]:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
body.dark .btn-danger { background: #c4293a; border-color: #c4293a; color: #fff; }
body.dark .btn-danger:hover { background: #a91f2e; border-color: #a91f2e; }

.theme-toggle {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--text); }
.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun  { display: inline; }
body.dark .theme-toggle .icon-moon { display: inline; }
body.dark .theme-toggle .icon-sun  { display: none; }

/* ── Seitentitel-Leiste (Titel + Icon-Navigation) ─────────── */
.page-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.page-bar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  color: var(--text-dim);
  text-decoration: none;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface2); color: var(--accent); }

/* Ein <button type="submit" class="icon-btn"> (z.B. Löschen-Buttons in
   Formularen) wird sonst von der generischen ".btn-primary, button[type=
   submit]"-Regel oben ueberschrieben (Vollfarbe statt Icon-Look) - siehe
   wiederkehrende Spezifitaets-Problematik mit generischen button-Selektoren.
   Hoehere Spezifitaet stellt hier gezielt wieder den Icon-Look her. */
button.icon-btn[type="submit"] {
  background: transparent;
  border: none;
  padding: 0;
  font-weight: 400;
}
button.icon-btn[type="submit"]:hover {
  background: var(--surface2);
  border-color: transparent;
}
.page-bar-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 0 6px;
  letter-spacing: -0.1px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Layout-Container ─────────────────────────────────────── */
.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}
.breadcrumb { margin-bottom: 14px; font-size: 13px; }
.breadcrumb a { color: var(--text-dim); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }

h1 { font-size: 22px; margin: 0 0 6px; letter-spacing: -0.2px; }
h2 { font-size: 16px; margin: 28px 0 10px; color: var(--text); }
h3 { font-size: 13px; margin: 20px 0 8px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }

/* ── Meldungen ─────────────────────────────────────────────── */
.flash-status {
  background: var(--green-bg);
  border: 1px solid var(--green);
  color: var(--green);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 18px;
  font-size: 14px;
}
.flash-errors {
  background: var(--red-bg);
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 18px;
  font-size: 14px;
}
.flash-errors ul { margin: 0; padding-left: 18px; }
.notice-warning {
  background: var(--yellow-bg); border: 1px solid var(--yellow); color: var(--yellow);
  border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; font-size: 13px;
}
.notice-danger {
  background: var(--red-bg); border: 1px solid var(--red); color: var(--red);
  border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; font-size: 13px;
}
.notice-info {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; font-size: 13px;
}

/* ── Kennzahlen (Dashboard) ───────────────────────────────── */
.kennzahlen { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.kennzahl {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 14px 18px;
  flex: 1;
  min-width: 160px;
}
.kennzahl span { display: block; color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.kennzahl strong { font-size: 20px; font-weight: 700; }
.positiv { color: var(--green); }
.negativ { color: var(--red); }

/* ── Navigations-Kacheln (Dashboard) ──────────────────────── */
.nav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 8px; }
.nav-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: 16px 18px; }
.nav-group h4 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); }
.nav-group a { display: block; padding: 6px 0; color: var(--text); text-decoration: none; font-size: 14px; }
.nav-group a:hover { color: var(--accent); }

/* ── Karten / Formulare ───────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 18px 22px;
  margin-bottom: 16px;
}
.card summary { cursor: pointer; font-weight: 600; list-style: none; color: var(--text); }
.card summary::-webkit-details-marker { display: none; }
.card summary::before { content: "▸ "; color: var(--text-dim); }
.card[open] summary::before { content: "▾ "; }
details.card { padding: 14px 22px; }
details.card[open] { padding-bottom: 18px; }
.card summary small { font-weight: 400; color: var(--text-dim); margin-left: 6px; }

.form-section { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.form-grid { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: end; }
.form-grid.stacked { flex-direction: column; align-items: stretch; max-width: 480px; }
.form-grid label,
form > label { display: flex; flex-direction: column; font-size: 12px; color: var(--text-dim); gap: 4px; margin-bottom: 10px; }
.form-grid > label { margin-bottom: 0; }

label { font-size: 12px; color: var(--text-dim); }

input, select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 11px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  width: 100%;
  max-width: 420px;
}
input[type="checkbox"], input[type="radio"] { width: auto; max-width: none; accent-color: var(--accent); }
textarea { max-width: 560px; min-height: 90px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
input[type="file"] { max-width: 420px; padding: 6px; }

form { margin: 0 0 6px; }

/* ── Tabellen ─────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  font-size: 13px;
  margin-bottom: 16px;
}
th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
th {
  background: var(--thead-bg);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-dim);
  font-weight: 600;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--row-hover); }

.sortable-th {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.sortable-th:hover { color: var(--accent); }
.sortable-th.active { color: var(--text); }
.sortable-th .sort-icon { display: inline-flex; opacity: 0.7; }
.sortable-th.active .sort-icon { opacity: 1; }

.status-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  vertical-align: middle;
}
.status-dot.dot-green  { background: var(--green); }
.status-dot.dot-yellow { background: var(--yellow); }
.status-dot.dot-red    { background: var(--red); }
.status-dot.dot-neutral{ background: var(--border); }
tfoot td { border-top: 2px solid var(--border); border-bottom: none; }
tr.row-overdue td { background: var(--red-bg); }

/* ── Geschäftspartner-Live-Suche (Autocomplete) ───────────── */
.partner-picker { position: relative; }
.pp-results {
  display: none;
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.pp-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.pp-item:last-child { border-bottom: none; }
.pp-item:hover, .pp-item:focus { background: var(--surface2); outline: none; }
.pp-item.pp-empty { color: var(--text-dim); cursor: default; }
.pp-item.pp-empty:hover { background: none; }

.table-scroll { overflow-x: auto; border-radius: var(--radius-lg); }
.table-scroll table { margin-bottom: 0; }

.orders-table th:first-child, .orders-table td:first-child { width: 100px; white-space: nowrap; }

/* ── Status-Badges ────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-neutral { background: var(--surface2); color: var(--text-dim); border: 1px solid var(--border); }
.badge-green   { background: var(--green-bg); color: var(--green); }
.badge-yellow  { background: var(--yellow-bg); color: var(--yellow); }
.badge-red     { background: var(--red-bg); color: var(--red); }
.badge-brand   { background: var(--brand-green-bg); color: #1f7a13; }
body.dark .badge-brand { color: var(--brand-green); }

/* ── Pagination-Links (Laravel-Standard) ──────────────────── */
nav[role="navigation"] { font-size: 13px; margin-top: 4px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 720px) {
  .header-inner { padding: 0 14px; flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; }
  .container { padding: 16px 14px 40px; }
  .kennzahlen, .nav-grid { grid-template-columns: 1fr; }
}

/* Reduzierte Bewegung respektieren */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ── Tab-Navigation (z. B. Auftrag bearbeiten) ─────────────── */
.tab-nav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  border-radius: 0;
}
.tab-btn:hover { background: none; border-color: var(--border); color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
