/* ══════════════════════════════════════════════════════════════
   INVOICE SPLITTER — styles.css
   Design System: Dark canvas, amber accents, RTL-first
   ══════════════════════════════════════════════════════════════ */

/* ── Reset & tokens ──────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-base: #0d0f14;
  --bg-card: #151820;
  --bg-card2: #1c2030;
  --bg-lane: #181c28;
  --border: #2a2f45;
  --border-hi: #3a4060;
  --amber: #f59e0b;
  --amber-dim: #b45309;
  --amber-glow: rgba(245, 158, 11, 0.18);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.15);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.15);
  --text-1: #f1f5f9;
  --text-2: #94a3b8;
  --text-3: #64748b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  --transition: 180ms ease;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg-base);
  color: var(--text-1);
  font-family: "IBM Plex Sans Arabic", "Inter", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 80px;
}

/* ── Header ──────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 15, 20, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 28px;
  filter: drop-shadow(0 0 8px var(--amber));
}

.logo-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--amber);
}

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

/* ── Sections ─────────────────────────────────────────────────── */
.step-section {
  max-width: 1100px;
  margin: 36px auto 0;
  padding: 0 24px;
  display: none;
}

.step-section.active {
  display: block;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.section-header h2 {
  font-size: 22px;
  font-weight: 600;
}

.step-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--amber);
  color: #000;
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 16px var(--amber-glow);
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-success,
.btn-add,
.btn-ghost-sm {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  font-family: inherit;
}

.btn-primary {
  background: var(--amber);
  color: #000;
}

.btn-primary:hover {
  background: #fbbf24;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--amber-glow);
}

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

.btn-secondary:hover {
  border-color: var(--amber);
  color: var(--amber);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text-1);
  border-color: var(--border-hi);
}

.btn-ghost-sm {
  background: transparent;
  color: var(--text-3);
  border: 1px solid var(--border);
  padding: 8px 14px;
  font-size: 13px;
}

.btn-ghost-sm:hover {
  color: var(--text-2);
  border-color: var(--border-hi);
}

.btn-success {
  background: var(--green);
  color: #000;
}

.btn-success:hover {
  background: #4ade80;
  transform: translateY(-1px);
}

.btn-add {
  background: var(--bg-card2);
  color: var(--amber);
  border: 1px dashed var(--amber-dim);
}

.btn-add:hover {
  background: var(--amber-glow);
}

.full-width {
  width: 100%;
  justify-content: center;
  margin-top: 12px;
}

/* ── Inputs ───────────────────────────────────────────────────── */
.inp {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text-1);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border var(--transition);
}

.inp:focus {
  border-color: var(--amber);
}

.inp::placeholder {
  color: var(--text-3);
}

.inp-sm {
  width: 88px;
}

/* ── Camera Landing ──────────────────────────────────────────── */
.camera-landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 60px 24px;
  text-align: center;
}

/* Pulsing amber ring around the camera button */
.camera-pulse-ring {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-pulse-ring::before,
.camera-pulse-ring::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--amber);
  animation: ring-pulse 2.4s ease-out infinite;
  opacity: 0;
}

.camera-pulse-ring::before {
  width: 140px;
  height: 140px;
  animation-delay: 0s;
}

.camera-pulse-ring::after {
  width: 180px;
  height: 180px;
  animation-delay: 0.8s;
}

@keyframes ring-pulse {
  0% {
    transform: scale(0.85);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.1);
    opacity: 0;
  }
}

/* The big circular camera button itself */
.btn-camera-big {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--amber);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 0 0 6px rgba(245, 158, 11, 0.15),
    0 8px 40px rgba(245, 158, 11, 0.4);
  transition: all 200ms ease;
  color: #000;
  position: relative;
  z-index: 1;
}

.btn-camera-big:hover {
  transform: scale(1.08);
  box-shadow:
    0 0 0 10px rgba(245, 158, 11, 0.12),
    0 12px 50px rgba(245, 158, 11, 0.55);
}

.btn-camera-big:active {
  transform: scale(0.96);
}

/* Text below the button */
.camera-cta-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-1);
  margin: 0;
}

.camera-cta-sub {
  font-size: 14px;
  color: var(--text-2);
  margin: 0;
  max-width: 280px;
}

