/* ========================================
   竑榮倉庫 - 入庫系統 樣式
   Mobile First Design
   ======================================== */

/* CSS Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  /* 品牌色系 - 來自 Logo */
  --primary: #142864;
  --primary-dark: #0f1d4a;
  --primary-light: #1e3264;
  --secondary: #6e96c8;
  --secondary-light: #a8c0e0;
  
  /* 功能色 */
  --success: #10b981;
  --success-light: #d1fae5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  
  /* 背景色 */
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-gradient: linear-gradient(135deg, #f0f4ff 0%, #f8fafc 100%);
  
  /* 文字色 */
  --text: #1e293b;
  --text-light: #64748b;
  --text-muted: #94a3b8;
  
  /* 邊框和陰影 */
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow: 0 2px 8px rgba(20, 40, 100, 0.08);
  --shadow-md: 0 4px 16px rgba(20, 40, 100, 0.12);
  --shadow-lg: 0 8px 24px rgba(20, 40, 100, 0.16);
  
  /* 圓角 */
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 20px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* App Container */
#app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg-gradient);
}

/* Page Base */
.page {
  padding: 16px;
  min-height: 100vh;
}

.page.hidden {
  display: none;
}

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

/* ========================================
   Header
   ======================================== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border-light);
}

.header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.btn-back {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 16px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.btn-back:hover {
  background: rgba(20, 40, 100, 0.05);
}
  font-size: 16px;
  cursor: pointer;
  padding: 8px;
  margin-left: -8px;
}

.btn-back:hover {
  color: var(--primary-dark);
}

.btn-manual {
  background: none;
  border: 1px solid var(--primary);
  color: var(--primary);
  font-size: 14px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 48px;
  box-shadow: var(--shadow);
  letter-spacing: 0.3px;
}

.btn .icon {
  font-size: 20px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(20, 40, 100, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(20, 40, 100, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(20, 40, 100, 0.3);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-secondary:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.btn-large {
  padding: 16px 32px;
  font-size: 18px;
  border-radius: var(--radius-lg);
}

.btn-primary:active {
  transform: scale(0.98);
}

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

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

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-large {
  width: 100%;
  padding: 16px 24px;
  font-size: 18px;
  min-height: 56px;
}

.btn-small {
  padding: 6px 12px;
  font-size: 14px;
  min-height: 36px;
}

/* ========================================
   Home Page
   ======================================== */
#page-home {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  text-align: center;
  padding-top: 40px;
  background: transparent !important;
}

.page {
  padding: 16px;
  min-height: 100vh;
  padding-top: 40px;
}

.logo-area {
  margin-bottom: 12px;
  background: transparent !important;
}

.logo-area h1 {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.logo-area .subtitle {
  color: var(--text-light);
  font-size: 16px;
}

.action-buttons {
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.version {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-light);
  font-size: 12px;
}

/* ========================================
   Scan Page
   ======================================== */
.scan-area {
  width: 100%;
  margin-bottom: 24px;
}

.camera-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}

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

.scan-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scan-frame {
  width: 70%;
  height: 40%;
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
}

.scan-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-size: 14px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.camera-error {
  text-align: center;
  padding: 48px 24px;
  background: var(--bg-card);
  border-radius: var(--radius);
}

.camera-error p {
  margin-bottom: 16px;
  color: var(--text-light);
}

.result-area {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius);
  text-align: center;
}

.sku-info {
  margin-bottom: 24px;
}

.sku-code {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.sku-name {
  font-size: 16px;
  color: var(--text-light);
}

/* ========================================
   Manual Input Page
   ======================================== */
.form-area {
  padding: 24px 0;
}

.form-group {
  margin-bottom: 24px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-light);
  margin-bottom: 8px;
}

.input-large {
  width: 100%;
  padding: 16px;
  font-size: 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  transition: all 0.25s ease;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

.input-large:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20, 40, 100, 0.1), inset 0 1px 3px rgba(0,0,0,0.05);
}

.input-num {
  width: 60px;
  padding: 12px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  transition: all 0.25s ease;
}

.input-num:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20, 40, 100, 0.1);
}

