/* =====================================================================
   qrodex – Ihr digitales Asset-Portal
   Farbwelt nach Flyer: Marineblau als Träger, kräftiges Blau als Akzent,
   Weiß als Fläche. Große Karten, weiche Radien, klare Typografie.
   Dark Mode über data-bs-theme="dark".
   ===================================================================== */

:root {
  --qx-navy:      #0b2a6b;   /* Kopf- und Fußband, Seitenleiste */
  --qx-navy-deep: #071d4d;   /* Verläufe, Tiefen */
  --qx-blue:      #1f6feb;   /* Akzent, Schaltflächen, „dex“ im Logo */
  --qx-blue-dark: #1858c4;
  --qx-green:     #48a548;   /* Zustimmung, „gratis testen“ */

  --ap-accent: var(--qx-blue);
  --ap-accent-soft: rgba(31, 111, 235, .1);
  --ap-sidebar-w: 250px;
  --ap-radius: 16px;
  --ap-shadow: 0 1px 2px rgba(7, 29, 77, .06), 0 8px 24px rgba(7, 29, 77, .08);
  --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

[data-bs-theme="light"] {
  --bs-body-bg: #f4f7fc;
  --bs-body-color: #16233c;
  --ap-surface: #ffffff;
  --ap-sidebar-bg: var(--qx-navy);
  --ap-sidebar-fg: rgba(255, 255, 255, .82);
  --ap-sidebar-border: rgba(255, 255, 255, .12);
  --ap-border: #e3e9f4;
}

[data-bs-theme="dark"] {
  --bs-body-bg: #0a1424;
  --bs-body-color: #e5ebf6;
  --ap-surface: #13203a;
  --ap-sidebar-bg: #071730;
  --ap-sidebar-fg: rgba(255, 255, 255, .78);
  --ap-sidebar-border: rgba(255, 255, 255, .1);
  --ap-border: #223353;
  --ap-shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .3);
  --ap-accent-soft: rgba(31, 111, 235, .2);
}

body {
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4 { font-weight: 650; letter-spacing: -.015em; }

.btn-primary {
  --bs-btn-bg: var(--ap-accent);
  --bs-btn-border-color: var(--ap-accent);
  --bs-btn-hover-bg: #1d4ed8;
  --bs-btn-hover-border-color: #1d4ed8;
}
.text-accent { color: var(--ap-accent) !important; }

/* --- Seitenleiste --------------------------------------------------- */
.ap-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--ap-sidebar-w);
  background: linear-gradient(180deg, var(--qx-navy) 0%, var(--qx-navy-deep) 100%);
  color: #fff;
  padding: 1.25rem 0.875rem;
  z-index: 1030;
}

.ap-brand {
  display: flex; align-items: center; gap: .7rem;
  padding: .25rem .5rem 1.25rem;
  text-decoration: none; color: inherit;
}
.ap-brand { color: #fff; }
.ap-brand small { display: block; font-size: .72rem; color: rgba(255, 255, 255, .6); }
.ap-wordmark { font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; color: #fff; }
.ap-wordmark span { color: #6ea8ff; }
.ap-brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: var(--qx-blue); color: #fff; font-size: 1.15rem;
}
.ap-brand-mark-lg { width: 56px; height: 56px; border-radius: 18px; font-size: 1.7rem; }

.ap-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.ap-nav-title {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .1em;
  color: rgba(255, 255, 255, .45); padding: 1.25rem .75rem .35rem;
}
.ap-nav-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .75rem; border-radius: 10px;
  color: var(--ap-sidebar-fg); text-decoration: none;
  font-size: .925rem; transition: background .12s ease, color .12s ease;
}
.ap-nav-link i { width: 1.2rem; text-align: center; color: rgba(255, 255, 255, .55); }
.ap-nav-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.ap-nav-link.active { background: var(--qx-blue); color: #fff; font-weight: 600; }
.ap-nav-link.active i { color: #fff; }

.ap-sidebar-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--ap-sidebar-border); }
.ap-user {
  display: flex; align-items: center; gap: .6rem; padding: .5rem;
  border-radius: 10px; text-decoration: none; color: #fff;
}
.ap-user:hover { background: rgba(255, 255, 255, .08); }
.ap-user small { display: block; font-size: .75rem; color: rgba(255, 255, 255, .55); }
.ap-sidebar .btn-outline-secondary {
  color: rgba(255, 255, 255, .8); border-color: rgba(255, 255, 255, .25);
}
.ap-sidebar .btn-outline-secondary:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.ap-sidebar .btn-link { color: rgba(255, 255, 255, .6) !important; }
.ap-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .16); color: #fff; font-weight: 700;
}
.ap-sidebar .ap-avatar { background: var(--qx-blue); }

