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

body {
  font-family: 'Outfit', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #ffffff;
  color: #1e293b;
  line-height: 1.5;
  min-height: 100vh;
}

/* Nav Styles */
.nav {
  background: #ffffff;
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 40;
}

.nav-container {
  max-width: 80rem;
  margin: 0 auto;
  padding: 0 1rem;
}

.nav-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 3.5rem;
}

.nav-logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.nav-logo-image {
  height: 2rem;
  width: auto;
}

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

.nav-status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  background: #dbeafe;
  color: #1e40af;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid #93c5fd;
}

/* Wizard Page */
.wizard-page {
  min-height: calc(100vh - 3.5rem);
  padding: 1.5rem 1rem 3rem;
}

.wizard-container {
  max-width: 72rem;
  margin: 0 auto;
}

/* Progress Section */
.progress-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.progress-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.progress-count {
  font-size: 0.875rem;
  font-weight: 600;
  color: #2563eb;
}

.progress-bar {
  height: 0.5rem;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb 0%, #60a5fa 100%);
  border-radius: 9999px;
  transition: width 0.5s ease;
}

.progress-steps {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.progress-step {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.progress-step.pending {
  background: rgba(255, 255, 255, 0.05);
  color: #64748b;
  border-color: rgba(255, 255, 255, 0.1);
}

.progress-step.current {
  background: #2563eb;
  color: white;
  border-color: #60a5fa;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
}

.progress-step.completed {
  background: #10b981;
  color: white;
  border-color: #34d399;
}

.progress-step.required {
  position: relative;
}

.progress-step.required::after {
  content: '*';
  position: absolute;
  top: -4px;
  right: -4px;
  color: #f59e0b;
  font-size: 0.875rem;
  font-weight: 700;
}

.progress-step:hover:not(.current) {
  transform: scale(1.1);
  border-color: #2563eb;
}

/* Step Info */
.step-info {
  text-align: center;
  margin-bottom: 1.5rem;
}

.step-number {
  font-size: 0.875rem;
  font-weight: 500;
  color: #2563eb;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.step-title {
  font-size: 2rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

@media (min-width: 768px) {
  .step-title {
    font-size: 2.5rem;
  }
}

.step-desc {
  font-size: 1rem;
  color: #64748b;
  max-width: 40rem;
  margin: 0 auto 0.75rem;
}

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

.requirement-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.requirement-badge.required {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.requirement-badge.optional {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.requirement-text {
  font-size: 0.875rem;
  color: #475569;
}

/* Camera Section */
.camera-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 1024px) {
  .camera-section {
    grid-template-columns: 1fr 280px;
  }
}

.camera-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  overflow: hidden;
}

/* Camera View */
.camera-view {
  padding: 1.5rem;
}

.video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 0.75rem;
  overflow: visible; /* Allow button to be visible outside container */
  background: #000;
  margin-bottom: 1.25rem;
}

/* Mobile: Keep desktop-style contained camera window */
@media (max-width: 640px) {
  .video-container {
    /* Keep contained, not full screen */
    position: relative;
    aspect-ratio: 16/9;
    overflow: visible;
  }
  
  .camera-view {
    padding: 1.5rem;
  }
}

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

/* Video element on mobile - no rotation needed */
@media (max-width: 640px) {
  .video-element {
    object-fit: contain;
  }
}

.video-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* In fullscreen mode, overlay should cover entire container */
body.fullscreen-active .video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
}

.video-overlay img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0.7;
  mix-blend-mode: overlay;
}

.video-overlay svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.category-label {
  position: absolute;
  top: 1rem;
  left: 1rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  background: rgba(0, 0, 0, 0.5);
  padding: 0.75rem 1.25rem;
  border-radius: 0.75rem;
  backdrop-filter: blur(8px);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  z-index: 10;
  max-width: 70%;
  line-height: 1.2;
  transform-origin: left top;
  transition: transform 0.3s ease;
}

/* Fullscreen overlay - covers camera feed when not in fullscreen */
.fullscreen-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 35;
  backdrop-filter: blur(4px);
}

