/**
 * Vorratsmanager – Stylesheet
 * 
 * Aufbau:
 *  1. CSS-Variablen (Farben, Abstände)
 *  2. Reset & Basis
 *  3. Layout (Header, Content, Navigation)
 *  4. Komponenten (Cards, Buttons, Inputs, Badges)
 *  5. Views (Dashboard, Regal, Produkte, Inventur, Einkauf)
 *  6. Modal
 *  7. Login
 *  8. Responsive
 */

/* ═══════════════════════════════════════════════
   1. CSS-VARIABLEN
   ═══════════════════════════════════════════════ */
:root {
  --bg:           #FAF6F0;
  --card:         #FFFFFF;
  --card-border:  #E8E0D4;
  --text:         #2C2416;
  --text-muted:   #8B7D6B;
  --accent:       #D4890E;
  --accent-light: #FFF3E0;
  --success:      #2D8A4E;
  --success-light:#E8F5E9;
  --warn:         #D4890E;
  --warn-light:   #FFF3E0;
  --danger:       #C0392B;
  --danger-light: #FDEAEA;
  --shelf-light:  #B8A580;
  --shelf-dark:   #A89470;
  --shadow:       0 2px 12px rgba(44,36,22,0.08);
  --radius:       14px;
  --radius-sm:    10px;
  --font:         'Outfit', 'Segoe UI', system-ui, sans-serif;
}

/* ═══════════════════════════════════════════════
   2. RESET & BASIS
   ═══════════════════════════════════════════════ */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overscroll-behavior: none;
  line-height: 1.4;
}
input, select, button, textarea { font-family: inherit; }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--shelf-light); border-radius: 4px; }

/* ═══════════════════════════════════════════════
   3. LAYOUT
   ═══════════════════════════════════════════════ */
#app { display: flex; flex-direction: column; min-height: 100vh; }

