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

:root {
  --bg: #0a0a0b;
  --surface: #141416;
  --surface-hover: #1c1c20;
  --border: #2a2a2e;
  --text: #f0f0f0;
  --text-secondary: #8a8a8e;
  --primary: #6c63ff;
  --primary-hover: #5a52e0;
  --danger: #ff4757;
  --success: #2ed573;
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  line-height: 1.6;
}

/* App Layout */
.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  text-align: center;
  margin-bottom: 40px;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-secondary);
  margin-top: 8px;
  font-size: 1rem;
}

main { flex: 1; }

footer {
  text-align: center;
  margin-top: 60px;
  padding: 20px 0;
}

footer a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s;
}

footer a:hover { color: var(--text); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { color: var(--text); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { opacity: 0.9; }

.btn-small {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.btn-large {
  width: 100%;
  padding: 14px 24px;
  font-size: 1.05rem;
  justify-content: center;
  margin-top: 16px;
}

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

.btn-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.btn-close:hover { color: var(--text); }

/* Upload Area */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: var(--surface);
}

.upload-area:hover, .upload-area.dragover {
  border-color: var(--primary);
  background: rgba(108, 99, 255, 0.05);
}

.upload-icon {
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.upload-text {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 8px;
}

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

.upload-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
}

/* Camera */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal.hidden { display: none; }

.camera-modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  overflow: hidden;
}

.camera-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.camera-header h3 { font-size: 1rem; }

.camera-view {
  aspect-ratio: 4/3;
  background: #000;
  position: relative;
}

.camera-view video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-controls {
  padding: 20px;
  display: flex;
  justify-content: center;
}

.btn-capture {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: transparent;
  border: 3px solid #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.15s;
}
.btn-capture:hover { transform: scale(1.05); }

.capture-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff;
  display: block;
  transition: background 0.15s;
}

.btn-capture:active .capture-circle { background: var(--primary); }

/* Preview */
.preview-section { animation: fadeIn 0.3s ease; }

.preview-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.preview-image {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  background: #000;
  display: block;
}

.preview-info {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Loading */
.loading-section {
  text-align: center;
  padding: 60px 20px;
  animation: fadeIn 0.3s ease;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}

.loading-section p {
  color: var(--text-secondary);
}

/* Result */
.result-section { animation: fadeIn 0.3s ease; }

.result-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.result-qr {
  padding: 32px;
  text-align: center;
  background: #fff;
}

.result-qr img {
  width: 240px;
  height: 240px;
  image-rendering: pixelated;
}

.result-info {
  padding: 24px;
}

.result-info h3 {
  font-size: 1.2rem;
  margin-bottom: 4px;
}

.result-info > p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.result-url {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.result-url input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: monospace;
}

.result-actions {
  display: flex;
  gap: 12px;
}

.result-actions .btn { flex: 1; justify-content: center; }

/* Hidden utility */
.hidden { display: none !important; }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

/* Responsive */
@media (max-width: 480px) {
  header h1 { font-size: 2rem; }
  .upload-area { padding: 32px 16px; }
  .upload-actions { flex-direction: column; }
  .result-actions { flex-direction: column; }
  .result-qr img { width: 180px; height: 180px; }
}