body.fullscreen-active .fullscreen-overlay {
  display: none;
}

/* iOS Orientation Lock Reminder Overlay */
.ios-orientation-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1005;
  backdrop-filter: blur(8px);
}

.ios-orientation-content {
  background: #ffffff;
  border-radius: 1rem;
  padding: 2rem;
  max-width: 90%;
  width: 400px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.ios-orientation-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 1rem;
}

.ios-orientation-message {
  font-size: 1rem;
  color: #64748b;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.ios-orientation-ok-button {
  width: 100%;
  padding: 0.875rem 2rem;
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #2563eb 0%, #2563eb 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
  transition: all 0.2s;
}

.ios-orientation-ok-button:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.ios-orientation-ok-button:active {
  transform: translateY(0);
}

@media (max-width: 640px) {
  .ios-orientation-content {
    padding: 1.5rem;
    width: 85%;
  }
  
  .ios-orientation-title {
    font-size: 1.25rem;
  }
  
  .ios-orientation-message {
    font-size: 0.9375rem;
  }
}

/* Large fullscreen button in center */
.fullscreen-button-large {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 3rem;
  background: rgba(59, 130, 246, 0.9);
  color: white;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 1.5rem;
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: 600;
  transition: all 0.3s ease;
  min-width: 200px;
}

.fullscreen-button-large:hover {
  background: rgba(59, 130, 246, 1);
  transform: scale(1.05);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4);
}

.fullscreen-button-large:active {
  transform: scale(0.98);
}

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

.fullscreen-text {
  font-size: 1.125rem;
}

/* Small fullscreen button (shown in fullscreen mode, top right) */
.fullscreen-button {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1003;
  backdrop-filter: blur(8px);
  transition: background 0.2s ease, transform 0.2s ease;
}

body.fullscreen-active .fullscreen-button {
  display: flex;
}

.fullscreen-button:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: scale(1.1);
}

.fullscreen-button:active {
  transform: scale(0.95);
}

@media (max-width: 640px) {
  .category-label {
    font-size: 1.125rem;
    padding: 0.5rem 1rem;
    top: 0.75rem;
    left: 0.75rem;
  }
}

/* Simple Level Indicator: Horizontal line parallel to ground */
.level-line-indicator {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 33;
  pointer-events: none;
  transform: translateY(-50%);
}

/* In fullscreen landscape mode, move indicator to bottom center */
body.fullscreen-active .level-line-indicator {
  top: auto;
  bottom: 2rem;
  left: 50%;
  right: auto;
  width: auto;
  height: auto;
  transform: translateX(-50%);
}


.level-line {
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  background-color: rgba(251, 191, 36, 0.8); /* Yellow */
  transform: translateX(-50%);
  pointer-events: none;
}

/* In fullscreen landscape mode, line is horizontal at bottom */
body.fullscreen-active .level-line {
  left: 0;
  top: 0;
  width: 100%;
  height: 2px;
  transform: none;
  background-color: rgba(251, 191, 36, 0.8) !important; /* Yellow */
}

.level-angle-display {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translateX(-50%) translateY(-50%);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.5);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
}

/* In fullscreen landscape mode, angle display above the line */
body.fullscreen-active .level-angle-display {
  left: 50%;
  top: -2rem;
  transform: translateX(-50%);
}

/* iOS portrait-locked fullscreen: rotate and move level indicator to left edge */
body.ios-device.fullscreen-active.ios-fullscreen-portrait .level-line-indicator {
  top: 50%;
  left: 0.75rem;
  right: auto;
  bottom: auto;
  width: auto;
  height: auto;
  transform: rotate(90deg) translateY(-50%);
  transform-origin: left center;
}

body.ios-device.fullscreen-active.ios-fullscreen-portrait .level-line {
  left: 0;
  top: 0;
  width: 100%;
  height: 2px;
  transform: none;
}

body.ios-device.fullscreen-active.ios-fullscreen-portrait .level-angle-display {
  left: 50%;
  top: -2rem;
  transform: translateX(-50%);
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .level-angle-display {
    font-size: 0.7rem;
  }
}