/* Hint chips row */
.camera-hint-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

.chip {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid var(--amber-dim);
  color: var(--amber);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 99px;
}

/* ── Camera Viewfinder ───────────────────────────────────────── */
.camera-viewfinder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 24px 0;
}

.viewfinder-frame {
  position: relative;
  width: 100%;
  max-width: 560px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4 / 3;
  box-shadow:
    0 0 0 3px var(--amber),
    var(--shadow);
}

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

/* Corner guide marks */
.viewfinder-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.vf-corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: var(--amber);
  border-style: solid;
  opacity: 0.85;
}

.vf-corner.tl {
  top: 12px;
  left: 12px;
  border-width: 3px 0 0 3px;
  border-radius: 4px 0 0 0;
}
.vf-corner.tr {
  top: 12px;
  right: 12px;
  border-width: 3px 3px 0 0;
  border-radius: 0 4px 0 0;
}
.vf-corner.bl {
  bottom: 12px;
  left: 12px;
  border-width: 0 0 3px 3px;
  border-radius: 0 0 0 4px;
}
.vf-corner.br {
  bottom: 12px;
  right: 12px;
  border-width: 0 3px 3px 0;
  border-radius: 0 0 4px 0;
}

.vf-hint {
  font-size: 13px;
  color: var(--text-2);
  text-align: center;
}

/* Controls row: cancel | shutter | flip */
.vf-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  width: 100%;
  max-width: 560px;
  padding: 8px 0 16px;
}

.vf-cancel,
.vf-flip {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  justify-content: center;
  padding: 0;
  font-size: 18px;
}

/* Shutter button */
.btn-shutter {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: transparent;
  border: 4px solid var(--amber);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 120ms ease;
  position: relative;
}

.btn-shutter:hover {
  transform: scale(1.07);
}
.btn-shutter:active {
  transform: scale(0.93);
}

.shutter-inner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #fff;
  transition: background 120ms;
}

.btn-shutter:active .shutter-inner {
  background: var(--amber);
}

/* ── OCR Progress ────────────────────────────────────────────── */

.ocr-progress {
  margin: 24px 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.progress-bar-wrap {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--amber);
  border-radius: 99px;
  transition: width 300ms ease;
}

#ocr-status {
  color: var(--text-1);
  font-size: 14px;
  text-align: center;
  font-weight: 500;
}

.ocr-substatus {
  color: var(--text-3);
  font-size: 12px;
  text-align: center;
  margin-top: 4px;
}

/* Two column */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 24px;
}

@media (max-width: 700px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

.col-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 8px;
}

.col-hint {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 8px;
}

/* Image preview tabs */
.img-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.img-tab {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 99px;
  cursor: pointer;
  transition: all 140ms;
  font-family: inherit;
}

.img-tab.active {
  background: var(--amber);
  color: #000;
  border-color: var(--amber);
}

.receipt-img {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  max-height: 380px;
  object-fit: contain;
  background: #000;
}

.raw-textarea {
  width: 100%;
  resize: vertical;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  padding: 12px;
  font-size: 13px;
  font-family: monospace;
  outline: none;
  transition: border var(--transition);
}

.raw-textarea:focus {
  border-color: var(--amber);
}

/* ── Items table ─────────────────────────────────────────────── */
.items-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.items-table th,
.items-table td {
  padding: 13px 16px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.items-table th {
  background: var(--bg-card2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}

.items-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.items-table tfoot td {
  background: var(--bg-card2);
  font-weight: 700;
  color: var(--amber);
}

.total-row {
}

.btn-del-item {
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 150ms;
}

.btn-del-item:hover {
  color: var(--red);
  background: var(--red-dim);
}

.add-item-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.add-item-row .inp {
  flex: 1;
  min-width: 140px;
}

/* ── Purchaser form ──────────────────────────────────────────── */
.purchaser-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.purchaser-form .inp {
  flex: 1;
  min-width: 200px;
}

.hint {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 20px;
}

.purchasers-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
}

.purchaser-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 40px;
  padding: 8px 16px 8px 8px;
  transition: all var(--transition);
}

.purchaser-chip:hover {
  border-color: var(--border-hi);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: #000;
  flex-shrink: 0;
}

