/* ════════════════════════════════════════════════════════════════════
   MÄNGELLISTE APP - STYLES
   Warm dark design with orange/amber accents
   ════════════════════════════════════════════════════════════════════ */

:root {
  --bg:         #0a0807;
  --surface:    #110e0d;
  --card:       #181412;
  --border:     #241f1c;
  --border2:    #332b26;
  --accent:     #f97316;
  --accent-lt:  #fb923c;
  --accent-dim: #2e160a;
  --accent2:    #ef4444;
  --text:       #f5edeb;
  --muted:      #6b5d57;
  --muted-lt:   #a38c82;
  --danger:     #ef4444;

  /* Status Colors */
  --status-offen:       #fb923c;
  --status-offen-bg:    rgba(251, 146, 60, 0.15);
  --status-arbeit:      #7b9fe0;
  --status-arbeit-bg:   rgba(123, 159, 224, 0.15);
  --status-erledigt:    #5ec97a;
  --status-erledigt-bg: rgba(94, 201, 122, 0.15);

  /* Priority Colors */
  --prio-hoch:    #ef4444;
  --prio-mittel:  #e0b539;
  --prio-niedrig: #999;
}

* { 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, textarea { font-family: inherit; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input { caret-color: var(--accent-lt); }
textarea { 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(251, 146, 60, 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(140px, 1fr));
  gap: 12px; margin-bottom: 24px;
}
.stat-card {
  flex: 1; background: var(--card); border-radius: 10px; padding: 10px 12px;
  border: 1px solid var(--border); text-align: center;
  transition: border-color 0.2s;
}
.stat-value { font-size: 22px; font-weight: 700; }
.stat-label {
  font-size: 10px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.05em; margin-top: 2px;
}

/* ── FILTER TABS ── */
.filter-tabs {
  display: flex; gap: 8px; margin-bottom: 16px;
  overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: none; -ms-overflow-style: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
  padding: 6px 14px; 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;
}
.filter-tab:hover { border-color: var(--accent); color: var(--accent-lt); }
.filter-tab.active {
  border-color: var(--accent); background: rgba(249, 115, 22, 0.15);
  color: var(--accent-lt);
}
.filter-tab.status-offen.active { border-color: var(--status-offen); background: var(--status-offen-bg); color: var(--status-offen); }
.filter-tab.status-in_arbeit.active { border-color: var(--status-arbeit); background: var(--status-arbeit-bg); color: var(--status-arbeit); }
.filter-tab.status-erledigt.active { border-color: var(--status-erledigt); background: var(--status-erledigt-bg); color: var(--status-erledigt); }

/* ── ADD FORM ── */
/* ── 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: 500px;
  padding: 28px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
  max-height: 90vh;
  overflow-y: auto;
}
@keyframes fadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

.modal-content h3 { color: var(--accent-lt); margin: 0 0 20px; font-size: 18px; font-weight: 700; }
.form-row { display: flex; gap: 10px; margin-bottom: 12px; }
.form-input, .form-textarea {
  width: 100%; padding: 10px 14px; border-radius: 10px;
  background: #070605; border: 1px solid var(--border2);
  color: var(--text); font-size: 14px; outline: none;
  transition: border-color 0.2s;
}
.form-input:focus, .form-textarea:focus { border-color: var(--accent); }
.form-textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.form-select {
  width: 100%; padding: 10px 14px; border-radius: 10px;
  background: #110d0c; 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='%237a5a48' 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); }

.photo-btn {
  width: 100%; padding: 10px; border-radius: 10px;
  border: 1px dashed rgba(249, 115, 22, 0.3); background: transparent;
  color: var(--muted-lt); cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all 0.2s;
}
.photo-btn:hover { border-color: var(--accent); color: var(--accent-lt); }
.photo-btn.has-photo { background: #1f1410; border-style: solid; }
.photo-preview-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px; margin-top: 8px; width: 100%;
}
.photo-preview-item {
  position: relative; width: 100%; padding-bottom: 100%;
  border-radius: 10px; overflow: hidden; background: #110d0c;
}
.photo-preview-item img {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  object-fit: cover;
}
.photo-delete-badge {
  position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,0.7);
  color: white; border-radius: 50%; width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: bold; cursor: pointer; border: none;
  backdrop-filter: blur(4px);
}
.photo-delete-badge:hover { background: var(--danger); }
.photo-count-badge {
  position: absolute; bottom: 6px; right: 6px; background: rgba(0,0,0,0.75);
  color: white; font-size: 11px; padding: 4px 8px; border-radius: 12px;
  font-weight: 600; backdrop-filter: blur(4px);
}

.btn-add {
  flex: 1; padding: 11px; border-radius: 10px; border: none;
  background: var(--accent); color: #fff; font-weight: 700;
  font-size: 15px; cursor: pointer; transition: all 0.2s;
}
.btn-add:hover { background: #fb923c; }
.btn-add:disabled { background: #1a1412; color: #44352f; cursor: default; }
.btn-cancel {
  padding: 11px 18px; 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-fab {
  display: none; position: fixed; bottom: 24px;
  right: 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(249, 115, 22, 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(249, 115, 22, 0.5); }
@media (min-width: 1240px) {
  #add-fab { right: calc(50% - 600px + 20px); }
}

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

/* ── MANGEL CARD ── */
.mangel-card {
  background: var(--card); border: 1px solid var(--border2);
  border-radius: 14px; overflow: hidden;
  transition: border-color 0.2s; animation: fadeIn 0.2s ease;
}
.mangel-card:hover { border-color: var(--border2); }

.mangel-header {
  display: flex; gap: 14px; padding: 16px; cursor: pointer;
  align-items: flex-start;
}
.mangel-photo {
  width: 64px; height: 64px; object-fit: cover; border-radius: 8;
  flex-shrink: 0; border: 1px solid var(--border2);
}
.mangel-photo-placeholder {
  width: 64px; height: 64px; border-radius: 8; background: #261b18;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 24; color: #4a3530;
}
.mangel-info { flex: 1; min-width: 0; }
.mangel-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.mangel-room {
  font-size: 11px; color: var(--muted-lt); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.mangel-title {
  font-size: 15px; color: var(--text); font-weight: 600;
  line-height: 1.3; margin-bottom: 4px;
  display: flex; align-items: center; gap: 6px;
}
.mangel-date { font-size: 12px; color: var(--muted); }
.mangel-desc-preview { color: #5a4a42; margin-left: 8px; }
.mangel-expand {
  color: #5a4a42; font-size: 18px; transition: transform 0.2s;
  flex-shrink: 0; align-self: center;
}
.mangel-expand.open { transform: rotate(180deg); }

/* Status Badge */
.status-badge {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 3px 9px; border-radius: 20;
  display: inline-block;
}
.status-badge.offen { color: var(--status-offen); background: var(--status-offen-bg); border: 1px solid rgba(251, 146, 60, 0.27); }
.status-badge.in_arbeit { color: var(--status-arbeit); background: var(--status-arbeit-bg); border: 1px solid rgba(123, 159, 224, 0.27); }
.status-badge.erledigt { color: var(--status-erledigt); background: var(--status-erledigt-bg); border: 1px solid rgba(94, 201, 122, 0.27); }

/* Priority Dot */
.prio-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.prio-dot.hoch { background: var(--prio-hoch); box-shadow: 0 0 6px var(--prio-hoch); }
.prio-dot.mittel { background: var(--prio-mittel); box-shadow: 0 0 6px var(--prio-mittel); }
.prio-dot.niedrig { background: var(--prio-niedrig); box-shadow: 0 0 6px var(--prio-niedrig); }

/* Expanded Detail */
.mangel-detail {
  border-top: 1px solid var(--border2); padding: 16px;
  animation: fadeIn 0.15s ease;
}
.mangel-detail-photo {
  width: 100%; max-height: 300px; object-fit: contain;
  border-radius: 10px; margin-bottom: 14px; background: #110d0c;
}
.mangel-detail-desc {
  color: #b09080; font-size: 14px; line-height: 1.6;
  margin: 0 0 14px;
}
.mangel-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.status-btn {
  padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.status-btn.offen {
  border: 1px solid var(--border2);
  background: transparent; color: var(--muted);
}
.status-btn.offen.active { background: var(--status-offen-bg); color: var(--status-offen); }
.status-btn.in_arbeit {
  border: 1px solid rgba(123, 159, 224, 0.33);
  background: transparent; color: var(--muted);
}
.status-btn.in_arbeit.active { background: var(--status-arbeit-bg); color: var(--status-arbeit); }
.status-btn.erledigt {
  border: 1px solid rgba(94, 201, 122, 0.33);
  background: transparent; color: var(--muted);
}
.status-btn.erledigt.active { background: var(--status-erledigt-bg); color: var(--status-erledigt); }

.delete-btn {
  margin-left: auto; padding: 6px 14px; border-radius: 20px; font-size: 12px;
  font-weight: 600; cursor: pointer; border: 1px solid var(--border2);
  background: transparent; color: var(--muted-lt); transition: all 0.15s;
}
.delete-btn:hover { border-color: var(--danger); color: var(--danger); }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--muted);
  font-size: 14px;
}

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