/* public/css/pages/scan.css — Camera & OCR View */

.camera-container {
  position: relative;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow-lg);
}

.camera-video {
  width: 100%;
  height: 60vh;
  min-height: 400px;
  object-fit: cover;
  display: block;
}

/* === 引導對齊框 === */
.camera-guide-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-guide-box {
  width: 80%;
  height: 45%;
  border: 2px dashed rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-md);
  position: relative;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5); /* 遮罩效果 */
  transition: border-color var(--transition-base);
}

.camera-guide-box::before,
.camera-guide-box::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: var(--primary);
  border-style: solid;
}
.camera-guide-box::before {
  top: -2px; left: -2px;
  border-width: 3px 0 0 3px;
}
.camera-guide-box::after {
  bottom: -2px; right: -2px;
  border-width: 0 3px 3px 0;
}

.camera-guide-text {
  position: absolute;
  bottom: 120px; /* 避開下方控制列 */
  width: 100%;
  text-align: center;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

/* === 控制列 === */
.camera-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px; /* 縮小間距適應手機螢幕 */
  background: linear-gradient(to top, rgba(0,0,0,0.85) 50%, transparent);
}

.camera-controls .btn {
  white-space: nowrap; /* 避免文字斷行 */
  flex-shrink: 0;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.capture-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--text-muted);
  cursor: pointer;
  transition: transform 0.1s;
}
.capture-btn:active {
  transform: scale(0.9);
}

/* === OCR 結果表單 === */
.result-container {
  display: none;
  max-width: 800px;
  margin: 0 auto;
  gap: 24px;
  animation: fadeIn 0.4s ease-out;
}
.result-container.active {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 768px) {
  .result-container.active {
    grid-template-columns: 1fr;
  }
}

.preview-image {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-grid .full-width {
  grid-column: 1 / -1;
}

/* === 批次結果列表 === */
.batch-results-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-card {
  display: flex;
  align-items: stretch;
  padding: 16px;
  gap: 16px;
  transition: all var(--transition-base);
  border: 1px solid var(--glass-border);
}
.result-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary-glow);
}
.result-card.saved {
  opacity: 0.65;
  border-color: rgba(52, 211, 153, 0.3);
}

.result-card-img {
  flex: 0 0 160px;
  min-height: 100px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-elevated);
}
.result-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
}
.result-card-primary {
  font-size: 1.05rem;
}
.result-card-primary strong {
  color: var(--text-primary);
}
.result-card-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.result-card-confidence {
  font-size: 0.8rem;
  color: var(--success);
  margin-top: 2px;
}

.result-card-actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
}

.btn--sm {
  padding: 8px 16px;
  font-size: 0.85rem;
}

/* === Drop Zone === */
.drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

@media (max-width: 768px) {
  .result-card {
    flex-direction: column;
  }
  .result-card-img {
    flex: 0 0 auto;
    height: 150px;
  }
  .result-card-actions {
    flex-direction: row;
    justify-content: flex-end;
  }
}

/* === Mobile Processing Overlay === */
.camera-snapshot {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 5;
}

.mobile-progress-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.3s ease-out;
}

.mobile-progress-overlay .processing-card {
  width: 100%;
  max-width: 320px;
  padding: 32px 24px;
  text-align: center;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

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