.camera-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.8);
}

.error-content {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 0.75rem;
  padding: 1.5rem;
  max-width: 20rem;
  text-align: center;
}

.error-title {
  font-weight: 600;
  font-size: 1rem;
  color: #fca5a5;
  margin-bottom: 0.5rem;
}

.error-msg {
  font-size: 0.875rem;
  color: #fecaca;
  margin-bottom: 0.75rem;
}

.error-tips {
  font-size: 0.75rem;
  text-align: left;
  list-style: disc;
  list-style-position: inside;
  color: #fecaca;
}

.doi-permission {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
}

.doi-button {
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  background: #2563eb;
  color: white;
  font-size: 0.75rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
}

.doi-button:hover {
  background: #2563eb;
}

/* Capture Button - Floating Round Button */
.capture-button {
  position: absolute;
  right: 2.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(8px);
  border: 3px solid rgba(255, 255, 255, 0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 30;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  padding: 0;
}

.capture-button::before {
  content: '';
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(255, 255, 255, 1);
  transition: all 0.2s ease;
}

.capture-button:hover {
  background: rgba(255, 255, 255, 0.4);
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.capture-button:active {
  transform: translateY(-50%) scale(0.95);
}

.capture-button:active::before {
  background: rgba(255, 255, 255, 0.8);
}

/* Hide capture icon and text */
.capture-button .capture-icon,
.capture-button span {
  display: none;
}

/* Mobile adjustments - position at bottom center */
@media (max-width: 768px) {
  .capture-button {
    right: auto;
    left: 50%;
    top: auto;
    bottom: 3.5rem;
    transform: translateX(-50%);
    width: 3.5rem;
    height: 3.5rem;
  }
  
  .capture-button:hover {
    transform: translateX(-50%) scale(1.1);
  }
  
  .capture-button:active {
    transform: translateX(-50%) scale(0.95);
  }
  
  .capture-button::before {
    width: 2.5rem;
    height: 2.5rem;
  }
}

.capture-button:active {
  transform: translateY(0);
}

.capture-icon {
  width: 1.5rem;
  height: 1.5rem;
  border: 3px solid white;
  border-radius: 50%;
  position: relative;
}

.capture-icon::after {
  content: '';
  position: absolute;
  inset: 3px;
  background: white;
  border-radius: 50%;
}

/* Preview View */
.preview-view {
  padding: 1.5rem;
}

.preview-container {
  position: relative;
  width: 100%;
  /* Remove fixed aspect-ratio to preserve original image orientation */
  min-height: 200px;
  border-radius: 0.75rem;
  overflow: hidden;
  background: #000;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-image {
  max-width: 100%;
  max-height: 70vh;
  width: auto;
  height: auto;
  object-fit: contain;
  image-orientation: from-image; /* Respect EXIF orientation */
}

.preview-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.preview-actions.has-accept-next {
  grid-template-columns: 1fr 1fr 1fr;
}

.preview-actions.has-accept-finish {
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.preview-actions.has-accept-finish .accept-and-finish-button {
  grid-column: 1 / -1;
}

.action-button {
  padding: 1rem 1.5rem;
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.retake-button {
  background: #f1f5f9;
  color: #1e293b;
  border: 1px solid #cbd5e1;
}

.retake-button:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.accept-button {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.accept-button:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-1px);
}

.accept-and-next-button {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.accept-and-next-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-1px);
}

.accept-and-next-button:disabled {
  background: rgba(16, 185, 129, 0.2);
  color: rgba(255, 255, 255, 0.4);
  box-shadow: none;
  cursor: not-allowed;
}

.accept-and-finish-button {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.accept-and-finish-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.accept-and-finish-button:disabled {
  background: rgba(139, 92, 246, 0.2);
  color: rgba(255, 255, 255, 0.4);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Multi-photo Section */
.multi-photos {
  padding: 1rem 1.5rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.multi-photos-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.multi-photos-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #475569;
}

.multi-photos-count {
  font-size: 0.875rem;
  color: #2563eb;
}

.multi-photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.multi-photo-thumb {
  position: relative;
  aspect-ratio: 16/9;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: all 0.2s ease;
}

.multi-photo-thumb:hover {
  border-color: #2563eb;
  transform: scale(1.05);
}

.multi-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-orientation: from-image; /* Respect EXIF orientation */
}

.multi-photo-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.9);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-more-button {
  width: 100%;
  padding: 0.75rem;
  border-radius: 0.5rem;
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px dashed rgba(59, 130, 246, 0.3);
  cursor: pointer;
  transition: all 0.2s;
}

.add-more-button:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.5);
}

