/* ── Reset & Variables ─────────────────────────────────────────── */
:root {
  --primary:    #e67e22;
  --primary-dk: #d35400;
  --danger:     #e74c3c;
  --success:    #27ae60;
  --bg:         #f5f6fa;
  --card-bg:    #ffffff;
  --text:       #2c3e50;
  --text-muted: #7f8c8d;
  --border:     #dde1e7;
  --nav-bg:     #2c3e50;
  --nav-text:   #ecf0f1;
  --radius:     10px;
  --shadow:     0 2px 12px rgba(0,0,0,0.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navigation ────────────────────────────────────────────────── */
.nav {
  background: var(--nav-bg);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.nav-brand {
  color: var(--nav-text);
  font-size: 1.2rem;
  font-weight: 700;
  text-decoration: none;
}
.nav-links { display: flex; align-items: center; gap: 8px; }
.nav-user {
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
  padding: 4px 8px;
}
.nav-link {
  color: var(--nav-text);
  font-size: 0.9rem;
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.15s;
}
.nav-link:hover { background: rgba(255,255,255,0.1); text-decoration: none; }
.nav-logout { color: #ff8a80; }

/* ── Layout ─────────────────────────────────────────────────────── */
.main { min-height: calc(100vh - 56px); }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 80px;
}
.container-narrow { max-width: 640px; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dk); text-decoration: none; color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--bg); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; text-decoration: none; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-xs { padding: 4px 8px; font-size: 0.78rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-link { background: none; border: none; cursor: pointer; font-size: 0.85rem; padding: 2px 6px; border-radius: 4px; }
.btn-link:hover { text-decoration: underline; }
.nav-admin { color: #f0a500 !important; font-weight: 700; }
.nav-admin:hover { background: rgba(240,165,0,0.15) !important; }

/* ── Alerts ─────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.alert-error   { background: #fdecea; color: #c0392b; border: 1px solid #f5c6c0; }
.alert-success { background: #eafaf1; color: #1e8449; border: 1px solid #a9dfbf; }
.hidden { display: none !important; }

/* ── Auth Pages ─────────────────────────────────────────────────── */
.auth-wrap {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.auth-card {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 40px 32px;
  width: 100%;
  max-width: 420px;
}
.auth-logo { font-size: 3rem; text-align: center; margin-bottom: 8px; }
.auth-title { text-align: center; font-size: 1.6rem; margin-bottom: 4px; }
.auth-sub { text-align: center; color: var(--text-muted); font-size: 0.9rem; margin-bottom: 24px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 0.9rem; color: var(--text-muted); }

/* ── Forms ──────────────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.form-group input,
.form-group textarea,
.form-group select {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s;
  width: 100%;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
}
.form-group textarea { resize: vertical; }
.form-hint { font-size: 0.82rem; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }
.form-hint ol { padding-left: 18px; margin-top: 4px; }
.form-row { display: flex; gap: 10px; justify-content: flex-end; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; font-size: 0.9rem; }
.checkbox-label input[type=checkbox] { width: 18px; height: 18px; cursor: pointer; }

/* ── Tabs ───────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
}
.tab {
  padding: 8px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 8px 8px 0 0;
  border: 2px solid transparent;
  border-bottom: none;
  margin-bottom: -2px;
  transition: color 0.15s, background 0.15s;
}
.tab:hover { color: var(--primary); text-decoration: none; }
.tab-active {
  color: var(--primary);
  background: var(--card-bg);
  border-color: var(--border);
  border-bottom-color: var(--card-bg);
}

.archive-hint {
  background: #fffbea;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 20px;
}

/* ── Page Header ────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-header h2 { font-size: 1.4rem; }
.back-link { color: var(--text-muted); font-size: 0.9rem; display: block; margin-bottom: 8px; }
.back-link:hover { color: var(--primary); text-decoration: none; }

/* ── Status Badges ──────────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-badge.status-vorbereitung { background: #e8eaf6; color: #3949ab; }
.status-badge.status-aktiv        { background: #e8f5e9; color: #2e7d32; }
.status-badge.status-abgeschlossen{ background: #eceff1; color: #546e7a; }

.folder-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

/* Status-Select (Owner-Ansicht in Folder-Detail) */
.folder-title-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.folder-title-meta h2 { margin-bottom: 0; }

.status-select {
  border: none;
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}
.status-select.status-vorbereitung { background: #e8eaf6; color: #3949ab; }
.status-select.status-aktiv        { background: #e8f5e9; color: #2e7d32; }
.status-select.status-abgeschlossen{ background: #eceff1; color: #546e7a; }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card h3 { margin-bottom: 8px; font-size: 1.1rem; }
.card-hint { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 16px; }
.card-muted { background: var(--bg); box-shadow: none; border: 1px solid var(--border); font-size: 0.9rem; }
.card-muted p { margin-bottom: 4px; color: var(--text-muted); }

/* ── Folders Grid ───────────────────────────────────────────────── */
.folders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.folder-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s, box-shadow 0.15s;
  display: block;
}
.folder-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.12); text-decoration: none; }
.folder-thumb {
  position: relative;
  height: 180px;
  background: #ecf0f1;
  overflow: hidden;
}
.folder-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.folder-no-img {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: #bdc3c7;
}
.folder-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 0.78rem;
  padding: 3px 8px;
  border-radius: 20px;
}
.folder-archive-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 20px;
}
.folder-card-archived { opacity: 0.8; filter: grayscale(20%); }
.folder-info { padding: 14px 16px; }
.folder-name { font-weight: 700; font-size: 1rem; margin-bottom: 4px; }
.folder-desc { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 6px; }
.folder-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Folder Page ────────────────────────────────────────────────── */
.folder-header { margin-bottom: 20px; }
.folder-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.folder-title-row h2 { font-size: 1.5rem; }
.folder-description { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }
.folder-meta-line { font-size: 0.85rem; color: var(--text-muted); margin-top: 6px; }
.folder-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }

/* ── Shares Bar ─────────────────────────────────────────────────── */
.shares-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.share-chip {
  background: #eef2f7;
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}
.chip-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
  line-height: 1;
}

/* ── Image Grid ─────────────────────────────────────────────────── */
.image-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}
@media (min-width: 480px) { .image-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 768px) { .image-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1024px) { .image-grid { grid-template-columns: repeat(5, 1fr); } }

