/* ════════════════════════════════════════════════════════════════════
   EINKAUFSLISTE APP - STYLES
   Dark, sleek design consistent with Boxen App aesthetics
   ════════════════════════════════════════════════════════════════════ */

:root {
  --bg:         #060d0e;
  --surface:    #0a1416;
  --card:       #0c1618;
  --border:     #152a2e;
  --border2:    #1a3238;
  --accent:     #10b981;
  --accent-lt:  #34d399;
  --accent-dim: #0a2420;
  --accent2:    #0ea5e9;
  --text:       #d0eee0;
  --muted:      #3a6a5a;
  --danger:     #e05c5c;
  --success:    #10b981;

  /* Urgency */
  --sofort:     #e05c5c;
  --sofort-bg:  rgba(224, 92, 92, 0.12);
  --bald:       #c09040;
  --bald-bg:    rgba(192, 144, 64, 0.12);
  --irgendwann: #608080;
  --irgendwann-bg: rgba(96, 128, 128, 0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--bg); font-family: 'Plus Jakarta Sans', system-ui, sans-serif; color: var(--text); overscroll-behavior: none; overflow-x: hidden; }

input, button, select { font-family: inherit; }
input::placeholder { color: var(--muted); }
input { caret-color: var(--accent-lt); }
select { cursor: pointer; }
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

#app { width: 100%; max-width: 1200px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }

/* ── TOP BAR ── */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
#topbar-left { display: flex; align-items: center; gap: 10px; }
#topbar-icon {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
}
#topbar-title { font-size: 16px; font-weight: 700; }
#topbar-hub-link {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-decoration: none; letter-spacing: 0.1em; text-transform: uppercase;
  transition: color 0.2s;
}
#topbar-hub-link:hover { color: var(--accent-lt); }

/* ── CONTENT ── */
#content { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.view { display: none; padding: 20px; animation: fadeIn .2s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── PIN VIEW ── */
#view-pin { display: none; flex-direction: column; align-items: center; padding: 60px 20px 20px; }
#view-pin.active { display: flex; }
#pin-lock {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent-dim); border: 1px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-lt); margin-bottom: 20px;
}
#pin-heading { font-size: 13px; color: var(--muted); margin-bottom: 28px; letter-spacing: .12em; }
#pin-dots { display: flex; gap: 14px; margin-bottom: 8px; }
.dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: transparent; border: 2px solid var(--border2); transition: all .15s;
}
.dot.filled { background: var(--accent-lt); border-color: var(--accent-lt); box-shadow: 0 0 10px rgba(52, 211, 153, 0.5); }
#pin-error { color: var(--danger); font-size: 12px; margin-bottom: 12px; letter-spacing: .08em; display: none; }
#numpad { margin-top: 24px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 260px; }
.nk {
  background: var(--card); border: 1px solid var(--border2); border-radius: 14px;
  padding: 18px 0; color: var(--text); font-size: 22px; font-weight: 600;
  cursor: pointer; font-family: monospace; transition: background .15s;
}
.nk:active { background: var(--border2); }
.nk.empty { background: transparent; border: none; cursor: default; }

/* ── STATS ROW ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px; margin-bottom: 24px;
}
.stat-card {
  flex: 1; background: var(--card); border-radius: 10px; padding: 10px 8px;
  border: 1px solid var(--border); text-align: center;
  transition: border-color 0.2s;
}
.stat-card.has-items { border-color: rgba(255, 255, 255, 0.08); }
.stat-value {
  font-size: 22px; font-weight: 700; color: var(--muted);
  transition: color 0.2s;
}
.stat-value.active { color: var(--text); }
.stat-label {
  font-size: 10px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.05em; margin-top: 2px;
}

/* ── KATEGORIE FILTER TABS ── */
.kat-tabs {
  display: flex; gap: 8px; margin-bottom: 16px;
  overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: none; -ms-overflow-style: none;
}
.kat-tabs::-webkit-scrollbar { display: none; }
.kat-tab {
  padding: 6px 13px; border-radius: 20px; font-size: 12px; font-weight: 600;
  white-space: nowrap; cursor: pointer;
  border: 1px solid var(--border2); background: transparent; color: var(--muted);
  transition: all 0.2s;
}
.kat-tab:hover { border-color: var(--accent); color: var(--accent-lt); }
.kat-tab.active {
  border-color: var(--accent); background: rgba(16, 185, 129, 0.15);
  color: var(--accent-lt);
}

/* ── ADD FORM ── */
.add-form {
  background: var(--card); border: 1px solid rgba(16, 185, 129, 0.27);
  border-radius: 16px; padding: 18px; margin-bottom: 20px;
  animation: slideDown 0.2s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

.add-form h3 { color: var(--accent-lt); margin: 0 0 14px; font-size: 15px; font-weight: 700; }
.form-row { display: flex; gap: 8px; margin-bottom: 10px; }
.form-input {
  width: 100%; padding: 10px 14px; border-radius: 10px;
  background: #070e10; border: 1px solid var(--border2);
  color: var(--text); font-size: 14px; outline: none;
  transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--accent); }