/* Tips Sidebar */
.tips-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tips-card,
.settings-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  padding: 1.25rem;
}

.tips-title,
.settings-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.75rem;
}

.tips-list {
  font-size: 0.8125rem;
  color: #475569;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tips-list li {
  padding-left: 1.25rem;
  position: relative;
}

.tips-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: #2563eb;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: #475569;
  margin-bottom: 0.75rem;
}

.settings-row:last-child {
  margin-bottom: 0;
}

.color-picker {
  width: 2rem;
  height: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.25rem;
  cursor: pointer;
  background: transparent;
}

.opacity-slider {
  width: 5rem;
  accent-color: #2563eb;
}

.grid-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  width: 100%;
  justify-content: space-between;
}

.grid-toggle input {
  accent-color: #2563eb;
  width: 1rem;
  height: 1rem;
}

/* Wizard Navigation */
.wizard-nav {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  align-items: center;
}

@media (max-width: 1023px) {
  .wizard-nav {
    grid-template-columns: 1fr;
  }
}

.nav-button {
  padding: 0.875rem 2rem;
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.prev-button {
  justify-self: start;
}

.next-button {
  justify-self: end;
}

.prev-button {
  background: #f1f5f9;
  color: #1e293b;
  border: 1px solid #cbd5e1;
}

.prev-button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
}

.prev-button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.next-button {
  background: linear-gradient(135deg, #2563eb 0%, #2563eb 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.next-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  transform: translateY(-1px);
}

.next-button:disabled {
  background: #cbd5e1;
  color: #94a3b8;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Wizard Actions */
.wizard-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  margin-bottom: 1.5rem;
}

.wizard-button {
  padding: 1rem 2.5rem;
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 180px;
}

.cancel-button {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.cancel-button:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
}

.submit-button {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.submit-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-1px);
}

.submit-button:disabled {
  background: rgba(16, 185, 129, 0.2);
  color: rgba(255, 255, 255, 0.4);
  box-shadow: none;
  cursor: not-allowed;
}