/* --- Kopfzeile und Tableiste (Mobil) -------------------------------- */
.ap-topbar {
  position: sticky; top: 0; z-index: 1020;
  display: flex; align-items: center; gap: .5rem;
  padding: .6rem .9rem;
  padding-top: calc(.6rem + env(safe-area-inset-top));
  background: var(--qx-navy);
  color: #fff;
}
.ap-brand-sm { font-weight: 700; text-decoration: none; color: #fff; font-size: 1.1rem; }
.ap-brand-sm span { color: #6ea8ff; }
.ap-topbar .btn-icon { color: rgba(255, 255, 255, .85); }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 10px; }
.ap-dot {
  position: absolute; top: 5px; right: 6px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--bs-danger);
}

.ap-tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 1030;
  display: flex; justify-content: space-around;
  background: var(--ap-sidebar-bg);
  border-top: 1px solid var(--ap-border);
  padding-bottom: env(safe-area-inset-bottom);
}
.ap-tabbar a {
  flex: 1; text-align: center; padding: .5rem .25rem .4rem;
  color: var(--bs-secondary-color); text-decoration: none; font-size: .68rem;
}
.ap-tabbar a i { display: block; font-size: 1.25rem; margin-bottom: .1rem; }
.ap-tabbar a.active { color: var(--ap-accent); }
.ap-tab-scan i { color: var(--ap-accent); }

/* --- Hauptbereich ---------------------------------------------------- */
.ap-main {
  padding: 1.25rem;
  max-width: 1400px;
}
@media (min-width: 992px) {
  .ap-main { margin-left: var(--ap-sidebar-w); padding: 1.75rem 2rem 3rem; }
}
@media (max-width: 991.98px) {
  .ap-main { padding-bottom: 5.5rem; }
}

.ap-page-head {
  display: flex; flex-wrap: wrap; gap: .75rem;
  align-items: flex-start; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.ap-page-head h1 { font-size: 1.5rem; margin-bottom: .15rem; }
.ap-page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.ap-flash { position: sticky; top: 0; z-index: 1010; }
.ap-flash .alert { border: 0; border-radius: 12px; box-shadow: var(--ap-shadow); }

/* --- Karten ---------------------------------------------------------- */
.card {
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius);
  background: var(--ap-surface);
  box-shadow: var(--ap-shadow);
}
.card-header { background: transparent; border-bottom: 1px solid var(--ap-border); font-weight: 600; }

