/**
 * OnesoftPOS - Menu Image Scanner & Batch Import Stylesheet
 */

/* Modal Container */
#scanMenuModal.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
  padding: 16px;
}

#scanMenuModal.modal.open {
  opacity: 1;
  visibility: visible;
}

#scanMenuModal .scan-modal-card {
  background: #ffffff;
  border-radius: 18px;
  width: 95vw;
  max-width: 1280px;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  animation: scanModalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scanModalPop {
  0% { transform: scale(0.95) translateY(12px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* Modal Header */
.scan-modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line, #e2e8f0);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  flex-shrink: 0;
}

.scan-modal-title-area {
  display: flex;
  align-items: center;
  gap: 14px;
}

.scan-title-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.scan-modal-title-area h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  color: var(--ink, #0f172a);
}

.scan-modal-title-area p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted, #64748b);
}

.scan-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.scan-engine-select {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--line, #e2e8f0);
  background: #f8fafc;
  color: #334155;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.scan-engine-select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.scan-close-btn {
  background: transparent;
  border: none;
  font-size: 24px;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  line-height: 1;
  transition: all 0.15s;
}

.scan-close-btn:hover {
  color: #0f172a;
  background: #f1f5f9;
}

/* Modal Body */
.scan-modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
  background: #f8fafc;
}

/* Upload Step (Step 1) */
.scan-step-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 0;
  min-height: 420px;
}

.scan-dropzone {
  width: 100%;
  max-width: 680px;
  border: 2px dashed #cbd5e1;
  border-radius: 18px;
  padding: 40px 24px;
  text-align: center;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.scan-dropzone:hover,
.scan-dropzone.dragover {
  border-color: #6366f1;
  background: #f5f3ff;
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.15);
}

.scan-dropzone-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #eef2ff;
  color: #6366f1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  margin-bottom: 6px;
  transition: transform 0.2s;
}

.scan-dropzone:hover .scan-dropzone-icon {
  transform: scale(1.1);
}

.scan-dropzone h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}

.scan-dropzone p {
  margin: 0;
  font-size: 14px;
  color: #64748b;
  max-width: 440px;
}

.scan-badge-formats {
  display: inline-flex;
  gap: 6px;
  margin-top: 8px;
}

.scan-badge-formats span {
  background: #f1f5f9;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

/* Upload Preview State */
.scan-upload-preview-box {
  width: 100%;
  max-width: 680px;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.scan-preview-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.scan-preview-thumb-wrap {
  width: 80px;
  height: 80px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  flex-shrink: 0;
  position: relative;
  background: #0f172a;
}

.scan-preview-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-preview-meta {
  flex: 1;
  min-width: 0;
}

.scan-preview-filename {
  font-weight: 700;
  font-size: 15px;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scan-preview-size {
  font-size: 13px;
  color: #64748b;
  margin-top: 2px;
}

.scan-preview-reupload-btn {
  background: #f1f5f9;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
}

.scan-preview-reupload-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Optional API key accordion */
.scan-api-key-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
}

.scan-api-key-box summary {
  cursor: pointer;
  font-weight: 600;
  color: #6366f1;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.scan-api-key-box input {
  width: 100%;
  margin-top: 10px;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
}

/* Scanning Animation Overlay */
.scan-loading-card {
  text-align: center;
  padding: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.scan-beam-container {
  position: relative;
  width: 240px;
  height: 180px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid #6366f1;
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.scan-beam-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.9);
}

.scan-beam-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, transparent, #818cf8, #ffffff, #818cf8, transparent);
  box-shadow: 0 0 15px 4px rgba(99, 102, 241, 0.8);
  animation: scanBeamMove 1.6s ease-in-out infinite alternate;
}

@keyframes scanBeamMove {
  0% { top: 0; }
  100% { top: calc(100% - 4px); }
}

.scan-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e2e8f0;
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Step 2: Split Screen Review & Edit */
.scan-step-review {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  height: 100%;
  min-height: 540px;
}

@media (max-width: 1024px) {
  .scan-step-review {
    grid-template-columns: 1fr;
    height: auto;
  }
}

/* Left Panel: Image Preview */
.scan-image-panel {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  max-height: calc(94vh - 160px);
}

.scan-image-panel-head {
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.scan-zoom-controls {
  display: flex;
  gap: 6px;
}

.scan-zoom-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
}

.scan-zoom-btn:hover {
  border-color: #6366f1;
  color: #6366f1;
}

.scan-image-scroll-box {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12px;
  background: #0f172a;
}

.scan-image-scroll-box img {
  max-width: 100%;
  border-radius: 6px;
  transition: transform 0.2s ease;
  transform-origin: top center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Right Panel: Data Table */
.scan-table-panel {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  max-height: calc(94vh - 160px);
}

.scan-table-toolbar {
  padding: 12px 18px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.scan-counts-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.scan-count-pill {
  background: #eef2ff;
  color: #4f46e5;
  font-weight: 700;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 20px;
}

.scan-table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scan-table-actions input {
  padding: 6px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  width: 180px;
}

.scan-table-wrap {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

.scan-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.scan-items-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  z-index: 2;
  white-space: nowrap;
}

.scan-items-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.scan-items-table tr:hover {
  background: #f8fafc;
}

.scan-items-table tr.unselected {
  opacity: 0.45;
  background: #fafafa;
}

/* Inline Form Inputs inside Table */
.scan-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  background: transparent;
  transition: all 0.15s;
  color: #0f172a;
}

.scan-input:hover {
  border-color: #cbd5e1;
  background: #ffffff;
}

.scan-input:focus {
  border-color: #6366f1;
  background: #ffffff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.scan-input.price {
  font-weight: 700;
  color: var(--primary, #ef4b25);
  font-variant-numeric: tabular-nums;
  text-align: right;
  width: 110px;
}

.scan-select {
  padding: 6px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  background: #ffffff;
  color: #0f172a;
  outline: none;
}

.scan-select:focus {
  border-color: #6366f1;
}

.scan-del-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.15s;
}

.scan-del-btn:hover {
  color: #ef4444;
  background: #fef2f2;
}

/* Modal Footer */
.scan-modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--line, #e2e8f0);
  background: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.scan-footer-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #64748b;
}

.scan-footer-status i.fa-bolt {
  color: #f59e0b;
}

.scan-footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.scan-btn-import {
  background: linear-gradient(135deg, #ef4b25, #dc3c17);
  color: #ffffff;
  border: none;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(239, 75, 37, 0.3);
  transition: all 0.15s;
}

.scan-btn-import:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(239, 75, 37, 0.4);
}

.scan-btn-import:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