.error-msg {
  color: var(--danger);
  font-size: 14px;
  margin-top: 12px;
  padding: 12px;
  background: #fef2f2;
  border-radius: var(--radius-sm);
}

.sku-preview {
  margin-top: 24px;
  padding: 20px;
  background: var(--bg-card);
  border: 2px solid var(--success);
  border-radius: var(--radius);
  text-align: center;
}

.sku-preview .sku-code {
  font-size: 24px;
  color: var(--success);
}

/* ========================================
   Quantity Page
   ======================================== */
.sku-badge {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.sku-badge span {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 14px;
}

.badge-code {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

.badge-name {
  background: var(--bg);
  color: var(--text);
}

.quantity-form {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius);
}

.input-with-label {
  display: flex;
  align-items: center;
  gap: 12px;
}

.input-with-label .input-num {
  flex: 1;
}

.input-num {
  width: 100%;
  padding: 12px 16px;
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.input-num:focus {
  outline: none;
  border-color: var(--primary);
}

.unit {
  color: var(--text-light);
  font-size: 14px;
}

.num-pad {
  display: flex;
  align-items: center;
  gap: 16px;
}

.num-btn {
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 28px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.num-btn:hover {
  background: var(--primary-dark);
}

.num-btn:active {
  transform: scale(0.95);
}

.num-pad .input-num {
  flex: 1;
}

.total-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  margin: 24px 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-radius: var(--radius);
}

.total-display span:first-child {
  font-size: 16px;
}

.total-num {
  font-size: 36px;
  font-weight: 700;
}

/* ========================================
   Photo Page
   ======================================== */
.photo-type-selector {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.photo-type-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 16px;
}

.photo-type-btn.active {
  border-color: var(--primary);
  background: #eff6ff;
}

.photo-type-btn .photo-count {
  font-size: 12px;
  color: var(--text-light);
}

.camera-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}

#photo-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.capture-btn {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 72px;
  height: 72px;
  border: 4px solid white;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.capture-btn:active {
  transform: translateX(-50%) scale(0.9);
  background: rgba(255,255,255,0.3);
}

.photo-preview-area {
  margin-top: 16px;
}

.photo-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* 移除舊的縮圖樣式，使用下方新的四分格樣式 */
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.photo-thumb:hover .delete-btn {
  opacity: 1;
}

.photo-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.photo-actions .btn {
  flex: 1;
}

/* ========================================
   Confirm Page
   ======================================== */
.confirm-summary {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.summary-item:last-child {
  border-bottom: none;
}

.summary-item .label {
  color: var(--text-light);
  font-size: 14px;
}

.summary-item .value {
  font-weight: 600;
}

.summary-item.highlight {
  background: #eff6ff;
}

.summary-item.highlight .value {
  color: var(--primary);
  font-size: 20px;
}

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

.confirm-actions .btn {
  flex: 1;
}

/* ========================================
   Success Page
   ======================================== */
#page-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-top: 15vh;
}

.success-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--success);
  color: white;
  font-size: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  animation: popIn 0.3s ease;
}

@keyframes popIn {
  0% { transform: scale(0); }
  80% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

#page-success h2 {
  font-size: 24px;
  margin-bottom: 8px;
}

.success-msg {
  color: var(--text-light);
  margin-bottom: 32px;
}

.record-summary {
  background: var(--bg-card);
  padding: 24px 48px;
  border-radius: var(--radius);
  margin-bottom: 32px;
}

.record-code {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.record-qty {
  font-size: 18px;
  color: var(--text);
}

.success-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 280px;
}

/* ========================================
   Complete Page
   ======================================== */
.complete-info {
  text-align: center;
  margin-bottom: 32px;
}

.complete-info p {
  font-size: 18px;
  margin-bottom: 24px;
}

.batch-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-num {
  font-size: 48px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  color: var(--text-light);
  font-size: 14px;
}

/* ========================================
   Result Page (INBOUND Text)
   ======================================== */
.inbound-text-area {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  max-height: 50vh;
  overflow-y: auto;
}

