@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  --bg-primary: #080b11;
  --bg-secondary: #0f131e;
  --bg-tertiary: #161c2c;
  --bg-glass: rgba(15, 19, 30, 0.7);
  --border-glass: rgba(255, 255, 255, 0.08);
  
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  
  --accent-grad: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-purple) 100%);
  --accent-glow: 0 0 20px rgba(139, 92, 246, 0.25);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --font-display: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 30px;
  
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  background-image: 
    radial-gradient(at 10% 20%, rgba(59, 130, 246, 0.05) 0px, transparent 50%),
    radial-gradient(at 90% 80%, rgba(139, 92, 246, 0.05) 0px, transparent 50%);
}

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

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border: 2px solid var(--bg-primary);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Layout */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px;
  gap: 20px;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
  padding: 10px 15px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

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

.logo-icon {
  width: 40px;
  height: 40px;
  background: var(--accent-grad);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  color: white;
  box-shadow: var(--accent-glow);
}

h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 30%, #a78bfa 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: block;
}

/* Control Buttons & Mode Selector */
.header-actions {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

.mode-selector {
  display: flex;
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px 16px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
}

.mode-btn.active {
  background: var(--accent-grad);
  color: white;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

.mode-btn:not(.active):hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

/* File Actions */
.file-actions {
  display: flex;
  gap: 10px;
}

.btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  padding: 8px 16px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--text-muted);
}

.btn-primary {
  background: var(--accent-grad);
  border: none;
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.35);
  transform: translateY(-1px);
}

.btn-accent {
  background: transparent;
  border: 1px solid var(--accent-purple);
  color: var(--accent-purple);
}

.btn-accent:hover {
  background: rgba(139, 92, 246, 0.05);
  border-color: var(--accent-pink);
  color: var(--text-primary);
}

.btn-rose {
  background: transparent;
  border: 1px solid var(--accent-rose);
  color: var(--accent-rose);
}

.btn-rose:hover {
  background: rgba(244, 63, 94, 0.07);
  color: white;
}

#file-upload-input {
  display: none;
}

/* Main Grid Layout */
.main-content {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 20px;
  flex: 1;
  min-height: 0; /* Important for scroll containers */
}

@media (max-width: 1024px) {
  .main-content {
    grid-template-columns: 1fr;
  }
}

/* Left Panel: Image Canvas & Workspace */
.workspace-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  min-height: 500px;
  position: relative;
}

.workspace-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.workspace-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.workspace-status-badge {
  background: rgba(139, 92, 246, 0.1);
  color: var(--accent-purple);
  padding: 2px 10px;
  border-radius: var(--radius-xl);
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid rgba(139, 92, 246, 0.2);
  transition: all var(--transition-fast);
}

.workspace-status-badge.buy-mode {
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-cyan);
  border-color: rgba(6, 182, 212, 0.2);
}

.workspace-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: rgba(0, 0, 0, 0.2);
  overflow: auto;
  padding: 20px;
}

/* Upload Placeholder State */
.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 450px;
  text-align: center;
  padding: 40px;
  border: 2px dashed rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.01);
  transition: all var(--transition-normal);
  cursor: pointer;
}

.upload-placeholder:hover {
  border-color: var(--accent-purple);
  background: rgba(139, 92, 246, 0.02);
  transform: translateY(-2px);
}

.upload-icon {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--accent-purple);
  border: 1px solid var(--border-glass);
}

.upload-placeholder h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
}

.upload-placeholder p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.upload-or {
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Interactive Image Container */
.flyer-wrapper {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  max-height: 75vh;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-sm);
  overflow: hidden;
  user-select: none;
}

#flyer-img {
  display: block;
  max-width: 100%;
  height: auto;
  max-height: 75vh;
  pointer-events: none;
}

/* Overlay representing selection/bounding boxes */
.flyer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: default;
}

.flyer-overlay.draw-active {
  cursor: crosshair;
}

/* Defined Item Box */
.item-box {
  position: absolute;
  border: 2px solid var(--accent-purple);
  background: rgba(139, 92, 246, 0.1);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast), transform var(--transition-fast);
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  
  /* Optimize touch behavior on mobile */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.item-box:hover {
  background: rgba(139, 92, 246, 0.25);
  border-color: var(--accent-pink);
  transform: scale(1.01);
  box-shadow: 0 6px 15px rgba(236, 72, 153, 0.2);
}

.flyer-overlay.buy-active .item-box {
  border-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.08);
}

.flyer-overlay.buy-active .item-box:hover {
  background: rgba(6, 182, 212, 0.2);
  border-color: var(--accent-cyan);
  box-shadow: 0 6px 15px rgba(6, 182, 212, 0.25);
}

/* Hover Tooltip / Label inside box */
.box-label {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  background: rgba(8, 11, 17, 0.95);
  color: white;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  border: 1px solid var(--border-glass);
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}

.item-box:hover .box-label {
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}

/* Quantity badge on box */
.box-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--accent-grad);
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  box-shadow: 0 3px 6px rgba(0,0,0,0.2), var(--accent-glow);
  transform: scale(0);
  transition: transform var(--transition-spring);
}

