/* ── Variables ─────────────────────────────────────── */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-card: #ffffff;
  --bg-input: #f0f0f0;
  --accent: #89b800;
  --accent-hover: #7aa300;
  --danger: #e74c3c;
  --danger-hover: #c0392b;
  --text-primary: #1a1a1a;
  --text-secondary: #555555;
  --text-muted: #999999;
  --border: #e0e0e0;
  --msg-agent: #f0f4e4;
  --msg-user: #89b800;
  --shadow: 0 2px 12px rgba(0,0,0,0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

/* ── App Layout ───────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 1fr 320px;
  height: 100vh;
  gap: 0;
}

/* ── Left: Digital Counter ────────────────────────── */
.counter {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.counter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #025d00;
  border-bottom: none;
  color: white;
}

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

.agent-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #025d00;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.counter-header h1 {
  font-size: 16px;
  font-weight: 600;
}

.status {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
}

.status.connected {
  color: #89b800;
}

.status.speaking {
  color: #f1c40f;
}

.end-call-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--danger);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.end-call-btn:hover {
  background: var(--danger-hover);
}

/* Product Display */
.product-display {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.product-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.product-placeholder {
  text-align: center;
  color: var(--text-muted);
}

.product-placeholder p {
  margin-top: 12px;
  font-size: 18px;
}

.product-placeholder .hint {
  font-size: 13px;
  margin-top: 4px;
}

/* Product Card */
.product-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 400px;
  width: 100%;
}

.product-card img {
  max-width: 280px;
  max-height: 240px;
  object-fit: contain;
  border-radius: 12px;
  background: white;
  padding: 12px;
}

.product-card .product-name {
  font-size: 20px;
  font-weight: 600;
  text-align: center;
}

.product-card .product-price {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}

/* Product list (multiple results) */
.product-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 600px;
}

.product-list-item {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.product-list-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

.product-list-item img {
  width: 100%;
  height: 100px;
  object-fit: contain;
  border-radius: 6px;
  background: white;
  padding: 6px;
  margin-bottom: 8px;
}

.product-list-item .item-name {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
}

.product-list-item .item-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}

/* Action buttons */
.product-actions {
  display: flex;
  gap: 12px;
  padding: 12px 20px;
  justify-content: center;
}

.product-actions.hidden {
  display: none;
}

.action-btn {
  flex: 1;
  max-width: 200px;
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

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

.action-btn.confirm {
  background: var(--accent);
  color: white;
}

.action-btn.confirm:hover {
  background: var(--accent-hover);
}

.action-btn.reject {
  background: var(--danger);
  color: white;
}

.action-btn.reject:hover {
  background: var(--danger-hover);
}

/* ── Chat Section ─────────────────────────────────── */
.chat-section {
  display: flex;
  flex-direction: column;
  max-height: 280px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}

.chat-msg.agent {
  align-self: flex-start;
  background: var(--msg-agent);
  border-bottom-left-radius: 4px;
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--msg-user);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-msg.interim {
  opacity: 0.5;
  font-style: italic;
}

.chat-msg .msg-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.chat-msg.user .msg-label {
  color: rgba(255,255,255,0.7);
}

/* Chat Input */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
}

.chat-input-area input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input-area input::placeholder {
  color: var(--text-muted);
}

.chat-input-area input:focus {
  border-color: var(--accent);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.mic-btn {
  background: transparent;
  color: var(--text-secondary);
}

.mic-btn.active {
  background: var(--accent);
  color: white;
}

.mic-btn:hover {
  background: var(--accent);
  color: white;
}

.send-btn {
  background: var(--accent);
  color: white;
}

.send-btn:hover {
  background: var(--accent-hover);
}

/* ── Right: Cart Sidebar ──────────────────────────── */
.cart-sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  height: 100vh;
}

.cart-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: #025d00;
  color: white;
}

.cart-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: white;
}

.cart-store {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  margin-top: 2px;
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.cart-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
}

.cart-empty .hint {
  font-size: 13px;
  margin-top: 4px;
}

/* Cart item */
.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

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

.cart-item-info {
  flex: 1;
}

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

.cart-item-qty {
  font-size: 12px;
  color: var(--text-secondary);
}

.cart-item-price {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  margin-left: 12px;
}

/* Cart footer */
.cart-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

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

.cart-total span:first-child {
  font-size: 16px;
  font-weight: 500;
}

.total-amount {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}

.finalizar-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.finalizar-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.finalizar-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.finalizar-btn:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ── Connect Overlay ──────────────────────────────── */
.connect-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.connect-overlay.hidden {
  display: none;
}

.connect-card {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  max-width: 360px;
  width: 90%;
  box-shadow: var(--shadow);
}

.connect-icon {
  color: var(--accent);
  margin-bottom: 16px;
}

.connect-card h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.connect-card p {
  color: var(--text-secondary);
  font-size: 14px;
}

.connect-btn {
  margin-top: 20px;
  padding: 14px 32px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.connect-btn:hover {
  background: var(--accent-hover);
}

.connect-btn.hidden {
  display: none;
}

.connect-error {
  color: var(--danger);
  margin-top: 12px;
  font-size: 13px;
}

.connect-error.hidden {
  display: none;
}

/* Spinner */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 20px auto 0;
  animation: spin 0.8s linear infinite;
}

.spinner.hidden {
  display: none;
}

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

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

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

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

::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  .cart-sidebar {
    height: auto;
    max-height: 40vh;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .product-card img {
    max-width: 200px;
    max-height: 180px;
  }

  .chat-section {
    max-height: 200px;
  }
}
