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

:root {
  --bg: #f0f4f8;
  --surface: #ffffff;
  --primary: #4f6ef7;
  --primary-hover: #3b57d9;
  --primary-light: #eef1ff;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --border: #d1d5db;
  --border-light: #e5e7eb;
  --success: #10b981;
  --error: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
  --transition: 0.3s ease;
}

html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 40px 20px;
  line-height: 1.6;
}

.container {
  width: 100%;
  max-width: 680px;
}

/* ─── Header ──────────────────────────────── */
header {
  text-align: center;
  margin-bottom: 32px;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ─── Upload Section ──────────────────────── */
.upload-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--primary-light);
  position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: #dde4ff;
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.icon-upload {
  font-size: 3rem;
  line-height: 1;
}

.drop-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.drop-hint {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.drop-limit {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* File Preview */
.drop-zone-preview {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

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

.file-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.btn-change {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
  transition: all var(--transition);
  flex-shrink: 0;
}

.btn-change:hover {
  background: var(--border-light);
}

/* Options */
.options {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.option-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.option-group {
  display: flex;
  gap: 8px;
}

.radio-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.9rem;
  background: var(--surface);
}

.radio-btn:hover {
  border-color: var(--primary);
}

.radio-btn input[type="radio"] {
  display: none;
}

.radio-btn input[type="radio"]:checked + span {
  color: var(--primary);
  font-weight: 600;
}

.radio-btn:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* Convert Button */
.btn-convert {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 14px 32px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.btn-convert:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79,110,247,0.3);
}

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

.btn-convert-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  margin-top: 12px;
}

.btn-convert-secondary:hover:not(:disabled) {
  background: var(--border-light);
  box-shadow: none;
  transform: none;
}

.btn-loader {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -10px 0 0 -10px;
}

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

/* ─── Progress ────────────────────────────── */
.progress-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-top: 16px;
  text-align: center;
}

.progress-bar-container {
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #818cf8);
  border-radius: 3px;
  transition: width 0.4s ease;
  animation: progress-indeterminate 2s ease-in-out infinite;
  background-size: 200% 100%;
}

@keyframes progress-indeterminate {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.progress-status {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* ─── Result ──────────────────────────────── */
.result-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  margin-top: 16px;
  text-align: center;
}

.result-section h2 {
  font-size: 1.4rem;
  margin-bottom: 20px;
  color: var(--success);
}

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-download:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79,110,247,0.3);
}

.btn-download-pdf {
  background: var(--error);
}

.btn-download-pdf:hover {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(239,68,68,0.3);
}

/* Preview */
.result-preview {
  margin-top: 16px;
  text-align: left;
}

.result-preview h3 {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.preview-container {
  width: 100%;
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: #fafafa;
}

.preview-container img {
  width: 100%;
  display: block;
}

/* ─── Error ───────────────────────────────── */
.error-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  margin-top: 16px;
  text-align: center;
}

.error-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.error-icon {
  font-size: 1.5rem;
}

.error-message {
  font-size: 1rem;
  color: var(--error);
  font-weight: 500;
}

/* ─── Toast ───────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #333;
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  opacity: 0;
  transition: all 0.4s ease;
  pointer-events: none;
  z-index: 999;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Footer ──────────────────────────────── */
footer {
  text-align: center;
  margin-top: 32px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

footer a {
  color: var(--primary);
  text-decoration: none;
}

/* ─── Responsive ──────────────────────────── */
@media (max-width: 520px) {
  body { padding: 16px 12px; }
  header h1 { font-size: 1.5rem; }
  .upload-section { padding: 20px; }
  .drop-zone { padding: 32px 16px; }
  .options { flex-direction: column; align-items: flex-start; }
  .result-actions { flex-direction: column; align-items: stretch; }
  .btn-download { justify-content: center; }
}