.image-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: #ecf0f1;
  border-radius: 6px;
}
.image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
  transition: transform 0.2s;
}
.image-item:hover img { transform: scale(1.03); }
.img-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 0.75rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.image-item:hover .img-delete { display: flex; }
.img-delete:hover { background: var(--danger); }

/* ── FAB Upload Button ──────────────────────────────────────────── */
.fab-area {
  position: fixed;
  bottom: 24px;
  right: 20px;
  z-index: 50;
}
.fab {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 30px;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(230,126,34,0.45);
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.fab:hover { background: var(--primary-dk); transform: translateY(-2px); }
.fab:active { transform: scale(0.97); }

/* ── Upload Progress ────────────────────────────────────────────── */
.upload-progress {
  position: fixed;
  bottom: 90px;
  right: 20px;
  left: 20px;
  max-width: 360px;
  margin-left: auto;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 16px;
  z-index: 60;
}
.upload-progress-inner { display: flex; flex-direction: column; gap: 8px; }
#upload-status { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  width: 0%;
  transition: width 0.2s;
}

/* ── Lightbox ───────────────────────────────────────────────────── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.lightbox.open { display: flex; }
.lb-content {
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
#lb-img {
  max-width: 95vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 4px 40px rgba(0,0,0,0.5);
}
.lb-info {
  color: rgba(255,255,255,0.75);
  font-size: 0.82rem;
  text-align: center;
}
.lb-close {
  position: fixed;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 201;
}
.lb-prev, .lb-next {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.6rem;
  cursor: pointer;
  z-index: 201;
  line-height: 1;
}
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
.lb-prev:hover, .lb-next:hover, .lb-close:hover { background: rgba(255,255,255,0.3); }

/* ── Modal ──────────────────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal.open { display: flex; }
.modal-content {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 1.1rem; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
}

/* ── Empty State ────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 4rem; margin-bottom: 16px; }
.empty-state p { margin-bottom: 20px; font-size: 1rem; }
.empty-state h2 { color: var(--text); margin-bottom: 8px; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .auth-card { padding: 28px 20px; }
  .folder-title-row { flex-direction: column; }
  .folder-actions { width: 100%; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ── Admin ──────────────────────────────────────────────────────── */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 16px;
  text-align: center;
}
.stat-num { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

.form-row-multi {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}
.form-group-check { justify-content: flex-end; padding-bottom: 10px; }
.form-group-btn { min-width: 100px; }

.user-table-wrap { overflow-x: auto; }
.user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.user-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}
.user-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.user-table tr:last-child td { border-bottom: none; }
.user-table tr.row-admin { background: #fffbea; }
.td-muted { color: var(--text-muted); font-size: 0.82rem; }
.td-center { text-align: center; }
.td-actions { display: flex; gap: 6px; align-items: center; }
.badge-admin {
  display: inline-block;
  background: #fff3cd;
  color: #856404;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 6px;
}
.text-warning { color: #e67e22; }
.text-muted { color: var(--text-muted); }

/* ── User Checklist (Neuer Ordner Modal) ────────────────────────── */
.user-checklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--bg);
}
.user-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.1s;
}
.user-check-item:hover { background: #fff; }
.user-check-item input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; flex-shrink: 0; }
.user-check-name { font-size: 0.9rem; }