.box-badge.visible {
  transform: scale(1);
}

/* Temp Box drawing overlay */
.drawing-box {
  position: absolute;
  border: 2px dashed var(--accent-pink);
  background: rgba(236, 72, 153, 0.15);
  border-radius: var(--radius-sm);
  pointer-events: none;
}

.drawing-box.active-highlight {
  border: 2px dashed var(--accent-rose);
  background: rgba(244, 63, 94, 0.15);
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.4);
  animation: pulse-highlight 2s infinite ease-in-out;
}

@keyframes pulse-highlight {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 12px rgba(244, 63, 94, 0.4);
  }
  50% {
    opacity: 0.6;
    box-shadow: 0 0 4px rgba(244, 63, 94, 0.1);
  }
}

/* Right Panel: Shopping Receipt & Lineup */
.receipt-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 120px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.receipt-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.receipt-header h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.receipt-items-container {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Empty Receipt State */
.receipt-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 250px;
  text-align: center;
  color: var(--text-secondary);
}

.receipt-empty-icon {
  font-size: 2.5rem;
  color: var(--text-muted);
}

.receipt-empty-state p {
  font-size: 0.875rem;
  max-width: 250px;
}

/* Receipt Item Card */
.receipt-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  padding: 10px;
  border-radius: var(--radius-md);
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  animation: slideIn var(--transition-normal);
}

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

.receipt-item:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.receipt-item-thumb {
  width: 55px;
  height: 55px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-glass);
  flex-shrink: 0;
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.receipt-item-thumb:hover {
  transform: scale(1.05);
  border-color: var(--accent-cyan);
}

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

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

.receipt-item-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.receipt-item-price {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.receipt-item-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

/* Counter Controls */
.counter {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.counter-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
}

.counter-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.counter-value {
  width: 34px;
  border: none;
  background: transparent;
  color: white;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.875rem;
  outline: none;
}

/* Hide spin buttons */
.counter-value::-webkit-outer-spin-button,
.counter-value::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.receipt-item-subtotal {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent-cyan);
}

.receipt-item-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 0.875rem;
  transition: color var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.receipt-item-delete:hover {
  color: var(--accent-rose);
}

/* Footer of Receipt Card (Calculations & Actions) */
.receipt-footer {
  padding: 20px;
  border-top: 1px solid var(--border-glass);
  background: rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.summary-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.summary-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
}

.total-card {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: var(--radius-md);
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.05);
}

.total-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.total-amount {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.8rem;
  color: #fff;
  text-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
}

.receipt-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(8, 11, 17, 0.4);
  backdrop-filter: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 320px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--border-glass);
  transform: scale(0.9);
  transition: transform var(--transition-spring);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-primary);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-glass);
  color: white;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: all var(--transition-fast);
}

.form-input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 5px;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: var(--radius-xl);
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 1000;
  opacity: 0;
  transition: all var(--transition-spring);
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-icon {
  color: var(--accent-emerald);
}

/* Instructions drawer */
.instructions-panel {
  background: rgba(139, 92, 246, 0.05);
  border: 1px solid rgba(139, 92, 246, 0.1);
  border-radius: var(--radius-md);
  padding: 15px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.instructions-panel h4 {
  color: var(--accent-purple);
  font-family: var(--font-display);
  font-weight: 600;
}

.instructions-panel ul {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Crop Canvas helper (hidden) */
#crop-canvas {
  display: none;
}

/* Global Currency & Exchange Rate Selector */
.global-currency-container {
  display: flex;
  align-items: center;
  gap: 15px;
  background: var(--bg-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
}

.currency-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.currency-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.currency-select {
  padding: 6px 10px;
  font-size: 0.875rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-glass);
  color: white;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  width: auto;
  transition: border-color var(--transition-fast);
}

.currency-select:focus {
  border-color: var(--accent-purple);
}

.exchange-rate-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-left: 1px solid var(--border-glass);
  padding-left: 15px;
  animation: fadeIn var(--transition-fast) forwards;
}

.rate-input-container {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.rate-input {
  width: 80px;
  padding: 6px 8px;
  padding-right: 20px; /* Space for spinner */
  font-size: 0.875rem;
  text-align: right;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-glass);
  color: white;
  outline: none;
  transition: all var(--transition-fast);
}

.rate-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.15);
}

.rate-spinner {
  position: absolute;
  right: 6px;
  width: 10px;
  height: 10px;
  border: 1.5px solid rgba(6, 182, 212, 0.2);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

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

/* JPY Equivalent animation and display */
.jpy-equivalent-container {
  display: flex;
  animation: slideIn var(--transition-normal);
}

/* Autocomplete suggestions */
.autocomplete-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  max-height: 180px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  margin-top: 4px;
}