.inbound-text-area pre {
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.result-actions .btn {
  flex: 1;
}

/* ========================================
   Query Page
   ======================================== */
.query-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.query-options .btn {
  justify-content: flex-start;
  padding-left: 20px;
}

.quick-search {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.quick-search input {
  flex: 1;
}

.quick-search .btn {
  flex-shrink: 0;
}

.query-result {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
}

/* ========================================
   Lists
   ======================================== */
.batch-list,
.records-list,
.photo-gallery {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.list-item:hover {
  background: var(--bg);
}

.list-item:active {
  transform: scale(0.99);
}

.list-item .item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.list-item .item-title {
  font-weight: 600;
  color: var(--primary);
}

.list-item .item-date {
  font-size: 12px;
  color: var(--text-light);
}

.list-item .item-info {
  font-size: 14px;
  color: var(--text-light);
}

.photo-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.gallery-item {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ========================================
   Toast
   ======================================== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 1000;
  animation: toastIn 0.3s ease;
}

.toast.hidden {
  display: none;
}

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

/* ========================================
   Offline Banner
   ======================================== */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--warning);
  color: white;
  text-align: center;
  padding: 8px;
  font-size: 14px;
  z-index: 1001;
}

.offline-banner.hidden {
  display: none;
}

/* ========================================
   Desktop Adjustments (min-width: 768px)
   ======================================== */
@media (min-width: 768px) {
  #app {
    max-width: 600px;
  }
  
  .logo-area h1 {
    font-size: 40px;
  }
  
  .action-buttons {
    flex-direction: row;
    max-width: 400px;
  }
  
  .action-buttons .btn-large {
    flex: 1;
  }
}

/* ========================================
   Large Desktop (min-width: 1024px)
   ======================================== */
@media (min-width: 1024px) {
  #app {
    max-width: 800px;
    padding: 24px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-top: 24px;
    margin-bottom: 24px;
    min-height: calc(100vh - 48px);
  }
}

/* ========================================
   Utility Classes
   ======================================== */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mt-16 {
  margin-top: 16px;
}

.mb-16 {
  margin-bottom: 16px;
}

/* ========================================
   History Section
   ======================================== */
.history-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.history-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.history-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-light);
  font-size: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}

.history-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.history-item:active {
  transform: scale(0.98);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.history-batch {
  font-weight: 600;
  font-size: 16px;
  color: var(--primary);
}

.history-time {
  font-size: 12px;
  color: var(--text-light);
  background: var(--bg);
  padding: 4px 8px;
  border-radius: 12px;
}

.history-summary {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
}

.history-skus {
  font-size: 12px;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Batch Info Bar */
.batch-info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius);
  margin-bottom: 24px;
  font-size: 14px;
}

.batch-info-bar span:first-child {
  font-weight: 600;
}

/* Hint */
.hint {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 8px;
  text-align: center;
}

/* ========================================
   SKU List Page
   ======================================== */
.sku-list {
  margin-bottom: 20px;
}

.sku-list-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

.sku-item {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow);
  border-left: 4px solid var(--secondary);
}

.sku-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.sku-item:active {
  transform: scale(0.98);
}

.sku-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.sku-item-code {
  font-weight: 700;
  font-size: 18px;
  color: var(--primary);
}

.sku-item-qty {
  font-weight: 700;
  font-size: 16px;
  color: var(--primary);
}

.sku-item-detail {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 4px;
}

.sku-item-photos {
  font-size: 12px;
  color: var(--text-light);
}

.sku-item-edit-btn {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
}

.sku-item-edit-btn:active {
  background: var(--primary-dark);
}

.add-sku-btn-area {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.add-sku-btn-area .btn-large {
  width: 100%;
}

/* ========================================
   Confirm List Page
   ======================================== */
.confirm-list {
  margin-bottom: 20px;
}

.confirm-item {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--success);
}