.header {
  background: linear-gradient(135deg, #3B2F1E 0%, #5C4A32 100%);
  color: #FFF;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-title { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; }
.header-sub { font-size: 11px; opacity: 0.7; margin-top: 2px; }
.header-btn {
  background: rgba(255,255,255,0.15);
  border: none; border-radius: var(--radius-sm);
  padding: 8px 12px; color: #FFF;
  cursor: pointer; font-size: 16px;
}

.content {
  flex: 1;
  padding: 16px;
  padding-bottom: 80px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #FFF;
  border-top: 3px solid var(--card-border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 env(safe-area-inset-bottom, 12px);
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.10);
}
.nav-item {
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 4px 10px;
  color: var(--text-muted);
  font-size: 13px; font-weight: 500;
  transition: all 0.2s;
}
.nav-item.active { color: var(--accent); font-weight: 700; }
.nav-item .nav-icon { width: 34px; height: 34px; line-height: 1; display: block; }
.nav-item .nav-icon svg { width: 100%; height: 100%; }

/* ═══════════════════════════════════════════════
   4. KOMPONENTEN
   ═══════════════════════════════════════════════ */

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card--warning { border-left: 4px solid var(--danger); }
.card--info { border-left: 4px solid var(--warn); }
.card--muted { border-left: 4px solid var(--text-muted); }
.card--highlight { background: var(--accent-light); }

/* Buttons */
.btn {
  border: none; border-radius: var(--radius-sm);
  padding: 10px 20px; font-weight: 600;
  cursor: pointer; font-size: 14px;
  transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--accent); color: #FFF; }
.btn--secondary {
  background: transparent; color: var(--accent);
  border: 2px solid var(--accent);
}
.btn--danger { background: var(--danger); color: #FFF; }
.btn--danger-outline {
  background: transparent; color: var(--danger);
  border: 2px solid var(--danger);
}
.btn--success { background: var(--success); color: #FFF; }
.btn--small { padding: 5px 12px; font-size: 12px; }
.btn--full { width: 100%; }
.btn--icon {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: none; font-size: 20px; font-weight: 700;
  cursor: pointer; display: flex;
  align-items: center; justify-content: center;
}
.btn--icon-plus { background: var(--accent-light); color: var(--accent); }
.btn--icon-minus { background: var(--danger-light); color: var(--danger); }
.btn--icon-round {
  width: 56px; height: 56px; border-radius: 50%;
  font-size: 28px; font-weight: 800;
}

/* Inputs */
.input {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  font-size: 14px; background: var(--bg);
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.input--search { padding-left: 36px; }
.input--center { text-align: center; font-size: 18px; font-weight: 700; max-width: 120px; margin: 0 auto; }

.form-label { font-size: 12px; color: var(--text-muted); font-weight: 600; display: block; margin-bottom: 4px; }
.form-group { margin-bottom: 12px; }
.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; }

/* Badges */
.badge {
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge--danger { background: rgba(192,57,43,0.12); color: var(--danger); }
.badge--warn { background: rgba(212,137,14,0.12); color: var(--warn); }
.badge--success { background: rgba(45,138,78,0.12); color: var(--success); }

/* Stock Bar */
.stock-bar {
  width: 100%; background: #EDE8DF;
  border-radius: 6px; height: 10px; overflow: hidden;
}
.stock-bar--small { height: 6px; }
.stock-bar__fill {
  height: 100%; border-radius: 6px;
  transition: width 0.4s ease;
}

/* Category filter pills */
.filter-pills {
  display: flex; gap: 6px;
  overflow-x: auto; padding-bottom: 8px;
  margin-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}
.pill {
  padding: 5px 12px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; white-space: nowrap;
  border: 2px solid; cursor: pointer; background: transparent;
  transition: all 0.2s;
}
.pill.active { color: #FFF !important; }

/* ═══════════════════════════════════════════════
   5. VIEW-SPEZIFISCH
   ═══════════════════════════════════════════════ */

/* Dashboard Stat Grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.stat-card { text-align: center; padding: 14px 10px; }
.stat-icon { font-size: 24px; margin-bottom: 4px; }
.stat-value { font-size: 26px; font-weight: 800; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* Product list item */
.product-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; cursor: pointer;
}
.product-indicator {
  width: 6px; height: 48px;
  border-radius: 3px; flex-shrink: 0;
}
.product-info { flex: 1; min-width: 0; }
.product-name {
  font-weight: 600; font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.product-meta { font-size: 12px; color: var(--text-muted); }
.product-location { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.stock-count { font-weight: 800; font-size: 18px; min-width: 28px; text-align: center; }

/* Shelf visual */
.shelf-cabinet {
  background: linear-gradient(180deg, var(--shelf-light) 0%, var(--shelf-dark) 100%);
  border-radius: var(--radius); padding: 6px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.15), 0 4px 16px rgba(0,0,0,0.1);
}
.shelf-compartment {
  background: linear-gradient(180deg, #FAF6F0 0%, #F0EAE0 100%);
  border-radius: 8px; margin: 4px;
  min-height: 68px; padding: 8px 10px;
  cursor: pointer;
}
.shelf-label {
  font-size: 11px; color: var(--text-muted);
  font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px;
}
.shelf-divider {
  height: 6px; margin: 0 4px;
  background: linear-gradient(180deg, #9B8660 0%, var(--shelf-light) 100%);
  border-radius: 3px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.shelf-item {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 8px; padding: 4px 8px;
  font-size: 11px; font-weight: 600;
  border: 1px solid;
}
.shelf-item-name {
  max-width: 90px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}

/* Inventory */
.inventory-counter { font-size: 48px; font-weight: 800; }
.inventory-label { font-size: 12px; color: var(--text-muted); }

/* Shopping list */
.shopping-check {
  width: 24px; height: 24px; border-radius: 7px;
  flex-shrink: 0; border: 2px solid var(--card-border);
  display: flex; align-items: center; justify-content: center;
  color: #FFF; font-size: 14px;
}
.shopping-check.checked {
  border-color: var(--success);
  background: var(--success);
}
.shopping-item.checked { opacity: 0.5; text-decoration: line-through; }

/* ═══════════════════════════════════════════════
   6. MODAL
   ═══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
}
.modal-content {
  position: relative; background: #FFF;
  border-radius: 18px; padding: 24px;
  max-width: 460px; width: 100%;
  max-height: 85vh; overflow: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 20px;
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close {
  background: none; border: none;
  font-size: 24px; cursor: pointer;
  color: var(--text-muted); line-height: 1;
}

/* ═══════════════════════════════════════════════
   7. LOGIN
   ═══════════════════════════════════════════════ */
.login-container {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #3B2F1E 0%, #5C4A32 50%, #3B2F1E 100%);
}
.login-box {
  background: #FFF;
  border-radius: 20px; padding: 40px;
  max-width: 380px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center;
}
.login-icon { font-size: 48px; margin-bottom: 12px; }
.login-title { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.login-error {
  background: var(--danger-light); color: var(--danger);
  padding: 10px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 12px;
}

/* ═══════════════════════════════════════════════
   8. HELFER
   ═══════════════════════════════════════════════ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-12 { gap: 12px; }
.gap-20 { gap: 20px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-6 { margin-bottom: 6px; }
.mb-8 { margin-bottom: 8px; }
.mb-10 { margin-bottom: 10px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-bold { font-weight: 700; }
.hidden { display: none !important; }
.empty-hint { font-size: 12px; color: var(--text-muted); font-style: italic; }
.section-title {
  margin: 16px 0 8px; font-size: 14px;
  display: flex; align-items: center; gap: 6px;
}
.divider { border: none; border-top: 1px solid var(--card-border); margin: 12px 0; }
.loading { text-align: center; padding: 40px; color: var(--text-muted); }

/* ═══════════════════════════════════════════════
   9. RESPONSIVE
   ═══════════════════════════════════════════════ */
@media (display-mode: standalone) {
  body { padding-top: env(safe-area-inset-top); }
}
@media (max-width: 400px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 12px; padding-bottom: 80px; }
}

/* Quick Edit Scrollbereich */
#quick-list::-webkit-scrollbar { width: 3px; }
#quick-list::-webkit-scrollbar-thumb { background: var(--shelf-light); border-radius: 3px; }

/* SVG Icons */
.ico { display: inline-block; vertical-align: middle; flex-shrink: 0; }
.ico-cat { display: inline-block; vertical-align: middle; }
.nav-item .nav-icon { width: 28px; height: 28px; line-height: 1; display: block; }
.nav-item .nav-icon svg { width: 100%; height: 100%; }

/* ═══ Produkt-Grid (3 Spalten, Normalansicht) ═══ */
.product-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.pgrid-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: row;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
}
.pgrid-name {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pgrid-count {
  font-size: 12px;
  font-weight: 800;
}

/* ═══ Produkt Drag-Liste (Bearbeitungsmodus) ═══ */
.pdrag-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  background: var(--bg);
  border-radius: 10px;
  margin-bottom: 4px;
  user-select: none;
}
.pdrag-handle {
  color: var(--text-muted);
  cursor: grab;
  padding: 4px;
  flex-shrink: 0;
}
.pdrag-indicator {
  width: 4px;
  height: 28px;
  border-radius: 2px;
  flex-shrink: 0;
}
.pdrag-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.pdrag-count {
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
}