/* ============================================================
   Inventarsystem v2 – Design System
   Mobile-First | Bootstrap 5 Override
   ============================================================ */

/* ── Custom Properties ──────────────────────────────────────── */
:root {
  --sidebar-width:        260px;
  --sidebar-bg:           #0f172a;
  --sidebar-hover:        #1e293b;
  --sidebar-active:       rgba(99,102,241,.15);
  --sidebar-text:         #94a3b8;
  --sidebar-text-active:  #ffffff;

  --primary:              #6366f1;
  --primary-dark:         #4f46e5;
  --primary-light:        #eef2ff;

  --success:              #10b981;
  --warning:              #f59e0b;
  --danger:               #ef4444;
  --info:                 #3b82f6;

  --bg:                   #f1f5f9;
  --card-bg:              #ffffff;
  --border:               #e2e8f0;
  --text:                 #1e293b;
  --text-muted:           #64748b;

  --radius:               12px;
  --radius-sm:            8px;
  --shadow:               0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:            0 4px 12px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.05);

  --transition:           .18s ease;
  --navbar-height:        60px;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

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

/* ── Layout ─────────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  text-decoration: none;
}

.sidebar-brand-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sidebar-brand-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: 0.68rem;
  color: var(--sidebar-text);
  display: block;
  font-weight: 400;
}

.sidebar-nav {
  padding: 10px 0;
  flex: 1;
}

.nav-section-label {
  padding: 14px 20px 5px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: rgba(148,163,184,.45);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.nav-item i { font-size: 1rem; flex-shrink: 0; width: 18px; text-align: center; }

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
  border-left-color: transparent;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  border-left-color: var(--primary);
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: 0.72rem;
  color: rgba(148,163,184,.5);
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 999;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ── Main Content ────────────────────────────────────────────── */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content {
  flex: 1;
  padding: 28px 28px 52px;
  max-width: 1400px;
}

/* ── Top Navbar (mobile) ─────────────────────────────────────── */
.top-navbar {
  display: none;
  align-items: center;
  gap: 12px;
  height: var(--navbar-height);
  padding: 0 16px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.btn-hamburger {
  background: none; border: none;
  font-size: 1.5rem; cursor: pointer;
  color: var(--text);
  padding: 2px; display: flex; align-items: center;
  flex-shrink: 0;
}

.top-navbar-brand { font-weight: 700; font-size: 1rem; color: var(--text); }

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.page-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.page-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 3px 0 0;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fafafa;
}

.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  display: flex; align-items: center; gap: 7px;
}

.card-body { padding: 20px; }

/* ── Stat Cards (Dashboard) ──────────────────────────────────── */
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow var(--transition), transform var(--transition);
  text-decoration: none;
  color: inherit;
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); color: inherit; }

.stat-icon {
  width: 50px; height: 50px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem; flex-shrink: 0;
}