.form-select {
  width: 100%; padding: 10px 14px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--border2);
  color: var(--text); font-size: 14px; outline: none;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%233a6a5a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.form-select:focus { border-color: var(--accent); }

.btn-add {
  flex: 1; padding: 11px; border-radius: 10px; border: none;
  background: var(--accent); color: #fff; font-weight: 700;
  font-size: 14px; cursor: pointer; transition: all 0.2s;
}
.btn-add:hover { background: #14d09a; }
.btn-add:disabled { background: #0a1810; color: #1a4030; cursor: default; }
.btn-cancel {
  padding: 11px 16px; border-radius: 10px; border: 1px solid var(--border2);
  background: transparent; color: var(--muted); cursor: pointer;
  transition: all 0.2s; font-size: 14px;
}
.btn-cancel:hover { border-color: var(--muted); color: var(--text); }

/* ── FAB (Add Button) ── */
#add-fab {
  display: none; position: fixed; bottom: 24px;
  right: calc(50% - 250px + 20px);
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); border: none; color: #fff;
  font-size: 26px; cursor: pointer;
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
  align-items: center; justify-content: center; z-index: 100;
  transition: transform 0.2s, box-shadow 0.2s;
}
#add-fab:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(16, 185, 129, 0.5); }
@media (min-width: 1240px) {
  #add-fab { right: calc(50% - 600px + 20px); }
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-overlay.active { display: flex; animation: fadeIn 0.2s ease; }
.modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  width: 100%;
  max-width: 450px;
  padding: 28px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}
@keyframes fadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* ── ITEM LIST ── */
#view-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  padding-bottom: 80px;
  align-items: start;
}
@media (max-width: 400px) {
  #view-list { grid-template-columns: 1fr; }
}

/* ── ITEM CARDS ── */
.items-section { display: flex; flex-direction: column; gap: 10px; }

.item-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
.item-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: transparent;
  transition: background 0.3s;
}
.item-card.sofort::before { background: #ef4444; }
.item-card.bald::before { background: #f59e0b; }
.item-card.irgendwann::before { background: #10b981; }

.item-card:hover {
  transform: translateY(-2px);
  border-color: var(--border2);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.item-card.done { opacity: 0.5; filter: grayscale(0.5); }

/* Custom Checkbox */
.item-check {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border2);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: all 0.2s;
  flex-shrink: 0;
  padding: 0;
}
.item-card.done .item-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.item-check svg { width: 14px; height: 14px; }

/* Content */
.item-content { flex: 1; min-width: 0; }
.item-text-row { display: flex; align-items: center; gap: 8px; }
.item-text {
  font-size: 15px; color: var(--text); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item-card.done .item-text {
  color: var(--muted); text-decoration: line-through;
}
.item-menge {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  flex-shrink: 0;
  white-space: nowrap;
  transition: all 0.2s;
}
.item-card:hover .item-menge {
  color: var(--text);
  border-color: var(--border2);
  background: rgba(255, 255, 255, 0.06);
}
.item-meta { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.item-kat { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 3px; }
.item-dring {
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase;
}
.item-dring.sofort { color: var(--sofort); }
.item-dring.bald { color: var(--bald); }
.item-dring.irgendwann { color: var(--irgendwann); }

/* Delete button */
.item-del {
  background: none; border: none; color: var(--border2); cursor: pointer;
  font-size: 18px; padding: 4px; flex-shrink: 0; line-height: 1;
  transition: color 0.2s; border-radius: 6px;
}
.item-del:hover { color: var(--danger); }

/* ── DONE SECTION ── */
.done-section { margin-top: 20px; }
.done-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.done-toggle {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 12px; font-weight: 600; display: flex; align-items: center;
  gap: 5px; font-family: inherit;
}
.done-toggle .arrow {
  transition: transform 0.2s; display: inline-block;
}
.done-toggle .arrow.open { transform: rotate(90deg); }
.done-clear {
  background: none; border: none; color: var(--border2); cursor: pointer;
  font-size: 12px; font-family: inherit; transition: color 0.2s;
}
.done-clear:hover { color: var(--danger); }
.done-items { display: flex; flex-direction: column; gap: 6px; }

/* ── TOAST ── */
#toast {
  position: fixed; bottom: 90px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--card); border: 1px solid var(--border2); border-radius: 12px;
  padding: 10px 20px; font-size: 13px; color: var(--text);
  opacity: 0; transition: all .3s; pointer-events: none;
  white-space: nowrap; z-index: 100;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }

/* ── LOADING ── */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border2); border-top-color: var(--accent-lt);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  text-align: center; padding: 60px 20px; color: var(--muted);
}

/* ── RESPONSIVE ── */
@media (max-width: 520px) {
  #add-fab { right: 20px; }
}
