:root {
  --primary: #0d6efd;
  --success: #198754;
  --warning: #ffc107;
  --danger: #dc3545;
  --dark: #1a1a2e;
  --darker: #0f0f1a;
}

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

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--dark);
  color: #fff;
  min-height: 100vh;
  overflow-x: hidden;
}

.scanner-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 100vw;
}

.scanner-header {
  background: var(--darker);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.scanner-header h1 {
  font-size: 1.2rem;
  margin: 0;
  font-weight: 600;
}

.scanner-header .mode-badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--primary);
}

.camera-section {
  position: relative;
  background: #000;
  aspect-ratio: 4/3;
  max-height: 40vh;
  overflow: hidden;
}

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

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

.scan-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  animation: scanMove 2s linear infinite;
}

@keyframes scanMove {
  0% { top: 0; }
  50% { top: 100%; }
  100% { top: 0; }
}

.product-info {
  background: var(--darker);
  padding: 16px;
  border-radius: 12px 12px 0 0;
  margin-top: -12px;
  position: relative;
  z-index: 10;
  flex: 1;
}

.product-card {
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.product-sku {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
  word-break: break-all;
}

.product-name {
  font-size: 1rem;
  color: rgba(255,255,255,0.8);
  margin-bottom: 16px;
}

.stock-display {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.stock-box {
  flex: 1;
  background: rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.stock-label {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.6);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.stock-value {
  font-size: 1.75rem;
  font-weight: 700;
}

.stock-value.positive { color: var(--success); }
.stock-value.warning { color: var(--warning); }
.stock-value.danger { color: var(--danger); }

.action-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 12px;
  border: none;
  border-radius: 12px;
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
  min-height: 80px;
}

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

.action-btn.add-1 {
  background: var(--success);
  color: #fff;
}

.action-btn.add-5 {
  background: var(--primary);
  color: #fff;
}

.action-btn.set-qty {
  background: var(--warning);
  color: #000;
}

.action-btn .btn-label {
  font-size: 0.75rem;
  font-weight: 400;
  margin-top: 4px;
}

.qty-input-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.qty-input {
  flex: 1;
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 12px;
  padding: 16px;
  font-size: 1.5rem;
  color: #fff;
  text-align: center;
}

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

.confirm-btn {
  background: var(--success);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 16px 32px;
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.confirm-btn:disabled {
  background: rgba(255,255,255,0.2);
  cursor: not-allowed;
}

.voice-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.voice-btn.listening {
  background: var(--danger);
  animation: pulse 1s infinite;
}

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

.bulk-queue {
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
}

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

.queue-count {
  font-size: 1.25rem;
  font-weight: 600;
}

.queue-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

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

.submit-queue-btn {
  background: var(--success);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
}

.no-product {
  text-align: center;
  padding: 40px 20px;
  color: rgba(255,255,255,0.6);
}

.no-product i {
  font-size: 3rem;
  margin-bottom: 16px;
  display: block;
}

.manual-entry {
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
}

.manual-input {
  width: 100%;
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 12px;
  font-size: 1rem;
  color: #fff;
  margin-bottom: 12px;
}

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

.toast-container {
  position: fixed;
  top: 80px;
  left: 16px;
  right: 16px;
  z-index: 1000;
}

.toast {
  background: var(--darker);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideIn 0.3s ease;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }

@keyframes slideIn {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.mode-tabs {
  display: flex;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 4px;
  margin: 16px;
}

.mode-tab {
  flex: 1;
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  padding: 10px;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
}

.mode-tab.active {
  background: var(--primary);
  color: #fff;
}

.carton-prompt {
  background: rgba(13, 110, 253, 0.2);
  border: 2px solid var(--primary);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  text-align: center;
}

.carton-prompt h3 {
  margin: 0 0 12px 0;
  font-size: 1.1rem;
}

.carton-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.carton-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.install-prompt {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--darker);
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 300;
}

.install-prompt button {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-weight: 600;
  cursor: pointer;
}

.install-prompt .dismiss {
  background: transparent;
  color: rgba(255,255,255,0.6);
}

@media (min-width: 768px) {
  .scanner-container {
    max-width: 500px;
    margin: 0 auto;
  }
}