/* Kennzahlkacheln */
.ap-stat {
  display: block; text-decoration: none; color: inherit; height: 100%;
  padding: 1.1rem 1.2rem; border-radius: var(--ap-radius);
  background: var(--ap-surface); border: 1px solid var(--ap-border);
  box-shadow: var(--ap-shadow);
  transition: transform .12s ease, border-color .12s ease;
}
a.ap-stat:hover { transform: translateY(-2px); border-color: var(--ap-accent); }
.ap-stat-icon {
  width: 42px; height: 42px; border-radius: 12px; margin-bottom: .8rem;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem;
  background: var(--ap-accent-soft); color: var(--qx-blue);
}
.ap-stat-icon.tone-warn   { background: rgba(217, 145, 15, .12); color: #d9910f; }
.ap-stat-icon.tone-danger { background: rgba(214, 45, 45, .12);  color: #d62d2d; }
.ap-stat-icon.tone-ok     { background: rgba(72, 165, 72, .14);  color: var(--qx-green); }
.ap-stat-value { font-size: 1.95rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.ap-stat-value.is-danger { color: #d62d2d; }
.ap-stat-value.is-warn   { color: #d9910f; }
.ap-stat-label { color: var(--bs-secondary-color); font-size: .875rem; }

/* Asset-Kacheln */
.ap-asset-card { height: 100%; overflow: hidden; text-decoration: none; color: inherit; display: block; }
.ap-asset-card:hover { border-color: var(--ap-accent); }
.ap-asset-thumb {
  aspect-ratio: 16 / 10; background: var(--bs-tertiary-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: var(--bs-secondary-color); overflow: hidden;
}
.ap-asset-thumb img { width: 100%; height: 100%; object-fit: cover; }

.ap-meta { font-size: .8rem; color: var(--bs-secondary-color); }
.ap-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }

/* Zeitleiste der Historie */
.ap-timeline { list-style: none; margin: 0; padding: 0; }
.ap-timeline li { display: flex; gap: .8rem; padding: .55rem 0; min-width: 0; }
.ap-timeline li + li { border-top: 1px dashed var(--ap-border); }
/* Der Textblock muss schrumpfen dürfen, sonst schiebt langer Inhalt
   die Karte auseinander. min-width:0 hebt die Vorgabe von Flexbox auf,
   Inhalte nie unter ihre natürliche Breite zu stauchen. */
.ap-timeline li > div { min-width: 0; flex: 1 1 auto; }
.ap-timeline li > div > div { overflow-wrap: anywhere; }
.ap-timeline-icon {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bs-tertiary-bg); color: var(--bs-secondary-color); font-size: .85rem;
}

/* Ablagefläche für Uploads */
.ap-dropzone {
  border: 2px dashed var(--ap-border); border-radius: var(--ap-radius);
  padding: 1.75rem 1rem; text-align: center; color: var(--bs-secondary-color);
  transition: border-color .12s ease, background .12s ease; cursor: pointer;
}
.ap-dropzone:hover, .ap-dropzone.is-over { border-color: var(--ap-accent); background: var(--ap-accent-soft); }

/* Etikettenbogen */
.ap-labels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4mm; }
.ap-label {
  border: 1px solid #d5dae2; border-radius: 4px; padding: 3mm;
  display: flex; gap: 3mm; align-items: center; break-inside: avoid; height: 32mm;
}
.ap-label svg { width: 24mm; height: 24mm; flex: none; }
.ap-label-text { font-size: 8pt; line-height: 1.25; overflow: hidden; }
.ap-label-text strong { display: block; font-size: 9pt; }

/* Anmeldung */
.ap-auth-body { display: grid; place-items: center; min-height: 100dvh; padding: 1.25rem; }
.ap-auth-wrap { width: 100%; max-width: 26rem; }
.ap-auth-card { border-radius: 20px; }
.ap-error-code { font-size: 3.5rem; font-weight: 700; color: var(--ap-accent); line-height: 1; }

/* Scanner */
#ap-scanner-video {
  width: 100%; max-height: 60vh; border-radius: var(--ap-radius);
  background: #000; object-fit: cover;
}

/* Lange Wörter, Inventarnummern und Dateinamen dürfen die Karte nicht
   sprengen – sie brechen stattdessen um. */
.card-body, .list-group-item { overflow-wrap: anywhere; }
.min-w-0 { min-width: 0; }
dd, .ap-meta { overflow-wrap: anywhere; }

/* Bedienbarkeit */
:focus-visible { outline: 3px solid var(--ap-accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Tabellen */
.table { --bs-table-bg: transparent; }
.table > :not(caption) > * > * { padding: .7rem .75rem; }
.ap-table-wrap { overflow-x: auto; }


/* --- Ergänzungen für den Arbeitsschutz-Bereich ----------------------- */
.qx-hero {
  background: linear-gradient(120deg, var(--qx-navy) 0%, var(--qx-blue) 130%);
  color: #fff; border-radius: var(--ap-radius); padding: 1.35rem 1.5rem;
  margin-bottom: 1.25rem;
}
.qx-hero h1 { font-size: 1.45rem; margin-bottom: .2rem; }
.qx-hero p { color: rgba(255, 255, 255, .78); margin-bottom: 0; font-size: .925rem; }
.qx-hero .btn-light { color: var(--qx-navy); font-weight: 600; }

.qx-legend { list-style: none; margin: 0; padding: 0; font-size: .875rem; }
.qx-legend li { display: flex; align-items: center; gap: .55rem; padding: .3rem 0; }
.qx-legend .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.qx-legend .val { margin-left: auto; color: var(--bs-secondary-color); font-variant-numeric: tabular-nums; }

.qx-status { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 600; }
.qx-status .dot { width: 8px; height: 8px; border-radius: 50%; }

.qx-bg-row { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; }
.qx-bg-row + .qx-bg-row { border-top: 1px dashed var(--ap-border); }
.qx-bg-icon {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ap-accent-soft); color: var(--qx-blue);
}


/* --- Anhänge an Wissenseinträgen und Wartungen ---------------------- */
.qx-attachments {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
  margin: .6rem 0 .3rem;
}
.qx-thumb {
  display: block; width: 68px; height: 68px; border-radius: 10px;
  overflow: hidden; border: 1px solid var(--ap-border); flex: none;
}
.qx-thumb img { width: 100%; height: 100%; object-fit: cover; }
.qx-doc {
  display: inline-flex; align-items: center; gap: .4rem; max-width: 18rem;
  padding: .35rem .6rem; border-radius: 10px; text-decoration: none;
  border: 1px solid var(--ap-border); background: var(--bs-tertiary-bg);
  color: var(--bs-body-color); font-size: .85rem;
}
.qx-doc:hover { border-color: var(--qx-blue); }
.qx-doc i { color: var(--bs-secondary-color); }

.qx-attach-form { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.qx-attach-label {
  display: inline-flex; align-items: center; gap: .35rem; cursor: pointer;
  font-size: .82rem; color: var(--qx-blue); padding: .25rem .5rem;
  border: 1px dashed var(--ap-border); border-radius: 8px;
}
.qx-attach-label:hover { border-color: var(--qx-blue); background: var(--ap-accent-soft); }
