/* ─── Reset & Base ──────────────────────────────────────────────────── */

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

html {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  background: #f8f9fa;
  color: #1a1a1a;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.view {
  flex-direction: column;
  flex: 1;
  min-height: 100vh;
}

.view[hidden] {
  display: none !important;
}

.view:not([hidden]) {
  display: flex;
}

/* ─── Animations ────────────────────────────────────────────────────── */

.fade-in {
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

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

/* ─── Loading ───────────────────────────────────────────────────────── */

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 16px;
  color: #6b7280;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e5e7eb;
  border-top-color: #374151;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ─── Error ─────────────────────────────────────────────────────────── */

.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 12px;
  text-align: center;
  padding: 24px;
}

.error-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #fee2e2;
  color: #dc2626;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
}

.error-container h2 {
  font-size: 20px;
  font-weight: 600;
  color: #1f2937;
}

.error-container p {
  color: #6b7280;
  max-width: 400px;
}

/* ─── Buttons ───────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover:not(:disabled) {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* ─── Header & Footer ──────────────────────────────────────────────── */

.header {
  padding: 16px 24px;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  width: 28px;
  height: 28px;
  max-width: 28px;
  max-height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand {
  font-size: 15px;
  font-weight: 600;
  color: #374151;
  letter-spacing: -0.01em;
}

.back-link {
  font-size: 13px;
  color: #2563eb;
  text-decoration: none;
  font-weight: 500;
}

.back-link:hover {
  text-decoration: underline;
}

.footer {
  padding: 16px 24px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: #9ca3af;
  margin-top: auto;
}

.powered-by strong {
  color: #6b7280;
}

/* ─── Gallery Layout ────────────────────────────────────────────────── */

.gallery-layout {
  display: flex;
  flex-direction: column;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  gap: 20px;
}

/* ─── Carousel ──────────────────────────────────────────────────────── */

.media-viewer {
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

.carousel {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
}

.carousel-track {
  display: flex;
  height: 100%;
  transition: transform 0.3s ease;
}

.carousel-slide {
  flex: 0 0 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.carousel-slide video,
.carousel-slide img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, opacity 0.15s;
}

.carousel-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.7);
}

.carousel-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.carousel-prev {
  left: 12px;
}

.carousel-next {
  right: 12px;
}

.carousel-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.6);
}

.carousel-dots {
  display: flex;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s;
}

.dot.active {
  background: #fff;
}

.dot:hover {
  background: rgba(255, 255, 255, 0.7);
}

.carousel-counter {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  font-variant-numeric: tabular-nums;
}

.media-placeholder {
  color: #9ca3af;
  font-size: 14px;
  padding: 40px;
  text-align: center;
}

/* ─── File List ─────────────────────────────────────────────────────── */

.file-list-section {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
}

.file-list-title {
  font-size: 14px;
  font-weight: 600;
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
  color: #374151;
}

.file-list {
  max-height: 280px;
  overflow-y: auto;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.12s;
  animation: fadeInUp 0.3s ease-out both;
}

.file-item:last-child {
  border-bottom: none;
}

.file-item.clickable {
  cursor: pointer;
}

.file-item.clickable:hover {
  background: #f9fafb;
}

.file-icon {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #6b7280;
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 13px;
  font-weight: 500;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.file-badge {
  font-size: 10px;
  font-weight: 600;
  background: #f3f4f6;
  color: #6b7280;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.file-size {
  font-size: 12px;
  color: #9ca3af;
}

.btn-download {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
  opacity: 0;
}

.file-item:hover .btn-download {
  opacity: 1;
}

.btn-download:hover {
  background: #e5e7eb;
  color: #1f2937;
}

.btn-download:disabled {
  cursor: not-allowed;
}

.btn-download.downloading {
  opacity: 1;
  animation: spin 0.8s linear infinite;
}

/* ─── Case Claim List ───────────────────────────────────────────────── */

.case-layout {
  flex: 1;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

.case-title {
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 16px;
}

.claim-list {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
}

.claim-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #f3f4f6;
  text-decoration: none;
  color: inherit;
  transition: background 0.12s;
  animation: fadeInUp 0.3s ease-out both;
  cursor: pointer;
}

.claim-row:last-child {
  border-bottom: none;
}

.claim-row:hover {
  background: #f9fafb;
}

.claim-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.claim-id {
  font-size: 13px;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  color: #6b7280;
}

.platform-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
  text-transform: capitalize;
}

.platform-tiktok {
  background: #f0fdf4;
  color: #166534;
}

.platform-instagram {
  background: #fef3c7;
  color: #92400e;
}

.platform-facebook {
  background: #eff6ff;
  color: #1e40af;
}

.platform-twitter {
  background: #f0f9ff;
  color: #0369a1;
}

.platform-unknown {
  background: #f3f4f6;
  color: #6b7280;
}

.claim-row-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.claim-date {
  font-size: 12px;
  color: #9ca3af;
}

.claim-arrow {
  font-size: 18px;
  color: #d1d5db;
}

.empty-state {
  padding: 40px;
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
}

/* ─── Pagination ────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
}

.page-info {
  font-size: 13px;
  color: #6b7280;
}

/* ─── Responsive ────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .gallery-layout,
  .case-layout {
    padding: 16px;
  }

  .header,
  .footer {
    padding: 12px 16px;
  }

  .footer {
    flex-direction: column;
    gap: 4px;
    text-align: center;
  }

  .carousel {
    aspect-ratio: 4 / 3;
  }

  .file-list {
    max-height: 200px;
  }

  .btn-download {
    opacity: 1;
  }
}
