/* ==========================================================
   style.css - modern, bright, light theme + blue accent
   (drop-in replacement with higher-contrast form inputs +
   three-column form-grid + small refinements)
   ========================================================== */

/* ---------- color system ---------- */
:root {
  --bg: #f7f9fc;
  --card: #ffffff;
  --text: #0f1c2e;
  --muted: #5b6b82;
  --border: #e6ecf5;

  --accent: #2b79ff;
  --accent-600: #2568dc;
  --accent-050: #e9f1ff;

  --gray-light: #DCDCDC;
  --gray: #D3D3D3;
  --gray-dark: #C0C0C0;

  --green-light: #e6f4ea;
  --green: #38a169;
  --green-dark: #2f855a;

  --red-light: #ffe6e6;
  --red: #e53e3e;
  --red-dark: #c53030;

  --focus: 0 0 0 3px rgba(43,121,255,.25);
  --radius: 12px;
  --shadow: 0 6px 22px rgba(15,28,46,.08);

  /* inputs: higher contrast tokens */
  --input-bg: #f9fbff;                 /* subtle tint to stand out on white card */
  --input-border: #ced7e5;             /* stronger default border */
  --input-border-hover: #b9c6d8;
  --input-border-focus: #2b79ff;       /* brand accent */
  --input-shadow: 0 1px 0 rgba(15,28,46,.03);
  --input-shadow-focus: 0 0 0 3px rgba(43,121,255,.18); /* soft halo */
  --placeholder: #8a98ad;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 20% -10%, var(--accent-050), transparent) no-repeat, var(--bg);
}

/* ---------- layout wrappers ---------- */
.container { width: min(1600px, 92%); margin: 0 auto; }
.site-main { padding: 28px 0 60px; }

/* ---------- header & nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0;
}
.brand {
  display: flex; align-items: center; gap: 10px;
}
.brand-name {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: .2px;
}
.logo-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7fb3ff);
  box-shadow: 0 0 0 4px rgba(43,121,255,.15);
}

/* navigation */
.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 6px;
}

/* replaced the generic anchor rules with .nav-link to avoid clashing with .btn */
.site-nav a.nav-link {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}
.site-nav a.nav-link:hover {
  color: var(--text);
  background: #f1f5fb;
}
.site-nav a.nav-link.active {
  color: var(--accent-600);
  background: var(--accent-050);
}
.nav-link.disabled {
  opacity:.5; pointer-events:none;
}

/* auth area in nav */
.site-nav .nav-auth { display:flex; align-items:center; gap:10px; }
.site-nav .nav-user  { padding: 0 6px; color: var(--muted); }

/* stronger, nav-scoped styles for login/logout for readability */
.site-nav .btn-login {
  background-color: var(--green);
  color: #fff;
}
.site-nav .btn-login:hover {
  background-color: var(--green-dark);
  color: #fff;
}

.site-nav .btn-logout {
  background-color: var(--red);
  color: #fff;
}
.site-nav .btn-logout:hover {
  background-color: var(--red-dark);
  color: #fff;
}

