/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #6c5ce7;
  --primary-dark: #5a4bd1;
  --primary-light: #a29bfe;
  --accent: #a855f7;
  --bg: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-card-hover: #22223a;
  --text: #f0f0f5;
  --text-muted: #9a9ab0;
  --success: #00b894;
  --error: #ff6b6b;
  --warning: #ffc048;
  --border: rgba(255,255,255,0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --transition: 0.2s ease;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── Views ─── */
.view { min-height: 100dvh; padding: 16px; max-width: 480px; margin: 0 auto; }
.hidden { display: none !important; }

/* ─── Landing ─── */
.landing-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - 80px);
  text-align: center;
  gap: 32px;
}

.logo-area { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.logo-icon svg { width: 80px; height: 80px; filter: drop-shadow(0 4px 20px rgba(108,92,231,0.4)); }
.logo-area h1 {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.tagline { color: var(--text-muted); font-size: 1rem; line-height: 1.6; }

/* ─── Buttons ─── */
.action-buttons { display: flex; flex-direction: column; gap: 14px; width: 100%; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  padding: 12px 24px;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 4px 16px rgba(108,92,231,0.35);
}
.btn-primary:hover { box-shadow: 0 6px 24px rgba(108,92,231,0.5); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-card-hover); }

.btn-outline {
  background: transparent;
  color: var(--primary-light);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: rgba(108,92,231,0.1); }

.btn-large { padding: 16px 32px; font-size: 1.1rem; border-radius: var(--radius); }
.btn-small { padding: 8px 14px; font-size: 0.85rem; }
.btn-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* ─── How it works ─── */
.how-it-works { width: 100%; }
.how-it-works h3 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 16px; }
.steps { display: flex; flex-direction: column; gap: 12px; }
.step {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  text-align: left;
}
.step-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  font-weight: 700;
  font-size: 0.9rem;
}
.step p { font-size: 0.95rem; color: var(--text-muted); }
.step strong { color: var(--text); }

/* ─── Footer ─── */
.footer { text-align: center; padding: 16px 0; }
.footer p { font-size: 0.8rem; color: var(--text-muted); }

/* ─── View Header ─── */
.view-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-top: 8px;
}
.back-btn {
  background: var(--bg-card);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  transition: background var(--transition);
}
.back-btn:hover { background: var(--bg-card-hover); }
.back-btn svg { width: 20px; height: 20px; }
.view-header h2 { font-size: 1.3rem; font-weight: 700; }

/* ─── Cards ─── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.card h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 14px; }

/* ─── Drop Zone ─── */
.drop-zone {
  border: 2px dashed rgba(108,92,231,0.4);
  border-radius: var(--radius-sm);
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-muted);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(108,92,231,0.08);
}
.drop-icon { width: 48px; height: 48px; color: var(--primary-light); margin-bottom: 8px; }
.drop-zone p { font-size: 0.95rem; }

/* ─── File list ─── */
.file-list { max-height: 240px; overflow-y: auto; margin-top: 12px; }
.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03);
  margin-bottom: 6px;
  transition: background var(--transition);
}
.file-item:hover { background: rgba(255,255,255,0.06); }
.file-icon { font-size: 1.3rem; flex-shrink: 0; }
.file-name { flex: 1; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 0.8rem; color: var(--text-muted); flex-shrink: 0; }
.remove-btn {
  background: none;
  border: none;
  color: var(--error);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background var(--transition);
}
.remove-btn:hover { background: rgba(255,107,107,0.15); }
.file-count { font-size: 0.85rem; color: var(--text-muted); margin-top: 8px; text-align: right; }

