/* GurrSchlag — Vereinsdesign nach GurrKartei-Palette
   Primär #6680a4 / #afc6da / #d2d7ee, Akzent #4f9e9d, Violett #8b63a6 */

:root {
  --color-primary: #6680a4;
  --color-primary-light: #afc6da;
  --color-primary-very-light: #d2d7ee;
  --color-accent: #4f9e9d;
  --color-accent-2: #8b63a6;
  --color-text: #000000;
  --color-bg: #e1e1e2;
  --color-surface: #ffffff;
  --color-muted: #565655;
  --color-danger: #a33a32;
  --color-danger-bg: #f6e7e6;
  --color-warning: #765600;
  --color-warning-bg: #fff0b8;
  --color-ok: #2e6b46;
  --color-ok-bg: #e6f2ea;
  --color-border: #d8d8da;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  --bottom-nav-height: 58px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-text: #ececf0;
    --color-bg: #191b20;
    --color-surface: #25282f;
    --color-muted: #a9a9ad;
    --color-border: #3a3d45;
    --color-primary-light: #7d94ad;
    --color-primary-very-light: #2b3038;
    --color-danger-bg: #3a2624;
    --color-warning-bg: #38311c;
    --color-ok-bg: #1e2e26;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

.hidden { display: none !important; }

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

:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 1px;
  border-radius: 4px;
}

/* ---------- Grundbausteine ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
}
.button:hover { border-color: var(--color-primary); text-decoration: none; }
.button-primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; font-weight: 600; }
.button-primary:hover { background: #52688a; border-color: #52688a; }
.button-accent { background: var(--color-accent); border-color: var(--color-accent); color: #fff; font-weight: 600; }
.button-quiet { border-color: transparent; background: transparent; color: var(--color-muted); }
.button-danger { color: var(--color-danger); border-color: var(--color-danger); }
.button-sm { min-height: 36px; padding: 4px 12px; font-size: 14px; }

.icon-button {
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: transparent;
  font-size: 22px;
  color: var(--color-text);
  cursor: pointer;
}

input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 16px;
  font-family: inherit;
}
textarea { min-height: 44px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--color-primary); outline-offset: -1px; }

label { display: block; font-size: 14px; color: var(--color-muted); margin-bottom: 4px; }
label > input, label > select, label > textarea { margin-top: 4px; }

.check-line { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--color-text); min-height: 44px; }
.check-line input { width: 18px; height: 18px; accent-color: var(--color-primary); }

/* ---------- Layout: PC-Sidebar + mobile Bottom-Nav ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 58px;
  padding: 0 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
.topbar-logo { height: 34px; width: auto; display: block; }
.topbar-title { font-weight: 700; font-size: 18px; letter-spacing: 0.3px; }
.topbar-sub { font-weight: 400; color: var(--color-muted); font-size: 14px; margin-left: 6px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-name { color: var(--color-muted); font-size: 14px; }

.layout { display: flex; min-height: calc(100vh - 58px); }

.sidenav {
  width: 230px;
  flex-shrink: 0;
  padding: 16px 10px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidenav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--color-text);
  text-decoration: none;
  font-size: 15px;
}
.sidenav a svg { width: 20px; height: 20px; flex-shrink: 0; opacity: 0.75; }
.sidenav a:hover { background: var(--color-bg); text-decoration: none; }
.sidenav a.active { background: var(--color-primary); color: #fff; }
.sidenav a.active svg { opacity: 1; }
.sidenav .nav-footer { margin-top: auto; padding: 12px; font-size: 12px; color: var(--color-muted); }

.main { flex: 1; padding: 26px; max-width: 1240px; }

.bottomnav { display: none; }
.only-mobile { display: none; }

@media (max-width: 860px) {
  .layout { padding-bottom: var(--bottom-nav-height); }
  .only-mobile { display: inline-flex; }
  .main { padding: 16px; width: 100%; }
  .topbar-sub { display: none; }
  .user-name { display: none; }

  .bottomnav {
    position: fixed;
    z-index: 40;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--bottom-nav-height);
    display: flex;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.08);
  }
  .bottomnav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
    color: var(--color-muted);
    text-decoration: none;
    font-size: 11px;
    padding-top: 6px;
  }
  .bottomnav a svg { width: 22px; height: 22px; }
  .bottomnav a.active { color: var(--color-primary); font-weight: 600; }
  .sidenav { display: none; }
}

/* ---------- Seiteninhalte ---------- */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.page-head h1 { font-size: 24px; margin: 0; }
.page-head .spacer { flex: 1; }

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}
.card h2 { font-size: 17px; margin: 0 0 12px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

.stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius);
  padding: 14px;
}
.stat.stat-warn { border-left-color: var(--color-warning); }
.stat.stat-ok { border-left-color: var(--color-ok); }
.stat .stat-value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .stat-label { font-size: 13px; color: var(--color-muted); margin-top: 2px; }

