/* ═══════════════════════════════════════════
   SCAN INTERFACE
   Optimized for tablet use
   ═══════════════════════════════════════════ */

.scan-page {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--header-height));
  gap: var(--space-4);
}

/* ─── SCAN AREA ─── */
.scan-area {
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  box-shadow: var(--neu);
  padding: var(--space-6);
  text-align: center;
}

.scan-area-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-5);
}

.camera-preview {
  width: 100%;
  max-width: 500px;
  aspect-ratio: 1;
  margin: 0 auto var(--space-5);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  border: 2px dashed rgba(148, 163, 184, 0.3);
}

.camera-preview.active {
  border-color: var(--cyan);
  border-style: solid;
}

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

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

.viewfinder-overlay::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 65%;
  height: 65%;
  border: 3px solid rgba(6, 182, 212, 0.6);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.15);
}

.viewfinder-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--cyan);
  border-style: solid;
  border-width: 0;
}

.viewfinder-corner.tl { top: 17.5%; left: 17.5%; border-top-width: 4px; border-left-width: 4px; border-radius: 4px 0 0 0; }
.viewfinder-corner.tr { top: 17.5%; right: 17.5%; border-top-width: 4px; border-right-width: 4px; border-radius: 0 4px 0 0; }
.viewfinder-corner.bl { bottom: 17.5%; left: 17.5%; border-bottom-width: 4px; border-left-width: 4px; border-radius: 0 0 0 4px; }
.viewfinder-corner.br { bottom: 17.5%; right: 17.5%; border-bottom-width: 4px; border-right-width: 4px; border-radius: 0 0 4px 0; }

.scan-laser {
  position: absolute;
  left: 17.5%;
  right: 17.5%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  box-shadow: 0 0 8px var(--cyan);
  animation: laser-scan 2.5s ease-in-out infinite;
  opacity: 0.8;
}

@keyframes laser-scan {
  0%, 100% { top: 20%; }
  50% { top: 75%; }
}

.scan-input-wrapper {
  display: flex;
  gap: var(--space-3);
  max-width: 500px;
  margin: 0 auto;
}

.scan-input-wrapper .form-input {
  font-size: var(--text-lg);
  padding: 14px 18px;
  font-family: var(--font-mono);
  text-align: center;
  letter-spacing: 0.05em;
}

.scan-controls {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  margin-top: var(--space-4);
}

/* ─── ORDER INFO AFTER SCAN ─── */
.scan-order-info {
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  box-shadow: var(--neu);
  padding: var(--space-6);
  animation: slide-up var(--duration-enter) var(--ease-out);
}

.scan-order-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.scan-order-number {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--cyan);
}

.scan-order-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.scan-detail-item .info-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-1);
}

.scan-detail-item .info-value {
  font-size: var(--text-base);
  font-weight: var(--font-medium);
}

/* ─── STEP INDICATOR ─── */
.step-indicator {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  padding: var(--space-4) 0;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  position: relative;
  min-width: 80px;
  flex: 1;
  max-width: 140px;
}

.step-item::after {
  content: '';
  position: absolute;
  top: 20px;
  left: calc(50% + 24px);
  width: calc(100% - 48px);
  height: 2px;
  background: var(--bg-secondary);
}

.step-item:last-child::after { display: none; }

.step-item.done::after { background: var(--mint); }
.step-item.active::after { background: var(--cyan); }

.step-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  position: relative;
  z-index: 1;
  transition: all var(--duration-normal) var(--ease-out);
}

.step-item.waiting .step-circle {
  background: var(--bg-secondary);
  color: var(--text-muted);
}

.step-item.active .step-circle {
  background: var(--cyan);
  color: var(--white);
  box-shadow: 0 0 0 4px var(--cyan-subtle), 0 4px 12px rgba(6, 182, 212, 0.3);
  animation: step-active-pulse 2s ease-in-out infinite;
}

.step-item.done .step-circle {
  background: var(--mint);
  color: var(--white);
}

.step-item.done .step-circle::after {
  content: '';
  width: 12px;
  height: 6px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  margin-top: -2px;
}

.step-name {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
}

