/* ═══════════════════════════════════════════════════════
   TadaHub Upload Portal — Refined tech aesthetic
   Inspired by minimal SaaS dashboards + Apple HIG
   ═══════════════════════════════════════════════════════ */

:root {
  /* Color system — light */
  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --bg-subtle: #f4f4f5;
  --border: rgba(0, 0, 0, 0.06);
  --border-strong: rgba(0, 0, 0, 0.12);
  --text: #0a0a0a;
  --text-muted: #52525b;
  --text-soft: #71717a;

  /* Accent — refined blue */
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-glow: rgba(37, 99, 235, 0.18);

  --success: #16a34a;
  --success-soft: #f0fdf4;
  --error: #dc2626;
  --error-soft: #fef2f2;
}

/* Dark mode — auto theo system, có thể override qua [data-theme="dark"] */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a;
    --bg-elevated: #18181b;
    --bg-subtle: #27272a;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text: #fafafa;
    --text-muted: #a1a1aa;
    --text-soft: #71717a;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-soft: rgba(59, 130, 246, 0.12);
    --accent-glow: rgba(59, 130, 246, 0.28);
    --success-soft: rgba(22, 163, 74, 0.12);
    --error-soft: rgba(220, 38, 38, 0.12);
  }
}
:root[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-elevated: #18181b;
  --bg-subtle: #27272a;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --text-soft: #71717a;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --accent-glow: rgba(59, 130, 246, 0.28);
  --success-soft: rgba(22, 163, 74, 0.12);
  --error-soft: rgba(220, 38, 38, 0.12);
}

:root {

  /* Shadows — multi-layered */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 8px 24px -4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 16px 40px -8px rgba(0, 0, 0, 0.10);

  /* Radii */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 24px;

  /* Easing */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  /* Typography */
  --font: 'Inter var', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Ambient background ───────────────────────────── */
.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
}

.orb-1 {
  width: 480px;
  height: 480px;
  top: -200px;
  right: -100px;
  background: radial-gradient(circle, #dbeafe, transparent 70%);
}

.orb-2 {
  width: 400px;
  height: 400px;
  bottom: -150px;
  left: -100px;
  background: radial-gradient(circle, #f0fdf4, transparent 70%);
}

.grain {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.4'/%3E%3C/svg%3E");
  opacity: 0.03;
  mix-blend-mode: overlay;
}

/* ─── Container ────────────────────────────────────── */
.container {
  max-width: 540px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  min-height: 100vh;
}

@media (min-width: 768px) {
  .container { padding: 56px 24px; }
}

/* ─── States ───────────────────────────────────────── */
.hidden { display: none !important; }

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
  color: var(--text-muted);
}

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

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

.error-card, .done-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 40px 28px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: rise 0.5s var(--ease) both;
}

.error-icon, .done-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.error-icon { background: var(--error-soft); color: var(--error); }
.done-icon { background: var(--success-soft); color: var(--success); }

.error-card h1, .done-card h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.error-card p, .done-card p {
  color: var(--text-muted);
  font-size: 14px;
}

.done-meta { margin-top: 12px; font-size: 13px; color: var(--text-soft); }

/* ─── Upload App ───────────────────────────────────── */
.upload-app {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: rise 0.6s var(--ease) both;
}

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

/* ─── Header ───────────────────────────────────────── */
.job-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: flex;
  filter: drop-shadow(0 4px 8px rgba(37, 99, 235, 0.25));
}

.brand-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.brand-sub {
  color: var(--text-soft);
  font-weight: 500;
}

