/* ==========================================================================
   SPLIT BILL — TASTESKILL EDITORIAL MINIMALISM
   Anti-slop typography, dual-theme (Dark/Light), solid CTAs, mobile-first.
   ========================================================================== */

:root {
  /* Claude-inspired dark mode palette (warm dark espresso charcoal with terracotta orange) */
  --bg-canvas: #181716;
  --bg-card: #262522;
  --bg-surface: #302F2B;
  --bg-hover: #3A3935;
  --header-bg: rgba(24, 23, 22, 0.90);

  --border-subtle: rgba(245, 240, 230, 0.08);
  --border-strong: rgba(245, 240, 230, 0.16);

  --text-primary: #EDECE6;
  --text-secondary: #AEA9A0;
  --text-muted: #7E7A72;
  --text-emerald: #52BA84;
  --text-discount: #E06D53;

  --brand-dot: #DA7756;
  --brand-dot-glow: rgba(218, 119, 86, 0.5);
  --accent-color: #DA7756;

  --btn-solid-bg: #DA7756;
  --btn-solid-text: #FFFFFF;

  --toast-bg: #FAF9F5;
  --toast-text: #181716;

  --font-sans: -apple-system, BlinkMacSystemFont, "Geist", "Inter", "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", "SF Mono", ui-monospace, Menlo, Monaco, Consolas, monospace;
}

[data-theme="light"] {
  /* Claude-inspired warm white palette with orange accent */
  --bg-canvas: #FAF9F5;
  --bg-card: #FFFFFF;
  --bg-surface: #F3F1EC;
  --bg-hover: #EBE8E1;
  --header-bg: rgba(250, 249, 245, 0.92);

  --border-subtle: rgba(45, 35, 25, 0.08);
  --border-strong: rgba(45, 35, 25, 0.16);

  --text-primary: #1F1E1D;
  --text-secondary: #6A6864;
  --text-muted: #918F8A;
  --text-emerald: #CC5A36;
  --text-discount: #D9534F;

  --brand-dot: #CC5A36;
  --brand-dot-glow: rgba(204, 90, 54, 0.4);
  --accent-color: #CC5A36;

  --btn-solid-bg: #CC5A36;
  --btn-solid-text: #FFFFFF;

  --toast-bg: #1F1E1D;
  --toast-text: #FFFFFF;
}

/* Lenis Smooth Scroll Styles */
html.lenis, html.lenis body {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

.lenis.lenis-stopped {
  overflow: hidden;
}

.lenis.lenis-scrolling iframe {
  pointer-events: none;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Tabular Numerals for Financial Figures */
.col-qty, .col-price, .col-footer-val, .b-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Mobile-only Frame Architecture */
.mobile-container {
  max-width: 440px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(48px + env(safe-area-inset-bottom));
  position: relative;
}

@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/fonts/plus-jakarta-sans-800.ttf') format('truetype');
}

/* Zero-Overflow Mobile Header */
.header {
  height: 54px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s ease;
}

.brand:active {
  opacity: 0.75;
}

.brand-title {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: normal;
  color: var(--accent-color);
  line-height: 1;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.95);
  background: var(--bg-surface);
}

/* Main Content Views */
.main-content {
  padding: 16px;
  flex: 1;
}

.view-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hidden {
  display: none !important;
}

/* Upload Dropzone */
.upload-dropzone {
  border: 1.5px dashed var(--border-strong);
  background: var(--bg-card);
  border-radius: 14px;
  padding: 36px 16px;
  text-align: center;
  position: relative;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--border-strong);
  background: var(--bg-surface);
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.upload-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}

.upload-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.upload-text .primary-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

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

/* Demo Card */
.demo-trigger-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.demo-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.demo-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent-color);
}

