/* CSS Reset and Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary: #10b981;
  --background: #f8fafc;
  --surface: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 16px;
}

/* Dark mode variables */
[data-theme="dark"] {
  --primary: #818cf8;
  --primary-dark: #6366f1;
  --primary-light: #a5b4fc;
  --secondary: #34d399;
  --background: #0f172a;
  --surface: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --border: #334155;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
}

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

/* App Layout */
.app-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 2rem 1rem;
  text-align: center;
}

.header-content {
  max-width: 600px;
  margin: 0 auto;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: white;
  font-size: 1.5rem;
  font-weight: 700;
}

.logo svg {
  width: 32px;
  height: 32px;
}

.tagline {
  color: rgba(255, 255, 255, 0.8);
  margin-top: 0.5rem;
  font-size: 0.95rem;
}

/* Theme Toggle Button */
.theme-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius);
  padding: 0.5rem;
  cursor: pointer;
  color: white;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.theme-icon {
  width: 20px;
  height: 20px;
}

.header-content {
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

/* Main Container */
.main-container {
  flex: 1;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Tabs */
.tabs-container {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  padding: 0.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn svg {
  width: 18px;
  height: 18px;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--background);
}

.tab-btn.active {
  background: var(--primary);
  color: white;
}

/* Step-by-Step Guide */
.steps-guide {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.step-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
  border-radius: 50%;
  color: white;
}

.step-icon svg {
  width: 16px;
  height: 16px;
}

.step-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.step-number {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.step-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}

.step-connector {
  width: 24px;
  height: 2px;
  background: var(--border);
  border-radius: 1px;
}

.guide-hint {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-style: italic;
}

/* Cards */
.form-card, .result-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  animation: fadeIn 0.3s ease;
}

.card-header {
  margin-bottom: 1.5rem;
}

.card-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.card-header p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Form Elements */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}

.input-group input {
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: all 0.2s ease;
  background: var(--background);
  color: var(--text-primary);
}

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

.input-group input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

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

/* Buttons */
.actions-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  flex: 1;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

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

/* Focus visible for accessibility */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Error states */
.input-group.has-error input {
  border-color: #ef4444;
  background-color: #fef2f2;
}

.input-group.has-error input:focus {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.input-error {
  color: #ef4444;
  font-size: 0.8rem;
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.input-error::before {
  content: "⚠";
  font-size: 0.9rem;
}

/* Form validation summary */
.form-error-summary {
  background: #fef2f2;
  border: 1px solid #ef4444;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  color: #ef4444;
  font-size: 0.9rem;
}

.btn-secondary {
  background: var(--background);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}

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

/* Profile Photo Upload */
.input-group.full-width {
  grid-column: 1 / -1;
}

.photo-upload {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-upload:hover,
.photo-upload:focus,
.photo-upload.drag-over {
  border-color: var(--primary);
  background: var(--background);
}

.photo-upload:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.photo-upload-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.photo-upload-content svg {
  width: 20px;
  height: 20px;
}

.photo-preview {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.photo-preview img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.btn-icon {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn-icon:hover {
  background: var(--border);
  color: var(--text-primary);
}

.btn-icon svg {
  width: 14px;
  height: 14px;
}

.btn-primary svg, .btn-secondary svg {
  width: 18px;
  height: 18px;
}

/* Spinners */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

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

/* QR Code Display */
.result-card {
  text-align: center;
}

.qr-display {
  background: var(--background);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1rem;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#qrCode {
  animation: scaleIn 0.3s ease;
}

#qrCode img {
  max-width: 220px;
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: var(--text-secondary);
}

/* Modal Popup Notification */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal-popup {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 90vw;
  width: 320px;
  animation: scaleIn 0.2s ease;
}

.modal-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--secondary) 0%, #059669 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  color: white;
}

.modal-icon svg {
  width: 28px;
  height: 28px;
}

.modal-message {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.modal-instruction {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.modal-close-btn {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border: none;
  padding: 0.75rem 2rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-close-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.app-footer p {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.app-footer .footer-separator {
  margin: 0 0.25rem;
}

.app-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.app-footer a:hover {
  text-decoration: underline;
}

.heart-icon {
  width: 16px;
  height: 16px;
  color: #ef4444;
  animation: heartbeat 1.5s ease-in-out infinite;
}

.footer-logo {
  height: 48px;
  width: auto;
  vertical-align: middle;
  margin: 0 0.25rem;
  display: inline-block;
  border-radius: 4px;
  padding: 2px 4px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

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

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Responsive */
@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
  }
  
  .actions-row {
    flex-direction: column;
  }
  
  .tabs-container {
    flex-direction: column;
  }
  
  .card-header h2 {
    font-size: 1.1rem;
  }
  
  .main-container {
    padding: 1rem;
  }
  
  .qr-display {
    padding: 1.5rem;
  }
  
  .steps-guide {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
  }
  
  .step {
    width: 100%;
    justify-content: flex-start;
    gap: 0.75rem;
  }
  
  .step-connector {
    display: none;
  }
  
  .step-label {
    font-size: 0.85rem;
    white-space: normal;
  }
  
  .step-number {
    font-size: 0.65rem;
  }
  
  .step-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
  }
  
  .step-icon svg {
    width: 14px;
    height: 14px;
  }
  
  .guide-hint {
    font-size: 0.8rem;
    padding: 0 0.5rem;
  }
}

/* Print Styles */
@media print {
  body {
    background: white !important;
    color: black !important;
  }
  
  .app-header,
  .tabs-container,
  .steps-guide,
  .guide-hint,
  .form-card,
  .app-footer,
  .modal-overlay,
  .theme-toggle {
    display: none !important;
  }
  
  .main-container {
    max-width: 100%;
    padding: 0;
  }
  
  .result-card {
    box-shadow: none !important;
    background: white !important;
    border: none !important;
    display: block !important;
    margin: 0 auto !important;
    page-break-inside: avoid;
  }
  
  .qr-display {
    background: white !important;
    min-height: auto !important;
    padding: 1rem !important;
  }
  
  #qrCode img {
    max-width: 300px !important;
    box-shadow: none !important;
  }
  
  .result-actions {
    display: none !important;
  }
}

/* Screen reader only class */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
  