.download-button {
  background: linear-gradient(135deg, #2563eb 0%, #2563eb 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.download-button:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  transform: translateY(-1px);
}

.download-button:disabled {
  background: #cbd5e1;
  color: #94a3b8;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Summary Section */
.summary-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  padding: 1.5rem;
}

.summary-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 1rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.summary-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.summary-item:hover {
  border-color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.summary-item:hover .summary-item-label {
  color: #2563eb;
}

.summary-item-image-container {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.summary-item-image {
  width: 100%;
  height: auto;
  max-height: 200px;
  object-fit: contain; /* Preserve original aspect ratio */
  image-orientation: from-image; /* Respect EXIF orientation */
}

.summary-item-label {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  color: #475569;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-item.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16/9;
  color: #94a3b8;
  font-size: 0.75rem;
}

.summary-item.empty::before {
  content: '📷';
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
  opacity: 0.5;
}

/* Prevent scrolling when in fullscreen to keep address bar hidden */
body.fullscreen-active {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100svh; /* Use small viewport height to account for Safari address bar */
  max-height: 100vh; /* Fallback for browsers that don't support svh */
}

/* Full screen camera when in fullscreen mode */
body.fullscreen-active .camera-view {
  padding: 0;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100svh; /* Use small viewport height to account for Safari address bar */
  max-height: 100vh; /* Fallback for browsers that don't support svh */
  z-index: 1000;
  background: #000;
}

body.fullscreen-active .video-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100svh; /* Use small viewport height to account for Safari address bar */
  max-height: 100vh; /* Fallback for browsers that don't support svh */
  aspect-ratio: unset;
  border-radius: 0;
  margin-bottom: 0;
  z-index: 1001;
}

body.fullscreen-active .video-element {
  width: 100%;
  height: 100%;
  object-fit: contain; /* Use contain to show 16:9 aspect ratio without cropping */
  background: #000; /* Black background for letterboxing/pillarboxing */
}

/* Fullscreen mode: Progress section moved to video-container */
/* Original progress-section is hidden in fullscreen */
body.fullscreen-active .progress-section:not(.fullscreen-progress) {
  display: none !important;
}

/* Ensure progress section is visible when NOT in fullscreen on iOS */
body.ios-device:not(.fullscreen-active) .progress-section {
  display: block !important;
}

/* Fullscreen progress section inside video-container */
#progress-section-fullscreen.fullscreen-progress {
  position: absolute !important;
  top: 0 !important;
  left: 50% !important;
  right: auto !important;
  transform: translateX(-50%) !important;
  z-index: 1002 !important; /* Above video but below other UI elements */
  margin: 0 !important;
  margin-top: 0.75rem !important;
  border-radius: 0.75rem !important;
  padding: 0.5rem 1rem !important;
  background: rgba(0, 0, 0, 0.1) !important; /* More translucent */
  /* backdrop-filter: blur(8px) !important; */
  border: none !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.5rem !important;
  visibility: visible !important;
  opacity: 0.6 !important;
  pointer-events: auto !important;
  width: auto !important;
  height: auto !important;
  min-height: auto !important;
  box-sizing: border-box !important;
}

/* iOS portrait-locked fullscreen: rotate progress section to match overlay */
body.ios-device.fullscreen-active.ios-fullscreen-portrait #progress-section-fullscreen.fullscreen-progress {
  top: 10rem !important;
  bottom: auto !important;
  right: 3rem !important;
  left: auto !important;
  transform: rotate(90deg) translateX(63%)!important;
  transform-origin: right center !important;
}

/* Fullscreen progress section styles */
#progress-section-fullscreen.fullscreen-progress .progress-header {
  display: none !important;
}

/* Hide progress bar in fullscreen - only show steps */
#progress-section-fullscreen.fullscreen-progress .progress-bar {
  display: none !important;
}

#progress-section-fullscreen.fullscreen-progress .progress-steps {
  display: flex !important;
  gap: 0.5rem !important;
  flex-wrap: nowrap !important;
  overflow-x: auto !important;
  scrollbar-width: none !important;
  margin: 0 !important;
}

#progress-section-fullscreen.fullscreen-progress .progress-steps::-webkit-scrollbar {
  display: none !important;
}

#progress-section-fullscreen.fullscreen-progress .progress-step {
  flex-shrink: 0 !important;
  width: 2.25rem !important;
  height: 2.25rem !important;
  font-size: 0.8rem !important;
  background: rgba(255, 255, 255, 0.25) !important;
  color: rgba(255, 255, 255, 0.9) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.4) !important;
  backdrop-filter: blur(4px) !important;
}

#progress-section-fullscreen.fullscreen-progress .progress-step.completed {
  background: rgba(59, 130, 246, 0.7) !important;
  color: white !important;
  border-color: rgba(59, 130, 246, 0.9) !important;
}

#progress-section-fullscreen.fullscreen-progress .progress-step.current {
  background: rgba(251, 191, 36, 0.8) !important;
  color: white !important;
  border-color: rgba(251, 191, 36, 1) !important;
}

/* Progress bar is hidden in fullscreen - only steps are shown */

/* Category label at top left in fullscreen (landscape orientation) */
body.fullscreen-active .category-label {
  position: fixed !important;
  top: 0.75rem !important;
  left: 1rem !important;
  z-index: 1003 !important;
  font-size: 1.25rem !important;
  padding: 0.5rem 1rem !important;
  transform: none !important; /* No rotation for landscape */
}