.demo-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.demo-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-solid-demo {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-solid-demo:active {
  background: var(--bg-hover);
  transform: scale(0.96);
}

/* Theme Switch (Centered directly below Demo Card) */
.theme-switch-centered {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 2px 0 6px 0;
}

.theme-toggle-cluster {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 3px;
  gap: 2px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.theme-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.theme-pill.active {
  background: var(--btn-solid-bg);
  color: var(--btn-solid-text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* Loading Card (No Dots) */
.loader-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 48px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-top: 24px;
}

.pulse-ring {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(128, 128, 128, 0.2);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loader-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.loader-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.scan-bar-track {
  width: 180px;
  height: 3px;
  background: var(--bg-surface);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.scan-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background: var(--text-primary);
  animation: progressPulse 1.4s ease-in-out infinite;
}

@keyframes progressPulse {
  0% { left: -50%; width: 50%; }
  50% { width: 70%; }
  100% { left: 100%; width: 50%; }
}

/* Receipt Header Card */
.receipt-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.receipt-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.receipt-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.receipt-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.receipt-date {
  font-size: 12px;
  color: var(--text-muted);
}

.receipt-preview-thumb {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}

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

.thumb-hint {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.75);
  font-size: 9px;
  text-align: center;
  padding: 2px 0;
  font-weight: 600;
  color: #FFF;
}

/* Editorial Tables */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
}

.table-header-row {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(128, 128, 128, 0.03);
}

.table-heading {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-primary);
}

.table-wrap {
  width: 100%;
  overflow-x: hidden;
}

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

.editorial-table thead tr {
  border-bottom: 1px solid var(--border-subtle);
}

.editorial-table th {
  padding: 8px 14px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-align: left;
}

.editorial-table th.col-qty {
  width: 36px;
  text-align: center;
  white-space: nowrap;
}

.editorial-table th.col-price {
  text-align: right;
  width: 110px;
  white-space: nowrap;
}

.editorial-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.col-qty {
  text-align: center;
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
}

.col-name {
  color: var(--text-primary);
}

.menu-title {
  font-weight: 500;
  display: block;
  line-height: 1.35;
}

.menu-unit-hint {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  display: block;
  margin-top: 2px;
}

.col-price {
  text-align: right;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.table-after .col-price {
  color: var(--text-primary);
}

.table-footer-row td {
  padding: 12px 14px;
  border-top: 1.5px solid var(--border-strong);
  border-bottom: none;
}

.col-footer-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  white-space: nowrap;
}

.col-footer-val {
  text-align: right;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
}

/* Summary Card */
.breakdown-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.b-label {
  color: var(--text-secondary);
}

.b-val {
  font-weight: 600;
  color: var(--text-primary);
}

.text-discount {
  color: var(--text-discount) !important;
}

.text-discount .b-val {
  color: var(--text-discount) !important;
}

.font-bold {
  font-weight: 700;
  color: var(--text-primary) !important;
}

.breakdown-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 0;
}

/* Actions Stack */
.actions-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

/* Solid Primary Button */
.btn-primary-solid {
  background-color: var(--btn-solid-bg);
  color: var(--btn-solid-text);
  font-size: 14px;
  font-weight: 700;
  height: 48px;
  border-radius: 10px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  width: 100%;
  transition: transform 0.1s ease, opacity 0.15s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

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

/* Flat Secondary Button */
.btn-secondary-flat {
  background-color: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  width: 100%;
  transition: all 0.15s ease;
}

.btn-secondary-flat:active {
  background-color: var(--bg-surface);
  transform: scale(0.98);
}

/* Centered Logo Footer */
.result-footer-brand {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 32px 0 16px 0;
}

.result-footer-brand .brand-title {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: normal;
  color: var(--accent-color);
  line-height: 1;
  opacity: 0.9;
}

/* Lightbox Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--modal-backdrop-bg, rgba(0, 0, 0, 0.85));
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  touch-action: none;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--bg-card);
}

.modal-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 8px;
  text-align: center;
}

.modal-body img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
  margin: 0 auto;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: var(--toast-text);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  z-index: 120;
  animation: fadeInOut 2.5s ease forwards;
  white-space: nowrap;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translate(-50%, 10px); }
  15% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -10px); }
}
