/* =====================================================================
   AssetPortal – Oberfläche
   Weiß, Dunkelgrau, Blau als Akzent. Große Karten, weiche Radien,
   klare Typografie. Dark Mode über data-bs-theme="dark".
   ===================================================================== */

:root {
  --ap-accent: #2563eb;
  --ap-accent-soft: rgba(37, 99, 235, .1);
  --ap-sidebar-w: 250px;
  --ap-radius: 16px;
  --ap-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

[data-bs-theme="light"] {
  --bs-body-bg: #f5f7fa;
  --bs-body-color: #1f2937;
  --ap-surface: #ffffff;
  --ap-sidebar-bg: #ffffff;
  --ap-border: #e6eaf0;
}

[data-bs-theme="dark"] {
  --bs-body-bg: #0f1622;
  --bs-body-color: #e5e9f0;
  --ap-surface: #182233;
  --ap-sidebar-bg: #131c2b;
  --ap-border: #26334a;
  --ap-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --ap-accent-soft: rgba(59, 130, 246, .16);
}

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: var(--ap-sidebar-bg);
  border-right: 1px solid var(--ap-border);
  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 small { display: block; font-size: .75rem; color: var(--bs-secondary-color); }
.ap-brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  background: var(--ap-accent); 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: .7rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--bs-secondary-color); padding: 1.25rem .75rem .35rem;
}
.ap-nav-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .75rem; border-radius: 10px;
  color: var(--bs-body-color); text-decoration: none;
  font-size: .925rem; transition: background .12s ease;
}
.ap-nav-link i { width: 1.2rem; text-align: center; color: var(--bs-secondary-color); }
.ap-nav-link:hover { background: var(--bs-tertiary-bg); }
.ap-nav-link.active { background: var(--ap-accent-soft); color: var(--ap-accent); font-weight: 600; }
.ap-nav-link.active i { color: var(--ap-accent); }

.ap-sidebar-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--ap-border); }
.ap-user {
  display: flex; align-items: center; gap: .6rem; padding: .5rem;
  border-radius: 10px; text-decoration: none; color: inherit;
}
.ap-user:hover { background: var(--bs-tertiary-bg); }
.ap-user small { display: block; font-size: .75rem; color: var(--bs-secondary-color); }
.ap-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ap-accent-soft); color: var(--ap-accent); font-weight: 700;
}

/* --- 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(--ap-sidebar-bg);
  border-bottom: 1px solid var(--ap-border);
}
.ap-brand-sm { font-weight: 700; text-decoration: none; color: inherit; }
.ap-brand-sm i { color: var(--ap-accent); }
.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: 40px; height: 40px; border-radius: 12px; margin-bottom: .8rem;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem;
  background: var(--ap-accent-soft); color: var(--ap-accent);
}
.ap-stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.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; }
.ap-timeline li + li { border-top: 1px dashed var(--ap-border); }
.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;
}

/* 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; }
