/* ------------------------------------------------------------------
   AssetMind — Styles
   Farb-/Mark-Spezifikation nach dataviz-Skill-Referenzpalette.
   ------------------------------------------------------------------ */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --page:            #0d0d0d;
  --surface-1:        #1a1a19;
  --surface-2:        #232322;
  --text-primary:    #ffffff;
  --text-secondary:  #c3c2b7;
  --muted:           #898781;
  --grid:            #2c2c2a;
  --baseline:        #383835;
  --border:          rgba(255,255,255,0.10);

  --series-1: #3987e5; /* blue   */
  --series-2: #d95926; /* orange */
  --series-3: #199e70; /* aqua   */
  --series-4: #c98500; /* yellow */
  --series-5: #d55181; /* magenta*/
  --series-6: #008300; /* green  */
  --series-7: #9085e9; /* violet */
  --series-8: #e66767; /* red    */

  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #d03b3b;
  --delta-good:      #0ca30c;
}

:root[data-theme="light"] {
  color-scheme: light;
  --page:            #f9f9f7;
  --surface-1:        #fcfcfb;
  --surface-2:        #f3f2ee;
  --text-primary:    #0b0b0b;
  --text-secondary:  #52514e;
  --muted:           #898781;
  --grid:            #e1e0d9;
  --baseline:        #c3c2b7;
  --border:          rgba(11,11,11,0.10);

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;

  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #d03b3b;
  --delta-good:      #006300;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  min-height: 100vh;
}
button, input, select, textarea { font-family: inherit; font-size: 14px; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }
h1, h2, h3, h4 { margin: 0 0 4px; font-weight: 600; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

.muted { color: var(--text-secondary); }
.muted.small, .small { font-size: 12.5px; }

/* ---------------------------- Layout ---------------------------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { display: block; font-size: 16px; }
.brand .tagline { display: block; font-size: 11.5px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: none; border-radius: 8px;
  padding: 10px 12px; text-align: left; color: var(--text-secondary);
  font-size: 14px; font-weight: 500;
}
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-item.active { background: color-mix(in srgb, var(--series-1) 18%, transparent); color: var(--text-primary); }

.sidebar-stats { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }
.sidebar-stat {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12.5px; color: var(--text-secondary);
  padding: 6px 10px; border-radius: 6px; background: var(--surface-2);
}
.sidebar-stat b { color: var(--text-primary); font-weight: 600; }
.sidebar-stat.alert b { color: var(--status-critical); }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 12px; }
.theme-toggle {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px; font-size: 13px; color: var(--text-primary);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: var(--surface-1);
}
.topbar-search { flex: 1; }
.topbar-search input {
  width: 100%; max-width: 480px; padding: 9px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-primary);
}
.topbar-actions { display: flex; gap: 10px; }

.btn {
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-primary); font-weight: 500;
}
.btn:hover { filter: brightness(1.1); }
.btn-primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.btn-ghost { background: transparent; }

.view-root { flex: 1; overflow-y: auto; padding: 24px 28px 48px; }

.view-header { margin-bottom: 20px; }
.view-header h1 { font-size: 22px; }

/* ---------------------------- Cards / KPIs ---------------------------- */

.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px;
}

.kpi-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 24px; }
.kpi-tile {
  flex: 1; min-width: 150px; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px;
}
.kpi-label { font-size: 12.5px; color: var(--text-secondary); }
.kpi-value { font-size: 30px; font-weight: 600; font-variant-numeric: proportional-nums; }
.kpi-tile.kpi-critical .kpi-value { color: var(--status-critical); }
.kpi-tile.kpi-warning .kpi-value { color: var(--status-warning); }

.chart-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 24px; }
.chart-card h3 { font-size: 14px; margin-bottom: 12px; }
.chart-flex { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }

.chart-hero { fill: var(--text-primary); font-size: 22px; font-weight: 600; }
.chart-sub { fill: var(--muted); font-size: 10px; }
.chart-value { fill: var(--text-secondary); font-size: 10px; font-weight: 600; }
.chart-axis { fill: var(--muted); font-size: 10px; }

.legend { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.legend-label { color: var(--text-secondary); flex: 1; }
.legend-value { font-weight: 600; }
.legend-pct { color: var(--muted); width: 36px; text-align: right; }

.list-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.mini-list { display: flex; flex-direction: column; gap: 2px; }
.mini-list li {
  display: flex; align-items: center; gap: 8px; padding: 8px 6px;
  border-radius: 6px; cursor: pointer; font-size: 12.5px;
}
.mini-list li:hover { background: var(--surface-2); }
.mini-name { font-weight: 500; flex: 1; }
.mini-meta, .mini-date { color: var(--muted); white-space: nowrap; }

/* ---------------------------- Badges ---------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-secondary);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--muted)); }
.typ-badge { color: var(--text-secondary); }

/* ---------------------------- Objekte / Filter ---------------------------- */

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.filter-bar select {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-1); color: var(--text-primary);
}