.expiry {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 5px 10px;
  background: var(--bg-subtle);
  border-radius: 999px;
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.expiry.warning { color: #b45309; background: #fffbeb; border-color: #fed7aa; }
.expiry.danger { color: var(--error); background: var(--error-soft); border-color: #fecaca; }

/* ─── Job card ─────────────────────────────────────── */
.job-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
}

.job-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

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

.job-label {
  font-size: 13px;
  color: var(--text-soft);
  font-weight: 500;
}

.job-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-align: right;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mono { font-family: var(--font-mono); font-size: 13px; }

/* ─── Dropzone ─────────────────────────────────────── */
.dropzone {
  position: relative;
  background: var(--bg-elevated);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-lg);
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s var(--ease);
  overflow: hidden;
}

.dropzone:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone.dragging {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
  transform: scale(1.01);
  box-shadow: var(--shadow-lg), 0 0 0 4px var(--accent-glow);
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  position: relative;
  z-index: 1;
}

.upload-icon {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff, #f0f9ff);
  border: 1px solid #dbeafe;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 6px;
  box-shadow: 
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 8px 16px -4px var(--accent-glow);
}

.upload-icon-glow {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow), transparent 60%);
  opacity: 0.6;
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
}

.dropzone-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.dropzone-hint {
  font-size: 14px;
  color: var(--text-muted);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  pointer-events: auto;
}

.link-btn:hover { color: var(--accent-hover); }

.dropzone-meta {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 4px;
}

/* ─── Stats bar ────────────────────────────────────── */
.stats-bar {
  display: flex;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 20px;
  box-shadow: var(--shadow-sm);
  gap: 20px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.stat-value {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s;
}

.stat-label {
  font-size: 12px;
  color: var(--text-soft);
  font-weight: 500;
}

.stat-divider {
  width: 1px;
  height: 32px;
  background: var(--border);
}

/* ─── File items ───────────────────────────────────── */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 4px;
}
.file-list::-webkit-scrollbar { width: 8px; }
.file-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  animation: rise 0.25s var(--ease) both;
  position: relative;
  overflow: hidden;
  min-height: 36px;
}

.file-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.file-icon.image { background: #eff6ff; color: #2563eb; }
.file-icon.video { background: #fdf4ff; color: #c026d3; }
.file-icon.raw { background: #fff7ed; color: #ea580c; }
.file-icon.audio { background: #f0fdf4; color: #16a34a; }
.file-icon.other { background: var(--bg-subtle); color: var(--text-muted); }

.file-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.005em;
  flex: 1;
  min-width: 0;
}

.file-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  white-space: nowrap;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-status .status-text {
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-item.error .file-status { color: var(--error); cursor: help; }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.uploading { background: var(--accent); animation: pulse-dot 1.2s ease-in-out infinite; }
.status-dot.done { background: var(--success); }
.status-dot.error { background: var(--error); }
.status-dot.paused { background: #f59e0b; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.file-action {
  background: none;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: var(--r-sm);
  color: var(--text-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.file-action:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

/* Progress bar embedded in file item */
.file-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.2s ease-out;
  border-radius: 0 2px 2px 0;
}

.file-item.uploading {
  border-color: var(--accent-soft);
}

.file-item.done .file-progress { display: none; }
.file-item.error { border-color: #fecaca; background: var(--error-soft); }

/* ─── Completed section ────────────────────────────── */
.completed-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.completed-section summary {
  list-style: none;
  padding: 14px 18px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  font-weight: 500;
  user-select: none;
}

.completed-section summary::-webkit-details-marker { display: none; }

.completed-section summary::after {
  content: '';
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform 0.2s;
  margin-left: 12px;
}

.completed-section[open] summary::after { transform: rotate(-135deg); }

.completed-count {
  background: var(--bg-subtle);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.completed-section .file-list {
  padding: 4px 12px 12px;
  gap: 6px;
}

.completed-section .file-item {
  border: none;
  background: var(--bg-subtle);
  box-shadow: none;
  padding: 10px 12px;
}

/* ─── Finish button ────────────────────────────────── */
.finish-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 999px;
  padding: 14px 24px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  margin-top: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.finish-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.finish-btn:active { transform: translateY(0); }

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

/* ─── Mobile tweaks ────────────────────────────────── */
@media (max-width: 480px) {
  .container { padding: 16px 14px 32px; }
  .dropzone { padding: 28px 18px; }
  .upload-icon { width: 56px; height: 56px; }
  .stats-bar { padding: 12px 16px; }
  .stat-value { font-size: 16px; }
  .job-value { max-width: 55%; font-size: 13px; }
  .file-name { font-size: 13px; }
}

/* ─── Reduced motion ───────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
