/* ===== Shared Chat Mockup Styles ===== */

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f0f0;
  display: flex;
  justify-content: center;
  gap: 40px;
  padding: 30px;
  flex-wrap: wrap;
  padding-top: 60px;
  -webkit-user-select: none;
  user-select: none;
}

:root {
  --primary: #0891b2;
  --primary-dark: #0e7490;
  --primary-light: #06b6d4;
  --gradient: linear-gradient(135deg, #0e7490 0%, #06b6d4 100%);
  --bubble-bg: #ecfeff;
  --bubble-text: #155e75;
  --bubble-border: #a5f3fc;
  --badge-bg: #0891b2;
  --occasion-bg: #ecfeff;
  --occasion-text: #155e75;
  --user-gradient: linear-gradient(135deg, #0e7490, #06b6d4);
  --chat-bg: linear-gradient(to bottom, #f0fdfa, #ccfbf1);
  --product-link-bg: linear-gradient(to right, rgba(236,254,255,0.5), rgba(207,250,254,0.4));
  --product-link-border: rgba(165,243,252,0.4);
}

/* ===== Auth Gate ===== */
body.auth-pending > *:not(.auth-loading):not(script) { display: none !important; }
.auth-loading {
  position: fixed; inset: 0; background: #f0f0f0;
  display: flex; align-items: center; justify-content: center; z-index: 9999;
  font-family: -apple-system, sans-serif; color: #6b7280; font-size: 14px;
}
.auth-loading .spinner {
  width: 24px; height: 24px; border: 3px solid #e5e7eb;
  border-top-color: #0891b2; border-radius: 50%;
  animation: authSpin 0.6s linear infinite; margin-right: 10px;
}
@keyframes authSpin { to { transform: rotate(360deg); } }
.signout-btn {
  position: fixed; top: 10px; right: 16px; z-index: 101;
  padding: 6px 14px; border: none; border-radius: 8px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  background: white; color: #6b7280; box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: all 0.2s;
}
.signout-btn:hover { color: #ef4444; }

/* ===== Nav Bar ===== */
.nav-bar {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 4px; background: white; padding: 4px;
  border-radius: 10px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); z-index: 100;
}
.nav-bar a {
  padding: 6px 14px; border-radius: 8px; font-size: 12px;
  font-weight: 600; text-decoration: none; color: #6b7280;
  transition: all 0.2s;
}
.nav-bar a:hover { color: #374151; background: #f3f4f6; }
.nav-bar a.active { background: var(--primary-dark); color: white; }

/* ===== Device Frame ===== */
.device-frame {
  background: #1a1a1a;
  border-radius: 40px;
  padding: 6px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.3);
  flex-shrink: 0;
}
.device-frame.phone { width: 393px; height: 852px; }
.device-frame.tablet { width: 700px; height: 900px; }
.device-frame.desktop { width: 1100px; height: 750px; border-radius: 36px; }
.device-label {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #666;
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}
.screen {
  background: #fff;
  border-radius: 30px;
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ===== Chat Header ===== */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  color: white;
  flex-shrink: 0;
  background: var(--gradient);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,0.2); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.header-info h3 { font-size: 16px; font-weight: 600; }
.header-info .status { font-size: 11px; opacity: 0.9; display: flex; align-items: center; gap: 4px; }
.status-dot {
  width: 7px; height: 7px; background: #4ade80; border-radius: 50%;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.header-buttons { display: flex; gap: 6px; }
.header-btn {
  width: 36px; height: 36px; border: none; background: rgba(255,255,255,0.2);
  border-radius: 10px; color: white; cursor: pointer; display: flex;
  align-items: center; justify-content: center; font-size: 16px;
  transition: all 0.2s; position: relative;
}
.header-btn:hover { background: rgba(255,255,255,0.35); transform: scale(1.05); }
.header-btn:active { transform: scale(0.95); }

/* Cart icon SVG styling */
.header-btn svg { width: 18px; height: 18px; }
.header-btn .badge {
  position: absolute; top: -5px; right: -5px; background: #22c55e;
  color: white; font-size: 10px; font-weight: 800; width: 20px; height: 20px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  border: 2px solid white; box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* Close button - more prominent */
.header-btn.close-btn {
  background: rgba(255,255,255,0.25);
  border: 1.5px solid rgba(255,255,255,0.4);
}
.header-btn.close-btn:hover { background: rgba(255,255,255,0.45); }
.header-btn.close-btn svg { width: 14px; height: 14px; stroke-width: 2.5; }

/* Language selector button */
.header-btn.lang-btn { font-size: 15px; }
.header-btn.lang-btn .lang-flag { font-size: 16px; line-height: 1; }

/* ===== Language Dropdown ===== */
.lang-dropdown {
  position: absolute; top: 68px; right: 12px; z-index: 60;
  background: white; border-radius: 14px; padding: 6px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2), 0 2px 8px rgba(0,0,0,0.1);
  min-width: 180px; opacity: 0; transform: translateY(-8px) scale(0.95);
  transition: all 0.2s ease; pointer-events: none;
}
.lang-dropdown.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.lang-option {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 10px; cursor: pointer; transition: background 0.15s;
  border: none; background: none; width: 100%; font-size: 13px;
  font-family: inherit; color: #374151;
}
.lang-option:hover { background: #f0fdfa; }
.lang-option.active { background: var(--bubble-bg); color: var(--primary-dark); font-weight: 600; }
.lang-option .lang-opt-flag { font-size: 18px; flex-shrink: 0; display: flex; align-items: center; }
.lang-flag-img { width: 1.2em; height: 1.2em; object-fit: contain; vertical-align: middle; border-radius: 2px; }
.lang-option .lang-opt-label { font-weight: 500; }
.lang-option .lang-opt-code { color: #9ca3af; font-size: 11px; margin-left: auto; text-transform: uppercase; }

/* ===== Mobile Tab Bar ===== */
.tab-bar { display: flex; border-bottom: 2px solid #e5e7eb; flex-shrink: 0; background: white; }
.tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 16px; font-size: 14px; font-weight: 600; color: #9ca3af;
  border: none; background: none; cursor: pointer; position: relative;
  transition: all 0.25s;
}
.tab .tab-icon { font-size: 16px; transition: all 0.25s; }
.tab.active {
  color: var(--primary-dark); background: #f0fdfa;
}
.tab.active .tab-icon { transform: scale(1.1); }
.tab.active::after {
  content: ''; position: absolute; bottom: -2px; left: 12px; right: 12px;
  height: 4px; border-radius: 4px 4px 0 0; background: var(--gradient);
}
.tab:not(.active):hover { color: #6b7280; background: #fafafa; }
.tab-badge {
  font-size: 10px; font-weight: 700; color: white;
  padding: 2px 7px; border-radius: 10px; min-width: 20px;
  text-align: center; background: var(--badge-bg);
  transition: transform 0.3s;
}
.tab-badge.bounce { animation: badgeBounce 0.4s ease; }
@keyframes badgeBounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* ===== Tab Content ===== */
.tab-panel { display: none; flex-direction: column; flex: 1; overflow: hidden; }
.tab-panel.active { display: flex; }

/* ===== Chat Messages ===== */
.messages { flex: 1; padding: 12px; overflow-y: auto; }
.message { margin-bottom: 12px; max-width: 92%; }
.message.assistant { display: flex; gap: 8px; align-items: flex-start; }
.message.user { margin-left: auto; }
.msg-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: #f3f4f6;
  display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0;
}
.msg-bubble { padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.55; }
.msg-bubble.assistant-bubble { background: #f3f4f6; color: #1f2937; border-top-left-radius: 4px; }
.msg-bubble.user-bubble { color: white; border-bottom-right-radius: 4px; background: var(--user-gradient); }

/* In-chat product references */
.product-ref {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; margin-top: 6px; border-radius: 10px;
  background: var(--product-link-bg); border: 1.5px solid var(--product-link-border);
  cursor: pointer; transition: all 0.15s;
}
.product-ref:hover { border-color: var(--primary-light); background: rgba(207,250,254,0.5); }
.product-ref:active { transform: scale(0.98); }
.product-ref-img {
  width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex-shrink: 0;
}
.product-ref-info { flex: 1; min-width: 0; }
.product-ref-name {
  font-size: 13px; font-weight: 600; color: var(--primary-dark);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.product-ref-price { font-size: 12px; color: #6b7280; }
.product-ref-arrow { color: var(--primary); font-size: 14px; flex-shrink: 0; }

/* Quick replies with scroll arrows */
.quick-replies-wrapper {
  display: flex; align-items: center; gap: 0; flex-shrink: 0;
  padding: 0 4px 12px; position: relative;
}
.qr-arrow {
  width: 28px; height: 28px; border: none; border-radius: 50%;
  background: white; color: #9ca3af; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0; transition: all 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  z-index: 2;
}
.qr-arrow:hover { color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.qr-arrow:active { transform: scale(0.92); }
.qr-arrow.hidden { opacity: 0; pointer-events: none; }
.quick-replies {
  display: flex; gap: 6px; overflow-x: auto; flex: 1;
  scroll-behavior: smooth; padding: 2px 6px;
  -ms-overflow-style: none; scrollbar-width: none;
}
.quick-replies::-webkit-scrollbar { display: none; }
.quick-reply {
  flex-shrink: 0; padding: 9px 15px; border-radius: 20px; font-size: 13px;
  font-weight: 500; border: 1px solid var(--bubble-border); background: var(--bubble-bg);
  color: var(--bubble-text); cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.quick-reply:hover { border-color: var(--primary-light); background: #cffafe; }
.quick-reply:active { transform: scale(0.96); }

/* Chat input */
.chat-input {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-top: 1px solid #e5e7eb; flex-shrink: 0; background: white;
}
.chat-input input {
  flex: 1; border: 1px solid #e5e7eb; border-radius: 20px;
  padding: 10px 16px; font-size: 14px; outline: none; transition: border-color 0.2s;
}
.chat-input input:focus { border-color: var(--primary-light); }
.send-btn {
  width: 38px; height: 38px; border: none; border-radius: 50%;
  color: white; cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 16px; background: var(--gradient);
  transition: transform 0.1s;
}
.send-btn:active { transform: scale(0.92); }

/* ===== Products Panel (tab-based) ===== */
.thumbnail-strip {
  display: flex; gap: 8px; padding: 10px 16px; overflow-x: auto;
  flex-shrink: 0; border-bottom: 1px solid #f3f4f6;
}
.thumbnail {
  width: 62px; height: 62px; border-radius: 10px; overflow: hidden;
  flex-shrink: 0; border: 2px solid transparent; cursor: pointer; transition: all 0.2s;
}
.thumbnail.active { border-color: var(--primary); }
.thumbnail:active { transform: scale(0.95); }
.thumbnail img { width: 100%; height: 100%; object-fit: cover; }

.product-list { flex: 1; overflow-y: auto; padding: 12px 16px; scroll-behavior: smooth; }
.product-card {
  background: white; border: 1px solid #e5e7eb; border-radius: 16px;
  overflow: hidden; margin-bottom: 12px; transition: all 0.3s;
}
.product-card:hover { border-color: var(--primary-light); box-shadow: 0 2px 12px rgba(8,145,178,0.1); }
.product-card.highlighted {
  border-color: var(--primary); box-shadow: 0 0 0 2px rgba(8,145,178,0.2), 0 4px 16px rgba(8,145,178,0.15);
}
.product-img { width: 100%; height: 200px; object-fit: cover; background: #f9fafb; }
.product-info { padding: 12px 14px; }
.product-title { font-size: 14px; font-weight: 600; color: #1f2937; margin-bottom: 4px; }
.product-desc {
  font-size: 12px; color: #6b7280; margin-bottom: 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.product-rating { display: flex; align-items: center; gap: 4px; font-size: 11px; color: #6b7280; margin-bottom: 8px; }
.stars { color: #fbbf24; letter-spacing: 1px; }
.product-footer { display: flex; align-items: center; justify-content: space-between; padding: 0 14px 12px; }
.product-price { font-size: 18px; font-weight: 700; color: var(--primary-dark); }
.add-btn {
  padding: 8px 16px; border: none; border-radius: 10px; color: white;
  font-size: 12px; font-weight: 600; cursor: pointer; background: var(--gradient);
  transition: all 0.15s;
}
.add-btn:active { transform: scale(0.95); }
.add-btn.added { background: #22c55e; }
.occasion-badge {
  display: inline-block; font-size: 10px; font-weight: 600;
  padding: 3px 8px; border-radius: 8px; margin-bottom: 8px;
  background: var(--occasion-bg); color: var(--occasion-text);
}

/* ===== Cart Overlay ===== */
.cart-overlay {
  position: absolute; inset: 0; z-index: 50; display: flex;
  flex-direction: column; background: white;
  opacity: 0; transform: translateY(100%);
  transition: all 0.3s ease; pointer-events: none;
}
.cart-overlay.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.cart-overlay-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid #e5e7eb; flex-shrink: 0;
}
.cart-overlay-header h3 { font-size: 16px; font-weight: 700; color: #1f2937; }
.cart-overlay-close {
  width: 32px; height: 32px; border: 1px solid #e5e7eb; border-radius: 8px;
  background: white; cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 16px; color: #6b7280; transition: all 0.2s;
}
.cart-overlay-close:hover { background: #f3f4f6; color: #1f2937; }
.cart-content { flex: 1; overflow-y: auto; padding: 16px; }
.cart-item {
  display: flex; gap: 12px; padding: 12px;
  border: 1px solid #e5e7eb; border-radius: 12px; margin-bottom: 10px;
}
.cart-item-img { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; background: #f9fafb; }
.cart-item-info { flex: 1; }
.cart-item-title { font-size: 13px; font-weight: 600; }
.cart-item-price { font-size: 12px; color: #6b7280; margin-top: 2px; }
.cart-qty { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.cart-qty button {
  width: 26px; height: 26px; border: 1px solid #e5e7eb; border-radius: 6px;
  background: white; cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.cart-qty button:hover { background: #f3f4f6; }
.cart-qty span { font-size: 13px; font-weight: 500; min-width: 20px; text-align: center; }
.cart-footer { padding: 16px; border-top: 1px solid #e5e7eb; background: #f9fafb; flex-shrink: 0; }
.cart-total { display: flex; justify-content: space-between; font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.checkout-btn {
  width: 100%; padding: 14px; border: none; border-radius: 12px;
  color: white; font-size: 14px; font-weight: 600; cursor: pointer;
  background: var(--gradient); transition: transform 0.1s;
}
.checkout-btn:active { transform: scale(0.98); }

/* Toast notification */
.toast {
  position: absolute; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1f2937; color: white; padding: 10px 18px; border-radius: 10px;
  font-size: 12px; font-weight: 500; opacity: 0; transition: all 0.3s;
  z-index: 55; pointer-events: none; white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Scroll highlight flash */
@keyframes highlightFlash {
  0% { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(8,145,178,0.3); }
  100% { border-color: #e5e7eb; box-shadow: none; }
}

/* Typing indicator */
.typing-indicator {
  display: flex; gap: 4px; padding: 10px 14px;
  background: #f3f4f6; border-radius: 16px; border-top-left-radius: 4px;
  width: fit-content;
}
.typing-dot {
  width: 7px; height: 7px; background: #9ca3af; border-radius: 50%;
  animation: typingBounce 1.4s infinite both;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

.hidden { display: none !important; }

/* ===== Tablet/Desktop side-panel layout ===== */
.tablet-chat-side { flex: 1; display: flex; flex-direction: column; border-right: 1px solid #e5e7eb; }
.tablet-drawer { width: 280px; display: flex; flex-direction: column; background: white; position: relative; flex-shrink: 0; }
.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 12px; background: var(--gradient); color: white; flex-shrink: 0;
}
.drawer-header h4 { font-size: 13px; font-weight: 600; }
.drawer-header .drawer-count {
  font-size: 11px; background: rgba(255,255,255,0.25); padding: 2px 8px;
  border-radius: 8px; font-weight: 600;
}
.drawer-product-list { flex: 1; overflow-y: auto; padding: 10px; -ms-overflow-style: none; scrollbar-width: none; }
.drawer-product-list::-webkit-scrollbar { display: none; }
.drawer-card {
  border: 1px solid #e5e7eb; border-radius: 12px; overflow: hidden;
  margin-bottom: 10px; transition: all 0.3s;
}
.drawer-card.highlighted {
  border-color: var(--primary); box-shadow: 0 0 0 2px rgba(8,145,178,0.2);
}
.drawer-card img { width: 100%; height: 140px; object-fit: cover; }
.drawer-card-body { padding: 10px; }
.drawer-card-badge {
  font-size: 9px; font-weight: 600; background: var(--occasion-bg);
  color: var(--occasion-text); padding: 2px 6px; border-radius: 6px;
  display: inline-block; margin-bottom: 6px;
}
.drawer-card-title { font-size: 12px; font-weight: 600; color: #1f2937; }
.drawer-card-desc { font-size: 10px; color: #6b7280; margin-top: 2px; }
.drawer-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.drawer-card-price { font-size: 16px; font-weight: 700; color: var(--primary-dark); }
.drawer-add-btn {
  padding: 5px 10px; border: none; border-radius: 8px;
  background: var(--gradient); color: white; font-size: 10px;
  font-weight: 600; cursor: pointer; transition: all 0.15s;
}
.drawer-add-btn:active { transform: scale(0.95); }

/* ===== Drawer toggle button (absolute, left-side drawer) ===== */
.drawer-toggle {
  position: absolute; top: 50%; z-index: 10;
  transform: translateY(-50%);
  width: 28px; height: 72px;
  background: var(--gradient); color: white;
  border: none; border-radius: 0 8px 8px 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
  box-shadow: 2px 0 8px rgba(0,0,0,0.15);
  transition: all 0.3s;
  padding: 0;
}
.drawer-toggle:hover { width: 32px; background: var(--primary-dark); }