/* ─── Room Code ─── */
.room-code-area { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 16px; }
.room-code {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 6px;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.qr-container { display: flex; justify-content: center; margin: 16px 0; }
.qr-container canvas, .qr-container img { border-radius: 12px; }
.connection-card { text-align: center; }
.connection-card .btn-outline { margin-top: 8px; width: 100%; }

/* ─── Receive - Join Area ─── */
.code-input {
  background: rgba(255,255,255,0.06);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 6px;
  text-align: center;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
  font-variant-numeric: tabular-nums;
}
.code-input-full { display: block; width: 100%; }
.code-input:focus { border-color: var(--primary); }
.code-input::placeholder { color: var(--text-muted); letter-spacing: 4px; font-weight: 400; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ─── QR Scanner ─── */
.qr-scan-area {
  margin-top: 14px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  aspect-ratio: 1;
  max-height: 280px;
}
.qr-scan-area video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

/* ─── Status ─── */
.status {
  text-align: center;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  min-height: 20px;
  margin: 12px 0;
  transition: all var(--transition);
}
.status:empty { display: none; }
.status.waiting { color: var(--warning); background: rgba(255,192,72,0.1); }
.status.success { color: var(--success); background: rgba(0,184,148,0.1); }
.status.error { color: var(--error); background: rgba(255,107,107,0.1); }

/* ─── Progress ─── */
.progress-area { margin-top: 16px; }
.progress-entry {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
}
.progress-label {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.file-size-sm { font-size: 0.8rem; color: var(--text-muted); flex-shrink: 0; }
.progress-bar {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 3px;
  width: 0%;
  transition: width 0.15s linear;
}
.progress-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: right;
}
.download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  padding: 8px 20px;
  background: linear-gradient(135deg, var(--success), #00d2a0);
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: 8px;
  text-decoration: none;
  transition: all var(--transition);
}
.download-btn:hover { box-shadow: 0 4px 12px rgba(0,184,148,0.3); }
.save-photos-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 6px;
  margin-left: 8px;
  padding: 8px 20px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}
.save-photos-btn:hover { box-shadow: 0 4px 12px rgba(108,92,231,0.3); }

/* ─── Received Gallery ─── */
.received-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin: 16px 0;
}
.gallery-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-card);
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
  aspect-ratio: 1;
}
.gallery-item.selected { border-color: var(--primary-light); }
.gallery-item:active { transform: scale(0.96); }
.gallery-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gallery-icon-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
}
.gallery-icon-placeholder .gi-emoji { font-size: 2rem; }
.gallery-icon-placeholder .gi-name {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}
.gallery-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.gallery-item.selected .gallery-check {
  background: var(--primary);
  border-color: var(--primary);
}
.gallery-check svg { width: 12px; height: 12px; opacity: 0; transition: opacity var(--transition); }
.gallery-item.selected .gallery-check svg { opacity: 1; }
.gallery-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(0,0,0,0.3);
}
.gallery-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  width: 0%;
  transition: width 0.15s linear;
}
.gallery-complete .gallery-progress { display: none; }
.gallery-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 8px 0 16px;
}

/* ─── Notice ─── */
.notice {
  text-align: center;
  font-size: 0.8rem;
  color: var(--warning);
  background: rgba(255,192,72,0.08);
  border: 1px solid rgba(255,192,72,0.15);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 12px 0;
  line-height: 1.4;
}

/* ─── Action Row (centering) ─── */
.action-row {
  display: flex;
  justify-content: center;
  margin: 12px 0;
}
.action-row .btn { min-width: 160px; }

/* ─── Ad Banner ─── */
.ad-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  background: var(--bg);
  padding: 4px;
  z-index: 100;
  min-height: 0;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

/* ─── Animations ─── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.card { animation: fadeIn 0.3s ease; }

/* ─── Mobile-first: full-width buttons, tighter spacing ─── */
.action-row .btn-large { width: 100%; }

@media (max-width: 380px) {
  .view { padding: 12px; }
  .card { padding: 14px; }
  .room-code { font-size: 1.6rem; letter-spacing: 4px; }
  .qr-container canvas, .qr-container img { max-width: 150px !important; max-height: 150px !important; }
  .drop-zone { padding: 20px 12px; }
  .drop-icon { width: 36px; height: 36px; }
  .btn-large { padding: 14px 20px; font-size: 1rem; }
}

/* ─── Desktop adjustments ─── */
@media (min-width: 600px) {
  .view { padding: 32px; }
  .landing-container { gap: 40px; }
  .logo-icon svg { width: 100px; height: 100px; }
  .logo-area h1 { font-size: 2.8rem; }
  .action-buttons { flex-direction: row; justify-content: center; }
  .btn-large { min-width: 200px; }
  .action-row .btn-large { width: auto; }
}
