/* === RESET & GRUNDLAGEN === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --bg2:       #1a1d27;
  --bg3:       #22263a;
  --border:    #2e3248;
  --text:      #e8eaf0;
  --text-muted:#8890aa;
  --accent:    #6366f1;
  --accent-h:  #4f52d4;
  --danger:    #ef4444;
  --radius:    10px;
  --sidebar-w: 240px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* === SIDEBAR === */
#sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: .5px;
}

nav { padding: 8px; }

.nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .9rem;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.nav-btn:hover  { background: var(--bg3); color: var(--text); }
.nav-btn.active { background: var(--accent); color: #fff; }

.sidebar-filters { padding: 12px 16px; flex: 1; }
.sidebar-filters h3 {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin: 16px 0 6px;
}

.filter-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .85rem;
  color: var(--text-muted);
  transition: background .15s, color .15s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.filter-chip:hover  { background: var(--bg3); color: var(--text); }
.filter-chip.active { background: var(--bg3); color: var(--text); font-weight: 600; }
.filter-chip .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* === MAIN === */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#topbar {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}

#search-input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  color: var(--text);
  font-size: .95rem;
  outline: none;
}
#search-input:focus { border-color: var(--accent); }

#view-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* === BUTTONS === */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: .9rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-h); }

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-size: .9rem;
  cursor: pointer;
  transition: background .15s;
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-size: .9rem;
  cursor: pointer;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

/* === ITEM GRID === */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
}

.item-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s, border-color .15s;
}
.item-card:hover { transform: translateY(-2px); border-color: var(--accent); }

.item-cover {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}
.item-cover img { width: 100%; height: 100%; object-fit: cover; }

.item-info { padding: 10px; }
.item-title { font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-subtitle { font-size: .78rem; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-meta { display: flex; gap: 5px; margin-top: 8px; flex-wrap: wrap; }

.badge {
  font-size: .7rem;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--bg3);
  color: var(--text-muted);
}
.badge.limited { background: #7c3aed22; color: #a78bfa; border: 1px solid #7c3aed44; }

/* === MODAL === */
#modal-overlay {
  position: fixed; inset: 0;
  background: #000a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
#modal-overlay.hidden { display: none; }

#modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  padding: 28px;
}

#modal-close {
  position: absolute; top: 14px; right: 14px;
  background: var(--bg3);
  border: none;
  border-radius: 50%;
  width: 30px; height: 30px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
}
#modal-close:hover { color: var(--text); }

/* === FORMULARE === */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .82rem; color: var(--text-muted); margin-bottom: 5px; }

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: .9rem;
  outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }

.form-group textarea { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Checkbox */
.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-check input { width: auto; }

/* Cover-Vorschau */
.cover-preview {
  width: 100%; aspect-ratio: 1;
  max-width: 120px;
  background: var(--bg3);
  border-radius: 8px;
  border: 2px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  overflow: hidden;
  margin-bottom: 8px;
}
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }

/* === STATISTIKEN === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 700; }
.stat-card .stat-label { font-size: .82rem; color: var(--text-muted); margin-top: 4px; }

/* === SETTINGS === */
.settings-section { margin-bottom: 32px; }
.settings-section h2 { font-size: 1rem; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
}
.list-item-actions { display: flex; gap: 6px; }
.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: .85rem;
}
.btn-icon:hover { background: var(--bg3); color: var(--text); }
.btn-icon.danger:hover { color: var(--danger); }

/* === EMPTY STATE === */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { margin-bottom: 16px; }

/* === ITEM DETAIL === */
.item-detail-header { display: flex; gap: 20px; margin-bottom: 24px; }
.item-detail-cover {
  width: 130px; height: 130px;
  border-radius: 10px;
  background: var(--bg3);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 3.5rem;
  overflow: hidden;
}
.item-detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.item-detail-meta h2 { font-size: 1.3rem; }
.item-detail-meta p { color: var(--text-muted); font-size: .9rem; margin-top: 4px; }
.item-detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.field-list { border-top: 1px solid var(--border); padding-top: 16px; }
.field-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.field-row .field-label { color: var(--text-muted); }

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.hidden { display: none !important; }

/* =====================
   MOBILE / RESPONSIVE
   ===================== */

#sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: #000a;
  z-index: 60;
}
#sidebar-backdrop.visible { display: block; }

#burger-btn {
  display: none;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.1rem;
  padding: 6px 11px;
  cursor: pointer;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  #burger-btn { display: block; }

  #sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 70;
    transform: translateX(-100%);
    transition: transform .25s ease;
    width: 280px;
  }
  #sidebar.open { transform: translateX(0); }

  #main { width: 100%; }

  #topbar { padding: 10px 14px; }

  #btn-add-item {
    position: fixed;
    bottom: 20px; right: 16px;
    width: 52px; height: 52px;
    border-radius: 50%;
    font-size: 1.5rem;
    padding: 0;
    box-shadow: 0 4px 16px #6366f155;
    z-index: 40;
  }

  .items-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  #modal {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
    margin: auto 0 0;
    padding: 20px 16px 32px;
  }
  #modal-overlay { align-items: flex-end; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  #view-container { padding: 12px; }
}

/* READ INDICATOR */
.item-card { position: relative; }
.read-btn {
  position: absolute;
  top: 8px; right: 8px;
  background: #00000066;
  border: none;
  border-radius: 50%;
  width: 30px; height: 30px;
  font-size: .9rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  transition: transform .15s;
}
.read-btn:hover { transform: scale(1.15); }
.item-card.is-read { opacity: .6; }
.item-card.is-read .read-btn { background: #22c55e99; }

/* --- View Toggle Button --- */
#view-toggle-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition: border-color .15s;
}
#view-toggle-btn:hover { border-color: var(--accent); color: var(--accent); }

/* --- Listenansicht --- */
.items-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  padding: 1px 0;
}
.list-item {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  background: var(--bg2);
  cursor: pointer;
  transition: background .15s;
}
.list-item:hover { background: var(--bg3); }
.list-item.is-read { opacity: .6; }
.list-cover {
  width: 52px;
  height: 70px;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}
.list-cover img { width: 100%; height: 100%; object-fit: cover; }
.list-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.list-title {
  font-weight: 600;
  font-size: .95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-sub {
  font-size: .8rem;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.list-actions { display: flex; align-items: center; }
.read-btn-sm {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  color: var(--text);
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, color .15s;
  flex-shrink: 0;
}
.read-btn-sm:hover,
.read-btn-sm.is-read-active { border-color: var(--accent); color: var(--accent); }