/* ─── PhotoStream — CSS ─────────────────────────────────────────────────── */

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #141414;
  --bg-surface: #1a1a1a;
  --bg-surface-hover: #252525;
  --bg-overlay: rgba(0, 0, 0, 0.92);
  --text-primary: #f0f0f0;
  --text-secondary: #999;
  --text-muted: #666;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --border: #2a2a2a;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 0.2s ease;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
  --sidebar-width: 280px;
}

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

html, body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Scrollbar ────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #444;
}

/* ─── Layout ───────────────────────────────────────────────────────────── */
.app {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ──────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  z-index: 10;
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-header h1 .logo {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.sidebar-stats {
  padding: 12px 20px;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 16px;
}

.sidebar-stats .stat-value {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 13px;
}

.sidebar-section {
  padding: 16px 12px;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 8px 8px;
}

/* ─── Filter buttons ───────────────────────────────────────────────────── */
.filter-group {
  display: flex;
  gap: 4px;
  padding: 0 8px 12px;
}

.filter-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font);
  transition: var(--transition);
}

.filter-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ─── Timeline ─────────────────────────────────────────────────────────── */
.timeline-year {
  margin-bottom: 2px;
}

.year-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  border-radius: 6px;
  transition: var(--transition);
}

.year-btn:hover {
  background: var(--bg-surface);
}

.year-btn.active {
  background: var(--bg-surface);
  color: var(--accent);
}

.year-count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.month-list {
  padding: 0 0 4px 12px;
  display: none;
}

.month-list.expanded {
  display: block;
}

.month-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 12px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  border-radius: 6px;
  transition: var(--transition);
}

.month-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.month-btn.active {
  color: var(--accent);
  background: rgba(59, 130, 246, 0.1);
}

.month-count {
  font-size: 11px;
  color: var(--text-muted);
}

/* ─── Main Content ─────────────────────────────────────────────────────── */
.main {
  flex: 1;
  min-width: 0;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toolbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.toolbar-info {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ─── Gallery Grid ─────────────────────────────────────────────────────── */
.gallery {
  padding: 16px;
}

.date-group {
  margin-bottom: 24px;
}

.date-group-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 8px 8px 12px;
  position: sticky;
  top: 52px;
  background: rgba(10, 10, 10, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 3;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 4px;
}

@media (min-width: 1400px) {
  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media (min-width: 1800px) {
  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

.photo-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 4px;
  cursor: pointer;
  background: var(--bg-surface);
  transition: transform 0.15s ease;
}

.photo-item:hover {
  transform: scale(1.02);
  z-index: 1;
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.3s ease;
}

.photo-item img.loading {
  opacity: 0;
}

.photo-item img.loaded {
  opacity: 1;
}

.photo-item .video-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 4px;
}

.photo-item .video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity var(--transition);
}

.photo-item:hover .video-overlay {
  opacity: 1;
}

.play-icon {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.play-icon::after {
  content: '';
  display: block;
  width: 0;
  height: 0;
  margin-left: 4px;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 16px solid #000;
}

/* ─── Loading States ───────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-surface-hover) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  z-index: 1000;
  transform-origin: left;
  transition: transform 0.3s ease;
}

.scan-banner {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.scan-banner .spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.scan-banner .scan-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.scan-banner .scan-text strong {
  color: var(--text-primary);
}

.scan-progress {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.scan-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ─── Empty State ──────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 15px;
}

/* ─── Infinite Scroll Loader ───────────────────────────────────────────── */
.load-more {
  display: flex;
  justify-content: center;
  padding: 24px;
}

.load-more .spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ─── Lightbox ─────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg-overlay);
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.lightbox.open {
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox.visible {
  opacity: 1;
}

.lightbox-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-image-container {
  max-width: calc(100vw - 120px);
  max-height: calc(100vh - 80px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: max-width 0.3s ease;
}

.lightbox.info-open .lightbox-image-container {
  max-width: calc(100vw - 480px);
}

.lightbox-image-container img {
  max-width: 100%;
  max-height: calc(100vh - 80px);
  object-fit: contain;
  border-radius: 4px;
  user-select: none;
  -webkit-user-drag: none;
  animation: lbFadeIn 0.15s ease;
}

.lightbox-image-container img.lb-img-preview {
  /* Thumbnail shown as instant preview — slightly soft at full size */
  image-rendering: auto;
}

@keyframes lbFadeIn {
  from { opacity: 0.7; }
  to { opacity: 1; }
}

.lightbox-image-container video {
  max-width: 100%;
  max-height: calc(100vh - 80px);
  border-radius: 4px;
  outline: none;
}

.lightbox-image-container .loading-placeholder {
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Lightbox Controls */
.lb-close,
.lb-prev,
.lb-next,
.lb-info-toggle {
  position: absolute;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: background var(--transition);
  backdrop-filter: blur(4px);
  z-index: 10;
}

.lb-close:hover,
.lb-prev:hover,
.lb-next:hover,
.lb-info-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lb-close {
  top: 16px;
  left: 16px;
}

.lb-prev {
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
}

.lb-next {
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
}

.lb-info-toggle {
  top: 16px;
  right: 16px;
}

.lb-info-toggle.active {
  background: var(--accent);
}

.lb-counter {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.5);
  padding: 4px 12px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}

/* ─── Info Panel ───────────────────────────────────────────────────────── */
.info-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 360px;
  height: 100%;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 10;
}

.lightbox.info-open .info-panel {
  transform: translateX(0);
}

.info-panel-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.info-panel-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}

.info-panel-header .info-date {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.info-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.info-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
}

.info-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.info-value {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  text-align: right;
  max-width: 60%;
  word-break: break-word;
}

.info-map {
  width: 100%;
  height: 200px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-top: 8px;
}

/* ─── Mobile Sidebar Toggle ────────────────────────────────────────────── */
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 50;
  width: 48px;
  height: 48px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  box-shadow: var(--shadow);
  align-items: center;
  justify-content: center;
}

/* ─── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 50;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: flex;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
  }

  .sidebar-backdrop.open {
    display: block;
  }

  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 2px;
  }

  .gallery {
    padding: 8px;
  }

  .toolbar {
    padding: 10px 16px;
  }

  .lightbox-image-container {
    max-width: 100vw;
    max-height: 100vh;
  }

  .lightbox.info-open .lightbox-image-container {
    max-width: 100vw;
  }

  .info-panel {
    width: 100%;
    height: 50%;
    top: auto;
    bottom: 0;
    right: 0;
    transform: translateY(100%);
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .lightbox.info-open .info-panel {
    transform: translateY(0);
  }

  .lb-prev, .lb-next {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .date-group-header {
    top: 48px;
  }
}

@media (max-width: 480px) {
  .photo-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
  }
}

/* ─── Login Overlay ────────────────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.login-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 40px 32px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
}

.login-logo {
  margin-bottom: 16px;
}

.login-card h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.login-field {
  text-align: left;
  margin-bottom: 16px;
}

.login-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.login-field input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
}

.login-field input:focus {
  border-color: var(--accent);
}

.login-error {
  font-size: 13px;
  color: #ef4444;
  min-height: 20px;
  margin-bottom: 8px;
}

.login-submit {
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background var(--transition);
}

.login-submit:hover {
  background: var(--accent-hover);
}

.login-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