.autocomplete-suggestion {
  padding: 8px 12px;
  font-size: 0.875rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.autocomplete-suggestion:hover,
.autocomplete-suggestion.active {
  background: var(--accent-grad);
  color: white;
}
/* Shared buttons styling */
.btn-emerald {
  background: transparent;
  border: 1px solid var(--accent-emerald);
  color: var(--accent-emerald);
}

.btn-emerald:hover {
  background: rgba(16, 185, 129, 0.08);
  border-color: #34d399;
  color: white;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Shared warning card styling */
.shared-warning-card {
  display: flex;
  align-items: center;
  gap: 15px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-md);
  padding: 15px;
  text-align: left;
  margin-bottom: 20px;
  width: 100%;
  box-sizing: border-box;
}

.shared-warning-card .warning-icon {
  font-size: 1.75rem;
  color: var(--accent-emerald);
  flex-shrink: 0;
}

.shared-warning-card .warning-text {
  flex: 1;
}

.shared-warning-card .warning-text strong {
  color: var(--text-primary);
  font-size: 0.95rem;
  display: block;
  margin-bottom: 4px;
}

.shared-warning-card .warning-text p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin: 0;
  line-height: 1.4;
}

/* Mobile Tabs Responsive Layout */
.mobile-tabs {
  display: none;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
  margin-bottom: 10px;
}

.mobile-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-fast);
  position: relative;
}

.mobile-tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

.mobile-tab-btn.active {
  background: var(--accent-grad);
  color: white;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

.mobile-receipt-badge {
  background: var(--accent-rose);
  color: white;
  font-size: 0.7rem;
  font-weight: bold;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
  margin-left: 4px;
  animation: badgePop var(--transition-spring);
}

@keyframes badgePop {
  0% { transform: scale(0.6); }
  100% { transform: scale(1); }
}

@media (max-width: 768px) {
  .mobile-tabs {
    display: flex;
  }

  .main-content {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

  .main-content.tab-workspace .receipt-card {
    display: none !important;
  }

  .main-content.tab-receipt .workspace-card {
    display: none !important;
  }

  .workspace-card {
    min-height: 380px;
  }

  .receipt-card {
    max-height: none;
  }

  /* Header adjustments for mobile */
  header {
    flex-direction: column;
    align-items: stretch;
    padding: 15px;
    gap: 12px;
  }

  .logo-section {
    justify-content: center;
  }

  .header-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .global-currency-container {
    justify-content: space-between;
  }

  .mode-selector {
    display: flex;
    justify-content: center;
  }

  .mode-btn {
    flex: 1;
    justify-content: center;
  }

  .file-actions {
    justify-content: center;
  }

  .file-actions label,
  .file-actions button {
    flex: 1;
    justify-content: center;
  }

  /* Popup input form responsive fit */
  .modal-overlay {
    align-items: flex-start;  /* Align to top to stay above keyboard */
    overflow-y: auto;         /* Allow scrolling the background overlay */
    padding: 20px 0;          /* Padding for top and bottom */
  }

  .modal-card {
    max-width: 340px;
    padding: 15px;
    max-height: none;         /* Revert card-specific max-height to scroll background instead */
    overflow-y: visible;
    margin: 0 auto 260px auto; /* Push buttons above keyboard when scrolled */
  }

  /* Lightbox-specific override to keep it centered on mobile */
  #lightbox-modal {
    align-items: center;      /* Always center lightbox content */
    overflow-y: hidden;       /* Disable scrolling background for lightbox */
    padding: 0;
  }
}

/* Modal Crop Preview Styles */
.modal-preview-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-preview-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.modal-preview-wrapper {
  width: 100%;
  max-height: 250px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-glass);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.modal-preview-wrapper img {
  width: 100%;
  height: auto;
  max-height: 242px; /* 250px minus vertical padding */
  object-fit: contain;
}

/* Lightbox Styles */
.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(0.95);
  transition: transform var(--transition-spring);
}

.modal-overlay.active .lightbox-content {
  transform: scale(1);
}

#lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--radius-md);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border-glass);
}

.lightbox-close {
  position: absolute;
  top: -45px;
  right: 0;
  background: transparent;
  border: none;
  color: white;
  font-size: 2.5rem;
  cursor: pointer;
  transition: color var(--transition-fast);
  line-height: 1;
  padding: 4px;
}

.lightbox-close:hover {
  color: var(--accent-rose);
}

/* QR Code & Share Styling */
.btn-indigo {
  background: transparent;
  border: 1px solid #6366f1;
  color: #a5b4fc;
}

.btn-indigo:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: #818cf8;
  color: white;
}

.qr-modal-card {
  max-width: 380px !important;
}

.qr-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
}

.qr-description {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
  margin: 0;
  line-height: 1.4;
}

.qr-code-wrapper {
  background: white;
  padding: 16px;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-code-wrapper img {
  width: 200px;
  height: 200px;
  display: block;
}

.qr-url-display-wrapper {
  display: flex;
  width: 100%;
  gap: 8px;
  box-sizing: border-box;
}

.qr-url-input {
  flex: 1;
  font-size: 0.8rem;
  background: rgba(8, 11, 17, 0.5);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  outline: none;
}

.btn-sm {
  padding: 6px 12px !important;
  font-size: 0.8rem !important;
}