.confirm-item-header {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.confirm-num {
  font-weight: 700;
  color: var(--secondary);
  margin-right: 8px;
  width: 24px;
}

.confirm-sku {
  font-weight: 700;
  color: var(--primary);
  font-size: 18px;
  color: var(--primary);
  flex: 1;
}

.confirm-qty {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.confirm-item-detail {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 4px;
  padding-left: 32px;
}

.confirm-item-photos {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 12px;
  padding-left: 32px;
}

.confirm-item-actions {
  display: flex;
  gap: 8px;
  padding-left: 32px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
}

.btn-secondary {
  background: var(--secondary);
  color: white;
}

.btn-secondary:active {
  background: #475569;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:active {
  background: #dc2626;
}

.confirm-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.confirm-actions .btn {
  width: 100%;
  padding: 16px;
  font-size: 16px;
}

/* SKU List Actions */
.sku-list-actions {
  display: flex;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.sku-list-actions .btn {
  flex: 1;
  padding: 14px;
  font-size: 16px;
}

.success-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 24px;
}

.success-actions .btn {
  width: 100%;
  padding: 16px;
  font-size: 16px;
}

/* 防止雙擊放大 */
* {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button, .btn {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

input {
  font-size: 16px !important; /* 預防 iOS 輸入框 zoom */
}

/* Logo */
.logo-img {
  width: 95%;
  max-width: 500px;
  margin-bottom: 16px;
  background: transparent !important;
}

.history-date {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

.detail-actions {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--border);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  max-width: 430px;
  margin: 0 auto;
}

.detail-actions .btn {
  flex: 1;
  padding: 14px;
}

/* Copy Button Area */
.copy-btn-area {
  padding: 16px;
}

.copy-btn-area .btn {
  width: 100%;
}

.result-actions {
  padding: 0 16px 24px 16px;
}

.result-actions .btn {
  width: 100%;
}

/* Video Camera */
.camera-preview video {
  width: 100%;
  height: 300px;
  object-fit: cover;
  background: #000;
  border-radius: var(--radius);
}

/* Camera Permission Hint */
.camera-permission-hint {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 2px dashed var(--border);
}

.hint-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.hint-sub {
  font-size: 14px;
  color: var(--text-light);
  margin-top: 12px;
  line-height: 1.6;
}

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

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

.page {
  animation: fadeIn 0.3s ease-out;
}

.history-item, .sku-item, .confirm-item {
  animation: fadeIn 0.3s ease-out;
  animation-fill-mode: both;
}

.history-item:nth-child(1), .sku-item:nth-child(1), .confirm-item:nth-child(1) { animation-delay: 0.05s; }
.history-item:nth-child(2), .sku-item:nth-child(2), .confirm-item:nth-child(2) { animation-delay: 0.1s; }
.history-item:nth-child(3), .sku-item:nth-child(3), .confirm-item:nth-child(3) { animation-delay: 0.15s; }
.history-item:nth-child(4), .sku-item:nth-child(4), .confirm-item:nth-child(4) { animation-delay: 0.2s; }
.history-item:nth-child(5), .sku-item:nth-child(5), .confirm-item:nth-child(5) { animation-delay: 0.25s; }

/* Toast Animation */
.toast {
  animation: slideIn 0.3s ease-out;
}

/* Success Icon Animation */
.success-icon {
  animation: pulse 1s ease-in-out infinite;
  font-size: 80px;
  color: var(--success);
}

/* SKU Item Actions - 移到右邊 */
.sku-item-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.sku-item-actions .btn-sm {
  padding: 8px 16px;
  font-size: 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* Upload Box */
.upload-box {
  border: 3px dashed var(--secondary);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  background: var(--bg-card);
  margin-bottom: 20px;
}

.upload-box:hover {
  border-color: var(--primary);
  background: rgba(20, 40, 100, 0.05);
}

.upload-box p {
  color: var(--primary);
  font-weight: 600;
  font-size: 16px;
}

/* Photo Section */
.photo-section {
  margin-bottom: 20px;
}

.photo-section h3 {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.photo-section h3 span {
  background: var(--primary);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
}

/* Photo Grid - 四分格正方形 */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  min-height: 80px;
}

.photo-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  min-width: 70px;
  min-height: 70px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  grid-column: 1 / -1;
  text-align: center;
  padding: 30px;
  color: var(--text-light);
  background: var(--bg-card);
  border-radius: var(--radius);
  font-size: 13px;
}

.photo-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  background: rgba(239,68,68,0.9);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
}

/* Scan Button */
.btn-scan {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary-light) 100%);
  color: white;
  margin-bottom: 16px;
  box-shadow: 0 4px 12px rgba(110, 150, 200, 0.3);
}

.btn-scan:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(110, 150, 200, 0.4);
}

