/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #a5b4fc;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.1);
  --transition: 0.2s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 20px;
  background-image: radial-gradient(ellipse at 50% 0%, #e0e7ff 0%, var(--bg) 60%);
}

/* ─── App Container ──────────────────────────────────────── */
.app-container {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ─── Header ─────────────────────────────────────────────── */
.header {
  text-align: center;
  padding-top: 16px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--primary);
}

.logo h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-secondary);
  margin-top: 6px;
  font-size: 15px;
}

/* ─── Tabs ───────────────────────────────────────────────── */
.tabs {
  display: flex;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 4px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.tab:hover {
  color: var(--text);
  background: rgba(99,102,241,0.05);
}

.tab.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}

/* ─── Tab Content ────────────────────────────────────────── */
.tab-content {
  display: none;
  flex-direction: column;
  gap: 20px;
}

.tab-content.active {
  display: flex;
}

/* ─── Upload Zone ────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: rgba(99,102,241,0.04);
  box-shadow: var(--shadow-lg);
}

.upload-zone.drag-over {
  transform: scale(1.01);
}

.upload-icon {
  color: var(--primary-light);
  margin-bottom: 12px;
}

.upload-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

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

/* ─── File List ──────────────────────────────────────────── */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-list:empty {
  display: none;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: slideIn 0.2s ease;
}

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

.file-item-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: rgba(99,102,241,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

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

.file-item-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item-size {
  font-size: 12px;
  color: var(--text-secondary);
}

.file-item-status {
  font-size: 12px;
  font-weight: 500;
}

.file-item-status.success { color: var(--success); }
.file-item-status.error { color: var(--danger); }
.file-item-status.uploading { color: var(--primary); }

.file-item-remove {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  font-size: 18px;
}

.file-item-remove:hover {
  background: rgba(239,68,68,0.1);
  color: var(--danger);
}

.file-item-progress {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.file-item-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ─── Buttons ─────────────────────────────────────────────── */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(99,102,241,0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: 0 4px 16px rgba(99,102,241,0.35);
  transform: translateY(-1px);
}

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

.btn-secondary {
  width: 100%;
  padding: 12px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary:hover {
  background: var(--bg);
  border-color: #cbd5e1;
}

.btn-copy, .btn-copy-link {
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-copy:hover, .btn-copy-link:hover {
  background: rgba(99,102,241,0.05);
  border-color: var(--primary);
}

.btn-copy.copied {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.btn-download {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: white;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-download:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

/* ─── Upload Progress ────────────────────────────────────── */
.upload-progress {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #8b5cf6);
  border-radius: 4px;
  width: 0%;
  transition: width 0.2s ease;
}

.progress-text {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}

/* ─── Result Card ────────────────────────────────────────── */
.result-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: fadeIn 0.3s ease;
}

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

.result-success-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(16,185,129,0.1);
  color: var(--success);
  font-size: 28px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-card h2 {
  font-size: 22px;
  font-weight: 700;
}

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

.code-display {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 12px;
  color: var(--primary);
  font-family: "SF Mono", "Fira Code", "JetBrains Mono", monospace;
  background: rgba(99,102,241,0.06);
  padding: 16px 32px;
  border-radius: var(--radius);
  border: 2px dashed rgba(99,102,241,0.2);
}

.share-link-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.share-link-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg);
  font-family: monospace;
}

.expiry-note {
  font-size: 13px;
  color: var(--warning);
}

/* ─── Receive Section ───────────────────────────────────── */
.receive-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.receive-prompt {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
}

.code-input-group {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.digit-input {
  width: 52px;
  height: 64px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  font-family: "SF Mono", "Fira Code", "JetBrains Mono", monospace;
  color: var(--text);
  transition: all var(--transition);
  background: var(--bg);
}

.digit-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
  background: white;
}

.digit-input.filled {
  border-color: var(--primary-light);
}

.digit-input.shake {
  animation: shake 0.5s ease;
  border-color: var(--danger) !important;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.error-message {
  font-size: 14px;
  color: var(--danger);
  padding: 8px 16px;
  background: rgba(239,68,68,0.06);
  border-radius: var(--radius-sm);
}

.btn-retrieve {
  margin-top: 8px;
}

/* ─── Receive Result ────────────────────────────────────── */
.receive-result {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: fadeIn 0.3s ease;
}

.receive-file-list {
  width: 100%;
  text-align: left;
}

/* ─── Footer ─────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 20px 0 32px;
}

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

/* ─── Toast ──────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: white;
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s ease, fadeOutRight 0.3s ease 2.5s forwards;
  max-width: 320px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeOutRight {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100%); }
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 480px) {
  .app-container { gap: 16px; }
  .code-display { font-size: 32px; letter-spacing: 8px; padding: 12px 20px; }
  .digit-input { width: 44px; height: 56px; font-size: 24px; }
  .code-input-group { gap: 6px; }
  .upload-zone { padding: 32px 16px; }
  .result-card, .receive-section, .receive-result { padding: 24px 16px; }
}