/* mobile nav toggle */
.nav-toggle {
  display: none;
  width: 44px; height: 36px;
  border: 0;
  border-radius: 8px;
  background: #f1f5fb;
  cursor: pointer;
}
.nav-toggle .bar {
  display: block;
  width: 22px; height: 2px;
  background: var(--text);
  margin: 4px auto;
  border-radius: 2px;
}
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* ---------- hero / general panels ---------- */
.hero {
  padding: 34px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fff, #fff8);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.hero h1 { margin: 0 0 10px; font-size: 2rem; }
.hero .lead { color: var(--muted); max-width: 60ch; }
.hero-actions { display: flex; gap: 12px; margin-top: 18px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

/* neutral */
.btn-neutral {
  background-color: var(--gray-light);
  color: var(--text);
}
.btn-neutral:hover { background-color: var(--gray); }

/* neutral / ghost */
.btn-ghost {
  background: transparent;
  color: var(--text);
}
.btn-ghost:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* default blue button */
.btn-primary {
  background-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background-color: var(--accent-600); }

/* 'important' button */
.btn-important {
  background-color: var(--red);
  color: #fff;
}
.btn-important:hover { background-color: var(--red-dark); }

/* login (green, lighter background, white text) – kept for use outside nav */
.btn-login {
  background-color: var(--green);
  color: #fff;
  box-shadow: 0 2px 4px rgba(56,161,105,0.2);
}
.btn-login:hover {
  background-color: var(--green-dark);
  color: #fff;
}

/* logout (red, lighter background, white text) – kept for use outside nav */
.btn-logout {
  background-color: var(--red-light);
  color: #fff;
  box-shadow: 0 2px 4px rgba(229,62,62,0.2);
}
.btn-logout:hover {
  background-color: var(--red);
  color: #fff;
}

/* Normalize anchors and buttons that look like buttons */
a.btn,
button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4em;                 /* optional, for icons */
    padding: 0.5rem 1rem;       /* keep your existing spacing */
    line-height: 1;             /* make text box consistent */
    border: 0;                  /* kill UA button border */
    font: inherit;              /* ensure same font metrics */
    text-decoration: none;
    -webkit-appearance: none;   /* remove native styling */
    appearance: none;
}

/* ---------- cards / grids ---------- */
.grid {
  display: grid; gap: 18px; margin-top: 24px;
  grid-template-columns: repeat(12, 1fr);
}
.card {
  grid-column: span 12;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 6px; font-size: 1.2rem; }
.card p  { margin: 0; color: var(--muted); }

/* ---------- panels & alerts ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.panel-header {
  display:flex; align-items:center;
  justify-content:space-between;
  gap:12px; margin-bottom: 10px;
}
.panel .lead { color: var(--muted); margin-top: 4px; }

.alert {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid #e6ecf5;
  border-radius: 10px;
  background: #f9fbff;
  color: var(--text);
}
.alert.error   { border-color:#ffd3d3; background:#fff5f5; color:#9c1c1c; }
.alert.success { border-color:#cfead1; background:#f0fff2; color:#1b6b2a; }

/* ---------- tables ---------- */
.table-wrap { overflow-x:auto; border:1px solid var(--border); border-radius:var(--radius); background:var(--card); box-shadow:var(--shadow); }
.table { width:100%; border-collapse:collapse; font-size:0.95rem; }
.table th, .table td { padding:12px 14px; border-bottom:1px solid var(--border); }
/* fix: use the muted var properly for header text color */
.table thead th { background:#f6f9ff; color: var(--muted); text-align:left; }
.table tr:hover td { background:#fafcff; }
.table .num { text-align:right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* ---------- forms ---------- */
.form {
  margin-top:14px;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:18px;
  box-shadow:var(--shadow);
}

/* form grid layout helpers */
.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;              /* default: 1 column (mobile friendly) */
}
.form-grid.two   { grid-template-columns: 1fr 1fr; }             /* 2 columns */
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }         /* 3 columns */

/* make inner rows line up neatly in grids */
.form-grid .form-row { margin: 0; }

/* responsive fallback: collapse to fewer columns on smaller screens */
@media (max-width: 900px) {
  .form-grid.three { grid-template-columns: 1fr 1fr; }           /* 3 → 2 */
}
@media (max-width: 600px) {
  .form-grid.two,
  .form-grid.three { grid-template-columns: 1fr; }               /* 2/3 → 1 */
}

/* fields & labels */
.form-row { display:flex; flex-direction:column; gap:6px; margin-bottom:14px; }
.form-row label { font-weight:600; color: var(--text); }
.form-row .req { color: var(--accent-600); }

/* inputs: higher contrast + clearer states */
input[type="text"],
select,
textarea {
  padding:10px 12px;
  border:1.5px solid var(--input-border);
  border-radius:10px;
  background: var(--input-bg);
  font:inherit;
  color:var(--text);
  outline:none;
  box-shadow: var(--input-shadow);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
input[type="text"]::placeholder,
textarea::placeholder { color: var(--placeholder); }

/* hover: subtle nudge */
input[type="text"]:hover,
select:hover,
textarea:hover { border-color: var(--input-border-hover); }

/* focus: strong but friendly */
input[type="text"]:focus,
select:focus,
textarea:focus {
  border-color: var(--input-border-focus);
  box-shadow: var(--input-shadow-focus);
  background:#fff;                                   /* slight lift on focus */
}

/* labels react on focus for better scanning */
.form-row:focus-within > label { color: var(--accent-600); }

/* readonly fields (e.g., kurzname on edit) */
input[readonly] {
  background:#eef3fa;
  color:#5b6b82;
  border-style:dashed;
}

/* checkbox rows: align neatly and keep contrast */
.form-row.checkbox-row { display:flex; align-items:left; gap:6px; margin-top:12px;}
.form-row.checkbox-row > label { font-weight:600; color: var(--muted); }
.form-row.checkbox-row input[type="checkbox"] {
  width:16px; height:16px; accent-color: var(--accent);
}

/* field errors: message + optional error class to tint borders */
.field-error { color:#9c1c1c; font-size:.9rem; margin-top:4px; }
input[type="text"].has-error,
select.has-error,
textarea.has-error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(229,62,62,.12);
}

/* action row */
.form-actions { display:flex; gap:10px; margin-top:8px; }
.btn.small { padding:6px 10px; font-weight:600; }

/* accessibility: higher-contrast user preference support */
@media (prefers-contrast: more) {
  input[type="text"],
  select,
  textarea {
    border-width:2px;
    box-shadow:none;
  }
  input[type="text"]:focus,
  select:focus,
  textarea:focus {
    box-shadow: 0 0 0 4px rgba(43,121,255,.28);
  }
}

/* ---------- multi-list (faculties) styling ---------- */

/* ensure multi-row selects fill available width nicely */
.multi-list select {
  width: 100%;
  max-width: 420px; /* optional upper bound to prevent overly wide selects */
}

/* add/remove row buttons align with select width */
.add-row,
.multi-list .remove {
  width: auto;
  align-self: start;
  margin-top: 6px;
}

/* keep the add button visually aligned under the select */
.add-row {
  display: inline-block;
  padding: 6px 10px;
  font-size: 0.9rem;
  white-space: nowrap;
  background: var(--accent-050);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent-600);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.add-row:hover {
  background: var(--accent-600);
  border-color: var(--accent-600);
  color: #fff;
}

/* remove button stays compact */
.multi-list .remove {
  padding: 4px 8px;
  margin-left: 6px;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--muted);
}
.multi-list .remove:hover {
  background: #ffe6e6;
  color: var(--red-dark);
}

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: #fff8;
  backdrop-filter: blur(6px);
}
.footer-inner { padding:18px 0; text-align:center; color: var(--muted); }
.foot-note { margin:6px 0 0; font-size:.9rem; }

/* ---------- responsiveness ---------- */
@media (max-width: 820px) {
  .site-nav {
    position: absolute; right:16px; top:60px;
    background:#fff; border:1px solid var(--border);
    border-radius:10px; padding:8px; box-shadow:var(--shadow);
    display:none;
  }
  .site-nav.open { display:block; }
  .site-nav ul { flex-direction:column; gap:4px; }
  .nav-toggle { display:inline-block; }
  .header-inner { gap:10px; }
}
@media (min-width: 720px) {
  .card { grid-column: span 4; }
}





/* ---------- service row tint (works with named colors or hex) ---------- */
/* Tunables */
:root {
  --svc-mix              : 30%;
  --svc-mix-hover        : 50%;
  --svc-mix-checked      : 50%;
  --svc-mix-checked-hover: 70%;
}

/* Default (with color-mix) — paint the table cells, not the row only */
@supports (color: color-mix(in srgb, white, black)) {
  .table tbody tr.svc-tint > * {
    background: color-mix(in srgb, var(--svc-row-color, white) var(--svc-mix), white);
    transition: background-color .15s ease, background .15s ease;
  }
  .table tbody tr.svc-tint:hover > * {
    background: color-mix(in srgb, var(--svc-row-color, white) var(--svc-mix-hover), white);
  }
  .table tbody tr.svc-tint.is-checked > * {
    background: color-mix(in srgb, var(--svc-row-color, white) var(--svc-mix-checked), white);
  }
  .table tbody tr.svc-tint.is-checked:hover > * {
    background: color-mix(in srgb, var(--svc-row-color, white) var(--svc-mix-checked-hover), white);
  }
}

/* Fallback for browsers without color-mix(): subtle left color bar */
@supports not (color: color-mix(in srgb, white, black)) {
  .table tbody tr.svc-tint > * {
    background: var(--card);
  }
  .table tbody tr.svc-tint > td:first-child {
    position: relative;
  }
  .table tbody tr.svc-tint > td:first-child::before {
    content: "";
    position: absolute; left: 0; top: 0; bottom: -1px; width: 6px;
    background: var(--svc-row-color, #eee);
    border-right: 1px solid var(--border);
  }
  /* Slightly stronger bar when selected */
  .table tbody tr.svc-tint.is-checked > td:first-child::before {
    background: var(--svc-row-color, #bbb);
  }
}

/* Make selectable rows feel clickable + keyboard focus hint */
.table tbody tr.svc-row-toggle { cursor: pointer; }
.table tbody tr.svc-row-toggle.kbd-focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}





/* ===== Submenu / Folder nav (adds on top of existing nav styles) ===== */

/* lay out the root UL a bit more explicitly */
.site-nav .nav-root { display:flex; align-items:center; gap: 6px; }

/* folder container */
.site-nav .has-submenu { position: relative; }

/* the folder button looks like a nav-link but is a <button> for a11y */
.site-nav .submenu-toggle {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: 10px 14px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.site-nav .submenu-toggle:hover {
    color: var(--text);
    background: #f1f5fb;
}
.site-nav .has-submenu.open > .submenu-toggle {
    color: var(--accent-600);
    background: var(--accent-050);
}
.site-nav .has-submenu .chev { transition: transform .15s ease; }
.site-nav .has-submenu.open .chev { transform: rotate(180deg); }

/* the dropdown list */
.site-nav .submenu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 14rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px 0;
    box-shadow: var(--shadow);
    z-index: 25;
}
.site-nav .submenu li { list-style: none; }
.site-nav .submenu a.nav-link {
    display:block;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
}
.site-nav .submenu a.nav-link:hover { background:#f6f9ff; color: var(--text); }
.site-nav .submenu a.nav-link.active {
    color: var(--accent-600);
    background: var(--accent-050);
}

/* Make disabled links still appear in submenu */
.site-nav .submenu .nav-link.disabled {
    opacity: .55;
    pointer-events: none;
}

/* make the HTML hidden attribute authoritative */
[hidden] { display: none !important; }

/* optional: belt-and-suspenders - if a folder is "open", show its submenu */
.site-nav .has-submenu.open > .submenu { display: block; }


/* ---- Mobile tweaks (keep your existing mobile rules, add these) ---- */
@media (max-width: 820px) {
    /* Show submenus inline under their folder on mobile */
    .site-nav .has-submenu { position: static; }
    .site-nav .submenu {
        position: static;
        border: 0;
        border-radius: 8px;
        box-shadow: none;
        padding: 4px 6px 6px;
        background: transparent;
    }
    /* Space the submenu items a bit */
    .site-nav .submenu a.nav-link { padding: 8px 10px; }
}





/* ==========================================================
   Destructive actions "arming" UI
   Reusable component: arm bar + armed delete buttons
   ========================================================== */

.arm-actions-bar {
  display: flex;
  justify-content: flex-end;  /* right side of the page */
  align-items: center;
}

.arm-pill {
  display: inline-flex;
  flex-direction: column;     /* toggles on top, status below */
  align-items: stretch;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #f9fafb;
  border: 1px solid var(--border);
}

/* first row: toggles */
.arm-toggles {
  display: flex;
  gap: 10px;
  justify-content: flex-end;  /* keep toggles pinned to the right */
  align-items: center;
}

.arm-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}

.arm-toggle-label {
  color: var(--muted);
  font-weight: 600;
}

.arm-toggle-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.arm-toggle-slider {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #e5e7eb;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.05);
  transition: background-color .18s ease, box-shadow .18s ease;
}

.arm-toggle-slider::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  transition: transform .18s ease;
}

/* Checked state */
.arm-toggle-input:checked + .arm-toggle-slider {
  background: var(--accent-050);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.35);
}

.arm-toggle-input:checked + .arm-toggle-slider::before {
  transform: translateX(18px);
}

/* Disabled state of second toggle */
.arm-toggle-input:disabled + .arm-toggle-slider {
  opacity: .4;
  cursor: not-allowed;
}

/* second row: status text */
.arm-status {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  text-align: left;           /* left-aligned below toggles */
}

/* status colors */
.arm-status-locked {
  background: var(--red-light);
  color: var(--red-dark);
}

.arm-status-half {
  background: #fef3c7;
  color: #92400e;
}

.arm-status-armed {
  background: var(--green-light);
  color: var(--green-dark);
}

/* ==========================================================
   Armed destructive button (reusable)
   Use with: class="btn btn-important btn-danger-armed"
   JS adds/removes .armed and toggles disabled
   ========================================================== */

.btn-danger-armed {
  background-color: var(--red-light);
  color: #fff;
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-danger-armed.armed {
  background-color: var(--red);
  opacity: 1;
  cursor: pointer;
}

.btn-danger-armed.armed:hover {
  background-color: var(--red-dark);
}

.btn-danger-armed:disabled {
  pointer-events: none;
}