.stat-icon.indigo  { background: #eef2ff; color: var(--primary); }
.stat-icon.green   { background: #d1fae5; color: var(--success); }
.stat-icon.amber   { background: #fef3c7; color: var(--warning); }
.stat-icon.blue    { background: #dbeafe; color: var(--info); }
.stat-icon.gray    { background: #f1f5f9; color: var(--text-muted); }

.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 3px; }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table {
  width: 100%; border-collapse: collapse;
  font-size: 0.875rem;
}

.table th {
  padding: 11px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}

.table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr[data-href] { cursor: pointer; }

.table-actions { display: flex; gap: 5px; justify-content: flex-end; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600; white-space: nowrap;
}

.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none; white-space: nowrap;
  font-family: inherit;
  line-height: 1.4;
}

.btn-primary   { background: var(--primary);  color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #f8fafc; color: var(--text); }

.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #059669; color: #fff; }

.btn-outline-primary {
  background: transparent; color: var(--primary);
  border-color: var(--primary);
}
.btn-outline-primary:hover { background: var(--primary); color: #fff; }

.btn-sm { padding: 5px 11px; font-size: 0.8125rem; }
.btn-lg { padding: 11px 22px; font-size: 1rem; }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #fff; color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.875rem;
  text-decoration: none; flex-shrink: 0;
}
.btn-icon:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-icon.danger:hover { border-color: var(--danger); color: var(--danger); background: #fef2f2; }
.btn-icon.success:hover { border-color: var(--success); color: var(--success); background: #d1fae5; }
.btn-icon.warning:hover { border-color: var(--warning); color: var(--warning); background: #fef3c7; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-label {
  display: block; font-size: 0.8125rem; font-weight: 600;
  color: var(--text); margin-bottom: 5px;
}

.form-label .req { color: var(--danger); margin-left: 2px; }

.form-control, .form-select {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem; color: var(--text);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none; font-family: inherit;
  appearance: auto;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}

.form-control::placeholder { color: #cbd5e1; }
textarea.form-control { resize: vertical; min-height: 88px; }
.form-text { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.form-group { margin-bottom: 18px; }

/* Color picker */
.color-preview {
  display: inline-block; width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  vertical-align: middle;
}

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 0.875rem;
  border: 1px solid transparent;
}

.alert i { flex-shrink: 0; font-size: 1rem; margin-top: 1px; }
.alert-success { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.alert-error,
.alert-danger   { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.alert-warning  { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.alert-info     { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }

.alert-close {
  margin-left: auto; background: none; border: none;
  cursor: pointer; opacity: .4; font-size: 1rem;
  padding: 0; color: inherit; flex-shrink: 0;
}
.alert-close:hover { opacity: 1; }

/* ── Filter Bar ──────────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}

.search-wrap { position: relative; flex: 1; min-width: 180px; max-width: 300px; }
.search-wrap i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-wrap .form-control { padding-left: 33px; }

.filter-bar .form-select { max-width: 190px; }

.filter-count {
  font-size: 0.8rem; color: var(--text-muted);
  margin-left: auto; white-space: nowrap;
}

/* ── Bulk-Erfassung ──────────────────────────────────────────── */
.bulk-header {
  display: grid;
  grid-template-columns: 1fr 1fr 30px;
  gap: 8px;
  padding: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.bulk-entry-row {
  display: grid;
  grid-template-columns: 1fr 1fr 30px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  animation: fadeSlide .12s ease;
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

#bulkTextareaWrap { margin-top: 12px; }

/* ── Detail View ─────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}

.detail-item {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.detail-item:nth-child(odd) { border-right: 1px solid var(--border); }
.detail-item:last-child:nth-child(odd) { border-right: none; }

.detail-label {
  font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); margin-bottom: 4px;
}

.detail-value { font-size: 0.9375rem; color: var(--text); font-weight: 500; }
.detail-value.empty { color: var(--text-muted); font-style: italic; font-weight: 400; }

/* ── Inventarnummer ──────────────────────────────────────────── */
.inv-nr {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.82rem;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 5px; font-weight: 600;
  white-space: nowrap;
}

/* ── Status-Timeline ─────────────────────────────────────────── */
.timeline { padding: 4px 0; }

.timeline-item {
  display: flex; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.timeline-item:last-child { border-bottom: none; }

.timeline-dot {
  width: 10px; height: 10px; border-radius: 50%;
  margin-top: 5px; flex-shrink: 0;
}

.timeline-time { font-size: 0.75rem; color: var(--text-muted); }

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 56px 20px; color: var(--text-muted);
}
.empty-state i { font-size: 2.8rem; opacity: .25; display: block; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; margin: 0; }

/* ── Status Distribution Bar ─────────────────────────────────── */
.dist-bar {
  height: 6px; border-radius: 3px;
  background: var(--border); overflow: hidden;
  display: flex; margin-top: 4px;
}
.dist-segment { height: 100%; transition: width .5s ease; }

/* ── Icon Select (Gerätetypen) ───────────────────────────────── */
.icon-preview { font-size: 1.3rem; color: var(--primary); }

/* ── Utility ─────────────────────────────────────────────────── */
.text-muted   { color: var(--text-muted) !important; }
.text-primary { color: var(--primary)    !important; }
.fw-600       { font-weight: 600; }
.fw-700       { font-weight: 700; }
.d-flex       { display: flex; }
.d-none       { display: none !important; }
.gap-1        { gap: 4px; }
.gap-2        { gap: 8px; }
.gap-3        { gap: 12px; }
.gap-4        { gap: 16px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap    { flex-wrap: wrap; }
.w-100        { width: 100%; }
.ms-auto      { margin-left: auto; }
.mt-3         { margin-top: 12px; }
.mt-4         { margin-top: 16px; }
.mb-3         { margin-bottom: 12px; }
.mb-4         { margin-bottom: 16px; }
.mb-0         { margin-bottom: 0; }
.p-0          { padding: 0; }

/* ── Grid helpers ────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-width))); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.3); }

  .main-wrapper { margin-left: 0; }
  .top-navbar { display: flex; }

  .content { padding: 16px 16px 44px; }

  .page-header { flex-direction: column; align-items: flex-start; }

  .filter-bar { flex-direction: column; align-items: stretch; padding: 12px 16px; }
  .filter-bar .form-control,
  .filter-bar .form-select,
  .search-wrap { max-width: 100%; }
  .filter-count { margin-left: 0; }

  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  .detail-grid { grid-template-columns: 1fr; }
  .detail-item:nth-child(odd) { border-right: none; }

  .bulk-entry-row { grid-template-columns: 1fr 1fr 30px; }
  .bulk-header    { grid-template-columns: 1fr 1fr 30px; }

  .table-actions { gap: 4px; }
}

@media (max-width: 480px) {
  .page-title { font-size: 1.2rem; }
  .bulk-entry-row { grid-template-columns: 1fr; }
  .bulk-header    { display: none; }
  .btn-icon { width: 34px; height: 34px; }
}

/* ── Bulk-Aktionsleiste ───────────────────────────────────────── */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--primary);
  color: #fff;
  border-top: 1px solid var(--border);
}

.bulk-bar .form-select,
.bulk-bar .form-control {
  background: rgba(255,255,255,.15);
  border-color: rgba(255,255,255,.3);
  color: #fff;
}

.bulk-bar .form-select option { background: #1e293b; color: #fff; }

.bulk-count {
  font-weight: 700;
  font-size: .875rem;
  white-space: nowrap;
}

.form-check-input {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* ── Print ───────────────────────────────────────────────────── */
@media print {
  .sidebar, .top-navbar, .btn, .filter-bar,
  .page-header .d-flex, .table-actions { display: none !important; }
  .main-wrapper { margin-left: 0; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