.object-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.object-card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; cursor: pointer; transition: transform .12s ease, border-color .12s ease;
  display: flex; flex-direction: column; gap: 10px;
}
.object-card:hover { transform: translateY(-2px); border-color: var(--series-1); }
.object-card-top { display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.object-card h3 { font-size: 15px; }
.object-card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

/* ---------------------------- Formular ---------------------------- */

.form-card { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.form-grid label, .full-width { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-secondary); }
.full-width { grid-column: 1 / -1; }
input, select, textarea {
  padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-primary); font-size: 13.5px;
}
textarea { resize: vertical; font-family: inherit; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------------------------- Detail Panel (Slide-over) ---------------------------- */

.overlay {
  position: fixed; inset: 0; display: flex; justify-content: flex-end;
  z-index: 60; opacity: 1; visibility: visible; transition: opacity .2s ease;
}
.overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.overlay-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.detail-panel {
  position: relative; width: 480px; max-width: 92vw; height: 100%;
  background: var(--surface-1); border-left: 1px solid var(--border);
  padding: 24px; overflow-y: auto; transform: translateX(0);
  transition: transform .25s ease; box-shadow: -8px 0 30px rgba(0,0,0,0.3);
}
.overlay.hidden .detail-panel { transform: translateX(24px); }

.detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.detail-header h2 { font-size: 18px; margin: 6px 0 2px; }
.icon-btn {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  width: 32px; height: 32px; flex-shrink: 0; color: var(--text-secondary);
}
.detail-badges { display: flex; gap: 8px; margin-bottom: 16px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab-btn {
  background: transparent; border: none; padding: 10px 12px; font-size: 13px;
  color: var(--text-secondary); border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab-btn.active { color: var(--text-primary); border-bottom-color: var(--series-1); }

.description { color: var(--text-secondary); margin-bottom: 16px; line-height: 1.5; }
.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 16px; font-size: 13px; }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tag { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 11.5px; color: var(--text-secondary); }

.meter-block { margin-bottom: 20px; }
.meter-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }

.quick-edit { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.quick-edit label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-secondary); }

.note-form { display: flex; gap: 8px; margin-bottom: 18px; }
.note-form textarea, .note-form input { flex: 1; }

.timeline { display: flex; flex-direction: column; gap: 10px; }
.timeline li { display: flex; gap: 10px; font-size: 13px; padding-bottom: 10px; border-bottom: 1px dashed var(--grid); }
.timeline li:last-child { border-bottom: none; }
.timeline-date { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.timeline li.note span:last-child { color: var(--text-secondary); }

.doc-list li { padding: 8px 0; font-size: 13.5px; border-bottom: 1px dashed var(--grid); }
.doc-list li:last-child { border-bottom: none; }

/* ---------------------------- Chat ---------------------------- */

.chat-box { display: flex; flex-direction: column; gap: 10px; height: 100%; }
.chat-messages {
  display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto;
  padding: 4px 2px;
}
.chat-msg {
  max-width: 85%; padding: 9px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.45;
}
.chat-msg.bot { align-self: flex-start; background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--border); }
.chat-msg.user { align-self: flex-end; background: var(--series-1); color: #fff; }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row input { flex: 1; }
.chat-suggestions { display: flex; gap: 6px; flex-wrap: wrap; }
.chat-suggestions button {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 11px; font-size: 12px; color: var(--text-secondary);
}
.chat-suggestions button:hover { color: var(--text-primary); border-color: var(--series-1); }

/* ---------------------------- Globaler Assistent (Drawer) ---------------------------- */

.assistant-drawer {
  position: fixed; bottom: 92px; right: 24px; width: 380px; height: 540px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.35); z-index: 70;
  display: flex; flex-direction: column; padding: 16px;
  opacity: 1; visibility: visible; transform: translateY(0);
  transition: opacity .2s ease, transform .2s ease;
}
.assistant-drawer.hidden { opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(12px); }
.assistant-header { display: flex; justify-content: space-between; align-items: center; font-weight: 600; margin-bottom: 10px; }
.assistant-drawer .chat-messages { flex: 1; }

.assistant-fab {
  position: fixed; bottom: 24px; right: 24px; width: 56px; height: 56px; border-radius: 50%;
  background: var(--series-1); color: #fff; border: none; font-size: 22px; z-index: 65;
  box-shadow: 0 10px 24px rgba(0,0,0,0.35);
}
.assistant-fab:hover { filter: brightness(1.08); }

/* ---------------------------- Toasts ---------------------------- */

.toast-root {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 80; align-items: center;
}
.toast {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-primary);
  padding: 10px 18px; border-radius: 999px; font-size: 13px; opacity: 0; transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease; box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------------------------- Responsive ---------------------------- */

@media (max-width: 980px) {
  .chart-grid { grid-template-columns: 1fr; }
  .list-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .sidebar-stats { display: none; }
  .main { height: auto; }
  .view-root { overflow-y: visible; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-panel { width: 100%; }
  .assistant-drawer { width: calc(100vw - 24px); right: 12px; left: 12px; }
}
