/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f8f8f8;
  --surface:   #ffffff;
  --border:    #e0e0e0;
  --text:      #1a1a1a;
  --muted:     #666666;
  --accent:    #2563eb;
  --accent-h:  #1d4ed8;
  --danger:    #dc2626;
  --success:   #16a34a;
  --warning:   #d97706;
  --radius:    12px;
  --radius-sm: 6px;
  --shadow:    0 1px 3px rgba(0,0,0,0.08);
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Navigation ───────────────────────────────────────────────────────────── */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
  background: #eff6ff;
  color: var(--accent);
}

.nav-user {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge {
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 99px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-admin  { background: #ede9fe; color: #5b21b6; }
.badge-member { background: #dcfce7; color: #166534; }
.badge-viewer { background: #f3f4f6; color: #374151; }

/* ── Page layout ──────────────────────────────────────────────────────────── */
.page { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem; }
.page-title { font-size: 1.4rem; font-weight: 600; margin-bottom: 1.25rem; }

/* ── Flash messages ───────────────────────────────────────────────────────── */
.flash-list { list-style: none; margin-bottom: 1rem; }
.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}
.flash-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }
.flash-danger  { background: #fef2f2; color: var(--danger);  border: 1px solid #fecaca; }
.flash-warning { background: #fffbeb; color: var(--warning); border: 1px solid #fde68a; }
.flash-info    { background: #eff6ff; color: var(--accent);  border: 1px solid #bfdbfe; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary   { background: var(--accent);  color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-danger    { background: var(--danger);  color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.35rem; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
}
.form-hint { font-size: 0.78rem; color: var(--muted); margin-top: 0.3rem; }
.form-check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}
.stat-card .stat-number { font-size: 1.8rem; font-weight: 600; }
.stat-card .stat-label  { font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }

/* ── Photo grid ───────────────────────────────────────────────────────────── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 4px;
}

.photo-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--border);
  cursor: pointer;
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
  display: block;
}

.photo-item:hover img { transform: scale(1.04); }

.photo-item .photo-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0);
  display: flex;
  align-items: flex-end;
  padding: 0.5rem;
  transition: background 0.2s;
}

.photo-item:hover .photo-overlay { background: rgba(0,0,0,0.3); }

.photo-badge {
  font-size: 0.7rem;
  background: rgba(0,0,0,0.6);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}
.photo-item:hover .photo-badge { opacity: 1; }

.video-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  background: rgba(0,0,0,0.55);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* ── Lightbox ─────────────────────────────────────────────────────────────── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.lightbox.open { display: flex; }
.lightbox img, .lightbox video {
  max-width: 95vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
}
.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  color: #fff;
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
  background: none;
  border: none;
}
.lightbox-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}
.lightbox-info {
  color: rgba(255,255,255,0.6);
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

/* ── Upload area ──────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: #eff6ff;
}
.upload-zone .upload-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  display: block;
}
.upload-zone p { color: var(--muted); font-size: 0.9rem; }

.upload-progress { margin-top: 1.5rem; }
.file-list { list-style: none; margin-top: 1rem; }
.file-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
}

/* ── Date filter bar ──────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.filter-bar select {
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text);
}

/* ── Table ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ── Login page ───────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.login-logo {
  text-align: center;
  margin-bottom: 1.75rem;
}
.login-logo h1 { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.login-logo p  { font-size: 0.85rem; color: var(--muted); margin-top: 0.25rem; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; display: block; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 0.5rem; color: var(--text); }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .nav-links { gap: 0; }
  .nav-links a { padding: 0.4rem 0.5rem; font-size: 0.82rem; }
  .page { padding: 1rem 0.75rem; }
  .page-title { font-size: 1.2rem; }
}

/* ── PWA install banner ───────────────────────────────────────────────────── */
.pwa-banner {
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  gap: 0.75rem;
}
.pwa-banner button {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  padding: 0.3rem 0.8rem;
  border-radius: 99px;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}