/* Step title and desc at top center in fullscreen (landscape orientation) */
body.fullscreen-active .step-title {
  position: fixed !important;
  top: 4rem !important;
  left: 50% !important;
  transform: translateX(-50%) !important; /* Only horizontal centering, no rotation */
  z-index: 9999 !important; /* Very high z-index for Android Chrome */
  background: rgba(0, 0, 0, 0.8) !important; /* More opaque for better visibility */
  backdrop-filter: blur(8px) !important;
  color: white !important;
  padding: 0.5rem 1.5rem !important;
  border-radius: 0.75rem !important;
  font-size: 1.1rem !important;
  font-weight: 700 !important;
  margin: 0 !important;
  pointer-events: none !important;
  display: block !important;
  opacity: 1 !important; /* Force opacity */
  white-space: nowrap !important;
  visibility: visible !important; /* Force visibility for Android Chrome */
}

/* Hide step-title on iOS in fullscreen mode */
body.ios-device.fullscreen-active .step-title {
  display: none !important;
  visibility: hidden !important;
}

/* Original step-desc is hidden in fullscreen */
body.fullscreen-active .step-desc:not(.fullscreen-step-desc) {
  display: none !important;
}

/* Fullscreen step-desc inside video-container */
#stepDesc-fullscreen.fullscreen-step-desc {
  position: absolute !important;
  top: 0.75rem !important;
  right: 0 !important;
  left: auto !important;
  z-index: 1002 !important;
  background: rgba(0, 0, 0, 0.1) !important; /* Translucent */
  backdrop-filter: blur(4px) !important;
  color: white !important;
  padding: 0.5rem 1rem !important;
  border-radius: 0.75rem !important;
  font-size: 0.9rem !important;
  max-width: 20% !important;
  text-align: right !important;
  margin: 0 !important;
  pointer-events: none !important;
  display: block !important;
  opacity: 0.6 !important;
  visibility: visible !important;
  box-sizing: border-box !important;
  line-height: 1.4 !important;
}

/* iOS portrait-locked fullscreen: rotate step desc to match overlay */
body.ios-device.fullscreen-active.ios-fullscreen-portrait #stepDesc-fullscreen.fullscreen-step-desc {
  top: 36rem !important;
  bottom: auto !important;
  right: 5rem !important;
  left: auto !important;
  max-width: 30% !important;
  transform: rotate(90deg) !important;
  transform-origin: right center !important;
}

/* Hide step-info when in fullscreen, but keep step-title and step-desc visible */
body.fullscreen-active .step-info {
  position: relative;
}

body.fullscreen-active .step-info > *:not(.step-title):not(.step-desc) {
  display: none;
}

/* Capture button in fullscreen mode */
body.fullscreen-active .capture-button {
  position: fixed;
  z-index: 1003;
}

@media (min-width: 641px) {
  body.fullscreen-active .capture-button {
    right: 1.5rem;
    left: auto;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
  }
}

@media (max-width: 640px) {
  body.fullscreen-active .capture-button {
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
  }
}

/* Responsive */
@media (max-width: 640px) {
  .wizard-page {
    padding: 0; /* Remove padding since progress bar is fixed */
    padding-top: calc(3.5rem + 3rem); /* Nav height + progress bar height */
  }

  .step-info {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
  }

  .step-title {
    font-size: 1.5rem;
  }

  .wizard-nav {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0 1rem;
  }

  .prev-button,
  .next-button {
    justify-self: stretch;
  }

  .wizard-actions {
    flex-direction: column;
    padding: 1rem;
  }

  .wizard-button {
    width: 100%;
  }
  
  /* Camera section margin can be overridden by JS */
  .camera-section {
    margin-top: 0;
  }
  
  /* Allow JS to override margin-top */
  .camera-section[style*="margin-top"] {
    margin-top: var(--camera-section-margin-top, 0) !important;
  }
}

