/* album.css — dt-gallery album view, Immich-inspired dark theme */

:root {
  --bg: #111111;
  --surface: #1e1e1e;
  --surface2: #262626;
  --border: #333333;
  --text: #e2e2e2;
  --text-dim: #909090;
  --accent: #4250af;
  --accent-hover: #5060c8;
  --face-box: rgba(99, 179, 237, 0.85);
  --face-box-hover: rgba(99, 179, 237, 1);
  --radius: 6px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

/* ── Toolbar ─────────────────────────────────────────────────────────────── */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: rgba(17, 17, 17, 0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  min-height: 52px;
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--text-dim);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.back-btn:hover { background: var(--surface2); color: var(--text); }

.album-info {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.tenant-badge {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  white-space: nowrap;
}

.album-sep { color: var(--border); }

.album-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Tabs ────────────────────────────────────────────────────────────────── */

.tab-bar {
  display: flex;
  gap: 2px;
  background: var(--surface2);
  border-radius: 8px;
  padding: 3px;
  flex-shrink: 0;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { background: var(--surface); color: var(--text); }
.tab-btn .count {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--border);
  border-radius: 10px;
  padding: 1px 7px;
  margin-left: 2px;
}
.tab-btn.active .count { color: var(--accent); }

/* ── Main content ────────────────────────────────────────────────────────── */

.main-content {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.view { display: block; }

/* ── Photo grid ──────────────────────────────────────────────────────────── */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
}

@media (max-width: 1100px) { .photo-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px)  { .photo-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 420px)  { .photo-grid { grid-template-columns: 1fr; } }

.photo-card {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  cursor: pointer;
  background: var(--surface);
}

.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
}
.photo-card:hover img { transform: scale(1.03); }

.photo-card .photo-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 60%, rgba(0,0,0,0.6) 100%);
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: flex-end;
  padding: 10px;
}
.photo-card:hover .photo-overlay { opacity: 1; }

.photo-card .photo-meta {
  font-size: 11px;
  color: #fff;
  line-height: 1.3;
}

.photo-card .face-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,0.6);
  border-radius: 10px;
  padding: 2px 7px;
  font-size: 11px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* Skeleton loading */
.skeleton-card {
  aspect-ratio: 1 / 1;
  background: var(--surface);
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}
@keyframes skeleton-pulse {
  0%, 100% { background: var(--surface); }
  50% { background: var(--surface2); }
}

/* ── Load more ───────────────────────────────────────────────────────────── */

.load-more-wrap {
  display: flex;
  justify-content: center;
  padding: 24px 0 0;
}

.load-more-btn {
  padding: 10px 28px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.load-more-btn:hover { background: var(--border); }

/* ── Empty state ─────────────────────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 280px;
  color: var(--text-dim);
}

/* ── People grid ─────────────────────────────────────────────────────────── */

.people-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  padding-top: 4px;
}
@media (max-width: 1100px) { .people-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 700px)  { .people-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 420px)  { .people-grid { grid-template-columns: repeat(2, 1fr); } }

.person-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}
.person-card:hover {
  background: var(--surface2);
  border-color: var(--border);
}

.person-avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface2);
}

.person-label { text-align: center; }
.person-display-name { font-size: 12px; font-weight: 600; display: block; }
.person-photo-count { font-size: 11px; color: var(--text-dim); display: block; }

/* ── Person view header ──────────────────────────────────────────────────── */

.person-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.back-people-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.back-people-btn:hover { background: var(--border); }

.person-avatar-lg {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface2);
}

.person-name { font-size: 16px; font-weight: 600; display: block; }
.person-photo-count-label { font-size: 13px; color: var(--text-dim); display: block; }

/* ── Photo detail modal ──────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fade-in 0.12s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-inner {
  position: relative;
  width: 100%;
  max-width: 1200px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}
.modal-close:hover { background: rgba(255,255,255,0.15); }

.modal-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  max-height: calc(100vh - 32px);
}

.modal-image-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
  min-height: 300px;
}

.img-container {
  position: relative;
  display: inline-block;
  line-height: 0;
}

#modalImg {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 32px);
  object-fit: contain;
}

#faceSvg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.face-rect {
  fill: none;
  stroke: var(--face-box);
  stroke-width: 2px;
  rx: 3;
}

/* ── Modal sidebar ───────────────────────────────────────────────────────── */

.modal-sidebar {
  width: 260px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 20px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (max-width: 768px) {
  .modal-body { flex-direction: column; }
  .modal-sidebar { width: 100%; border-left: none; border-top: 1px solid var(--border); max-height: 200px; }
}

.modal-meta { font-size: 12px; color: var(--text-dim); line-height: 1.8; }
.modal-meta strong { color: var(--text); }

.faces-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.face-list { display: flex; flex-direction: column; gap: 8px; }

.face-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}
.face-item:hover { background: var(--surface2); }

.face-item-thumb {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface2);
  flex-shrink: 0;
}

.face-item-name { font-size: 12px; color: var(--text); }
.face-item-score { font-size: 11px; color: var(--text-dim); }

.no-faces { font-size: 12px; color: var(--text-dim); }

/* ── Spinner ─────────────────────────────────────────────────────────────── */

.spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.spinner::after {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