/* Scan Page */
.scan-area {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  max-width: 300px;
  margin: 20px auto;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}

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

.scan-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 70%;
  height: 40%;
  border: 3px solid var(--primary);
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

.scan-hint {
  text-align: center;
  padding: 20px;
  color: var(--text-light);
}

/* OCR Button */
.btn-ocr {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary-light) 100%);
  color: white;
  margin-bottom: 16px;
  box-shadow: 0 4px 12px rgba(110, 150, 200, 0.3);
}

.btn-ocr:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(110, 150, 200, 0.4);
}

/* OCR Page */
.ocr-preview {
  width: 100%;
  max-width: 320px;
  margin: 20px auto;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}

.ocr-preview video,
.ocr-preview img {
  width: 100%;
  display: block;
}

.ocr-hint {
  text-align: center;
  padding: 16px;
  color: var(--text-light);
}

.ocr-actions {
  display: flex;
  gap: 12px;
  padding: 16px;
  justify-content: center;
}

.ocr-actions .btn {
  flex: 1;
  max-width: 200px;
}

.ocr-result {
  padding: 16px;
  margin-top: 16px;
}

.ocr-result h3 {
  font-size: 16px;
  color: var(--primary);
  margin-bottom: 12px;
}

.ocr-text {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  min-height: 60px;
  word-break: break-all;
}

/* Photo Thumbnails */
.photo-thumb {
  position: relative;
  width: calc(33.333% - 8px);
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s;
}

.photo-thumb:hover {
  transform: scale(1.05);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-type-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}

.photo-thumb .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: rgba(239,68,68,0.9);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.photo-thumb:hover .remove-btn {
  opacity: 1;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal.hidden {
  display: none;
}

.modal-content {
  position: relative;
  max-width: 90%;
  max-height: 80%;
}

.modal-content img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--radius);
}

.modal-close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.2);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
}

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

.modal-actions .btn {
  min-width: 100px;
}

/* Camera Fullscreen */
.camera-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #000;
  z-index: 9999;
}

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

.camera-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
}

.camera-top-bar {
  padding: 16px;
  display: flex;
  justify-content: flex-end;
}

.camera-top-bar .btn-back {
  background: rgba(0,0,0,0.5);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 16px;
  cursor: pointer;
}

.camera-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  height: 40%;
  border: 3px solid white;
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
}

.camera-bottom-bar {
  position: absolute;
  bottom: 40px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
}

.capture-btn-large {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: white;
  border: 4px solid var(--primary);
  font-size: 0;
  cursor: pointer;
  transition: transform 0.1s;
}

.capture-btn-large:active {
  transform: scale(0.9);
}

/* 保留舊樣式兼容性 */
.upload-area {
  border: 3px dashed var(--secondary);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  background: var(--bg-card);
}

.upload-area p {
  color: var(--primary);
  font-weight: 600;
}

.upload-hint {
  font-size: 12px;
  color: var(--text-light);
}

/* 鎖定頁面，禁止橫向滾動 */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

.page {
  max-width: 100%;
  overflow-x: hidden;
}

/* 數量輸入框加大 */
.quantity-form input[type="number"],
.quantity-form input {
  font-size: 28px !important;
  height: 60px;
  text-align: center;
}

.quantity-form .form-group label {
  font-size: 18px;
}

/* 首頁往下移 */
#page-home {
  padding-top: 100px;
}

.logo-area {
  margin-top: 40px;
}

/* 所有輸入框加大字體 */
input[type="text"],
input[type="number"],
input {
  font-size: 20px !important;
}

/* SKU 輸入框更大 */
#sku-input,
.sku-input input {
  font-size: 24px !important;
  height: 56px;
}