.chip-name {
  font-size: 14px;
  font-weight: 500;
}

.btn-remove-p {
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  margin-right: 4px;
}

.btn-remove-p:hover {
  color: var(--red);
}

/* ── Split layout ────────────────────────────────────────────── */
.split-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 760px) {
  .split-layout {
    grid-template-columns: 1fr;
  }
}

/* Palette */
.items-palette {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: 76px;
  align-self: start;
}

.palette-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge-remaining {
  background: var(--amber-glow);
  color: var(--amber);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: grab;
  transition: all 160ms;
  user-select: none;
}

/* Palette drop highlight when unassigning items */
.drag-over-palette {
  border: 1px dashed var(--amber);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.06);
}

.palette-item:active {
  cursor: grabbing;
}

.palette-item:hover {
  border-color: var(--amber);
  transform: translateX(-2px);
}

.palette-item.dragging {
  opacity: 0.4;
  pointer-events: none;
}

.item-emoji {
  font-size: 20px;
  flex-shrink: 0;
}

.item-info {
  flex: 1;
  min-width: 0;
}

.item-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-price {
  font-size: 11px;
  color: var(--amber);
  margin-top: 2px;
}

/* Lane */
.purchaser-lanes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  align-content: start;
}

.purchaser-lane {
  background: var(--bg-lane);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color 180ms;
  min-height: 200px;
}

.purchaser-lane.drag-over-lane {
  border-color: var(--amber);
  background: rgba(245, 158, 11, 0.06);
}

.lane-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.lane-header .avatar {
  width: 40px;
  height: 40px;
  font-size: 16px;
}

.lane-name {
  font-size: 14px;
  font-weight: 700;
}

.lane-total {
  font-size: 12px;
  color: var(--amber);
  margin-top: 1px;
}

.lane-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}

.lane-empty {
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
  padding: 20px 0;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lane-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  animation: slideIn 160ms ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.lane-item-emoji {
  font-size: 18px;
}

.lane-item-name {
  flex: 1;
  font-size: 13px;
}

.lane-item-qty {
  width: 46px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-1);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 13px;
  text-align: center;
  outline: none;
  font-family: inherit;
}

.lane-item-qty:focus {
  border-color: var(--amber);
}

.lane-item-sub {
  font-size: 11px;
  color: var(--amber);
  min-width: 52px;
  text-align: left;
}

.btn-del-lane {
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 5px;
  border-radius: 4px;
  transition: all 150ms;
}

.btn-del-lane:hover {
  color: var(--red);
  background: var(--red-dim);
}

/* ── Validation bar ──────────────────────────────────────────── */
.validation-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 24px;
  margin-bottom: 20px;
}

.val-label {
  font-size: 12px;
  color: var(--text-3);
  display: block;
}

.val-amount {
  font-size: 22px;
  font-weight: 700;
  font-family: "Inter", sans-serif;
}

.val-sep {
  font-size: 24px;
  color: var(--text-3);
}

.val-indicator {
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.val-ok {
  color: var(--green);
  font-weight: 700;
  font-size: 14px;
}

.val-warn {
  color: var(--red);
  font-weight: 700;
  font-size: 14px;
}

/* ── Summary ─────────────────────────────────────────────────── */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.sc-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.sc-name {
  font-size: 16px;
  font-weight: 700;
}

.sc-total {
  font-size: 20px;
  font-weight: 800;
  color: var(--amber);
  margin-top: 4px;
}

.sc-item-line {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-2);
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}

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

.grand-summary-box {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

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

.gsb-val {
  font-size: 28px;
  font-weight: 800;
  color: var(--green);
  font-family: "Inter", sans-serif;
}

/* ── Step nav ────────────────────────────────────────────────── */
.step-nav {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.step-nav.center {
  justify-content: center;
}

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text-1);
  border-radius: 40px;
  padding: 12px 28px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 999;
  transition:
    opacity 300ms,
    transform 300ms;
}

.toast.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(10px);
}

.toast.success {
  border-color: var(--green);
  color: var(--green);
}

.toast.error {
  border-color: var(--red);
  color: var(--red);
}

/* ── Utilities ───────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

.ocr-result-wrap {
  margin-top: 28px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-hi);
  border-radius: 99px;
}
