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

:root {
  --bg: #0f0f17;
  --surface: #1a1a2e;
  --surface2: #22223b;
  --accent: #7c4dff;
  --accent2: #00e5ff;
  --text: #e8e8f0;
  --text-muted: #8888aa;
  --success: #00c853;
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 8px 40px rgba(124, 77, 255, 0.15);
}

html, body {
  height: 100%;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ─── Layout ────────────────────────────────────────────────────────────── */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  gap: 24px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

/* ─── Logo / header ─────────────────────────────────────────────────────── */
.logo {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Drop zone ─────────────────────────────────────────────────────────── */
#drop-zone {
  width: 100%;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  padding: 56px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: transparent;
  user-select: none;
}

#drop-zone:hover, #drop-zone.dragover {
  border-color: var(--accent2);
  background: rgba(0, 229, 255, 0.05);
}

#drop-zone-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  display: block;
  margin-bottom: 8px;
}

#drop-zone-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.drop-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  display: block;
}

/* ─── Share text toggle ─────────────────────────────────────────────────── */
.share-text-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s;
}

.share-text-toggle:hover { color: var(--accent2); }

/* ─── Text panel ────────────────────────────────────────────────────────── */
#text-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#text-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  padding: 14px 16px;
  resize: vertical;
  transition: border-color 0.2s;
}

#text-input:focus {
  border-color: var(--accent2);
  outline: none;
}

#text-input::placeholder { color: var(--text-muted); }

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: 99px;
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  padding: 14px 36px;
  transition: opacity 0.2s, transform 0.1s;
  width: 100%;
}

.primary-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.primary-btn:active { transform: translateY(0); }

/* ─── Upload UI ─────────────────────────────────────────────────────────── */
#upload-ui {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

/* QR code */
#qr-container {
  padding: 16px;
  background: #fff;
  border-radius: var(--radius-sm);
  display: inline-block;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

/* Progress bar */
#progress-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#progress-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--text-muted);
}

#progress-track {
  width: 100%;
  height: 10px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 99px;
  transition: width 0.3s ease;
}

/* Success */
#success-section {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.success-icon {
  font-size: 3.5rem;
  color: var(--success);
}

#done-label {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--success);
}

#scan-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ─── Error ─────────────────────────────────────────────────────────────── */
#error-msg, #fatal-msg {
  color: #ff5252;
  font-size: 0.9rem;
  background: rgba(255, 82, 82, 0.1);
  border: 1px solid rgba(255, 82, 82, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  width: 100%;
  text-align: center;
}

/* ─── Get page ──────────────────────────────────────────────────────────── */
#file-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.file-entry {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.2s;
}

.file-entry:hover { box-shadow: 0 0 0 1px var(--accent); }

.preview-img {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 6px;
  opacity: 0.6;
  filter: blur(1px);
  transition: opacity 0.3s, filter 0.3s;
}

.full-img {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  border-radius: 6px;
}

.text-content {
  background: var(--bg);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  max-height: 400px;
  overflow-y: auto;
  padding: 14px 16px;
  white-space: pre-wrap;
  word-break: break-word;
}

.file-link {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--accent2);
  word-break: break-all;
}

.file-icon { font-size: 1.4rem; flex-shrink: 0; }

.file-name-pending {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.file-status {
  font-size: 0.78rem;
  color: var(--accent);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--surface2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

#status-label {
  font-size: 1rem;
  color: var(--text-muted);
  text-align: center;
  animation: pulse 2s ease-in-out infinite;
}

#save-all-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: 99px;
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  padding: 14px 36px;
  transition: opacity 0.2s, transform 0.1s;
  width: 100%;
  max-width: 300px;
}

#save-all-btn:hover { opacity: 0.9; transform: translateY(-1px); }
#save-all-btn:active { transform: translateY(0); }

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 500px) {
  .card { padding: 28px 20px; }
  #drop-zone { padding: 40px 16px; }
}