table.data { width: 100%; border-collapse: collapse; font-size: 15px; }
table.data th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-muted);
  padding: 8px 10px;
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}
table.data td { padding: 10px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: var(--color-primary-very-light); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Tabellen werden auf schmalen Screens zu Karten */
@media (max-width: 720px) {
  table.data.responsive, table.data.responsive tbody, table.data.responsive tr, table.data.responsive td {
    display: block;
    border: none;
  }
  table.data.responsive thead { display: none; }
  table.data.responsive tr {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 8px 12px;
  }
  table.data.responsive tr:hover { background: var(--color-surface); }
  table.data.responsive td { padding: 6px 2px; border: none; }
  table.data.responsive td[data-label]::before {
    content: attr(data-label) ": ";
    font-size: 12px;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  table.data.responsive td.num { text-align: left; }
}

.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid var(--color-border);
  white-space: nowrap;
}
.chip-ok { background: var(--color-ok-bg); border-color: var(--color-ok); color: var(--color-ok); }
.chip-warn { background: var(--color-warning-bg); border-color: var(--color-warning); color: var(--color-warning); }
.chip-danger { background: var(--color-danger-bg); border-color: var(--color-danger); color: var(--color-danger); }
.chip-neutral { color: var(--color-muted); }
.chip-primary { background: var(--color-primary-very-light); border-color: var(--color-primary); color: var(--color-primary); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.form-row-end { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filters .filter { flex: 1; min-width: 160px; }

.stock-badge { font-variant-numeric: tabular-nums; font-weight: 600; }
.stock-low { color: var(--color-danger); }
.stock-zero { color: var(--color-warning); }
.stock-ok { color: var(--color-ok); }

.empty-hint {
  color: var(--color-muted);
  padding: 18px 8px;
  text-align: center;
}
.empty-state {
  text-align: center;
  padding: 34px 16px;
}
.empty-state .empty-logo { height: 44px; width: auto; opacity: 0.55; margin-bottom: 8px; }
.empty-state p { color: var(--color-muted); margin: 0 0 16px; }

.article-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}

.line-items .line-row {
  display: grid;
  grid-template-columns: minmax(140px, 2fr) 90px 130px 130px 44px;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--color-border);
}
@media (max-width: 720px) {
  .line-items .line-row { grid-template-columns: 1fr 1fr; }
  .line-items .line-row .remove-line { grid-column: 1 / -1; justify-self: end; }
}

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--color-border); font-size: 14px; }
.timeline li:last-child { border-bottom: none; }
.timeline .timeline-when { color: var(--color-muted); font-size: 12px; }

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

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--color-primary-very-light);
}
@media (prefers-color-scheme: dark) {
  .login { background: var(--color-bg); }
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 28px;
  text-align: center;
}
.login-card .login-logo { height: 72px; width: auto; margin: 0 auto 10px; display: block; }
.login-card h1 { margin: 0 0 6px; font-size: 26px; }
.login-sub { color: var(--color-muted); font-size: 14px; margin: 0 0 18px; }
.login-card label { text-align: left; margin-bottom: 12px; }
.login-card .button { width: 100%; justify-content: center; margin-top: 4px; }
.login-error { color: var(--color-danger); font-size: 14px; min-height: 20px; }

/* ---------- Toasts & Modal ---------- */

.toasts {
  position: fixed;
  bottom: 76px;
  right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}
@media (max-width: 860px) {
  .toasts { bottom: calc(var(--bottom-nav-height) + 12px); right: 12px; left: 12px; max-width: none; }
}
.toast {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  font-size: 14px;
}
.toast-error { border-left-color: var(--color-danger); }
.toast-ok { border-left-color: var(--color-ok); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 560px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 80px);
}
.modal h2 { margin: 0 0 14px; font-size: 19px; }
.modal-body { overflow-y: auto; }
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

/* Mobil: Modal als Bottom-Sheet */
@media (max-width: 720px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal {
    max-width: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 92vh;
    padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  }
}