.step-item.active .step-name { color: var(--cyan); font-weight: var(--font-semibold); }
.step-item.done .step-name { color: var(--mint); }

@keyframes step-active-pulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--cyan-subtle), 0 4px 12px rgba(6, 182, 212, 0.3); }
  50% { box-shadow: 0 0 0 8px var(--cyan-subtle), 0 4px 20px rgba(6, 182, 212, 0.4); }
}

/* ─── ACTION BUTTONS ─── */
.scan-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.scan-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-height: 80px;
  width: 100%;
  border-radius: var(--radius-lg);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--white);
  transition: all var(--duration-normal) var(--ease-out);
  position: relative;
  overflow: hidden;
}

.scan-action-btn svg {
  width: 28px;
  height: 28px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.scan-action-btn.start {
  background: var(--mint);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.3);
}

.scan-action-btn.start:hover {
  background: #0ea271;
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(16, 185, 129, 0.4);
}

.scan-action-btn.end {
  background: var(--cyan);
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.3);
}

.scan-action-btn.end:hover {
  background: var(--cyan-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(6, 182, 212, 0.4);
}

.scan-action-btn.rework {
  background: var(--amber);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.3);
}

.scan-action-btn.rework:hover {
  background: #d97706;
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(245, 158, 11, 0.4);
}

.scan-action-btn:active {
  transform: translateY(0);
}

.scan-action-btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ─── FULL SCREEN FEEDBACK ─── */
.scan-feedback {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: feedback-in var(--duration-enter) var(--ease-spring);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.scan-feedback.success {
  background: rgba(16, 185, 129, 0.92);
  color: var(--white);
}

.scan-feedback.error {
  background: rgba(239, 68, 68, 0.92);
  color: var(--white);
}

.scan-feedback.rework {
  background: rgba(245, 158, 11, 0.92);
  color: var(--white);
}

.scan-feedback-icon {
  width: 120px;
  height: 120px;
  margin-bottom: var(--space-8);
  animation: feedback-icon var(--duration-enter) var(--ease-spring);
}

.scan-feedback-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
}

.scan-feedback-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-3);
}

.scan-feedback-subtitle {
  font-size: var(--text-lg);
  opacity: 0.9;
}

.scan-feedback-countdown {
  position: absolute;
  bottom: var(--space-10);
  font-size: var(--text-sm);
  opacity: 0.7;
}

@keyframes feedback-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes feedback-icon {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

/* ─── REWORK DIALOG ─── */
.rework-dialog {
  background: var(--glass-bg-strong);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow-elevated);
}

.rework-dialog h3 {
  margin-bottom: var(--space-5);
}

.rework-step-select {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.rework-step-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast);
  border: 2px solid transparent;
}

.rework-step-option:hover {
  background: var(--cyan-subtle);
}

.rework-step-option.selected {
  border-color: var(--cyan);
  background: var(--cyan-subtle);
}

.rework-step-option input[type="radio"] {
  accent-color: var(--cyan);
}

/* ─── SCAN IDLE STATE ─── */
.scan-idle {
  text-align: center;
  padding: var(--space-16) var(--space-8);
}

.scan-idle-icon {
  width: 100px;
  height: 100px;
  margin: 0 auto var(--space-6);
  opacity: 0.2;
}

.scan-idle-icon svg {
  width: 100%;
  height: 100%;
  stroke: var(--text-muted);
  fill: none;
  stroke-width: 1;
}

.scan-idle-text {
  font-size: var(--text-lg);
  color: var(--text-muted);
}

/* ─── RESPONSIVE ─── */
@media (min-width: 768px) {
  .scan-actions {
    flex-direction: row;
  }
  .scan-action-btn {
    flex: 1;
  }
}

@media (max-width: 768px) {
  .step-indicator {
    gap: var(--space-1);
  }
  .step-item {
    min-width: 50px;
  }
  .step-circle {
    width: 32px;
    height: 32px;
    font-size: var(--text-xs);
  }
  .step-name {
    font-size: 10px;
  }
  .scan-order-details {
    grid-template-columns: repeat(2, 1fr);
  }
  .camera-preview {
    aspect-ratio: 4/3;
  }
}
