/**
 * Mayū AI Assistant — Premium Frontend Stylesheet
 * Brand: Deep Peacock Blue (#0B2B40), Antique Gold (#D4AF37), Warm Ivory (#FAF7F2), Emerald Green (#0F5132)
 * Scoped strictly to #gama-widget-container to never interfere with active theme styles.
 */

:root {
  --gama-primary: #0B2B40;
  --gama-primary-dark: #071E2D;
  --gama-accent: #D4AF37;
  --gama-accent-light: #F4E5B8;
  --gama-bg: #FAF7F2;
  --gama-secondary: #0F5132;
  --gama-surface: #FFFFFF;
  --gama-text: #1E293B;
  --gama-muted: #64748B;
  --gama-border: #E8E0D2;
  --gama-shadow: 0 16px 40px rgba(11, 43, 64, 0.25);
}

#gama-widget-container {
  position: fixed;
  z-index: 999990;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  box-sizing: border-box;
}

#gama-widget-container * {
  box-sizing: border-box;
}

/* Accessible Focus Outlines */
#gama-widget-container button:focus-visible,
#gama-widget-container textarea:focus-visible,
#gama-widget-container a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.5) !important;
}

/* Positioning */
.gama-position-bottom-right {
  bottom: 24px;
  right: 24px;
}

.gama-position-bottom-left {
  bottom: 24px;
  left: 24px;
}

/* 1. Floating Mascot Launcher Button */
.gama-launcher-btn {
  position: relative;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 2.5px solid var(--gama-accent);
  background: var(--gama-primary);
  box-shadow: 0 10px 28px rgba(11, 43, 64, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  outline: none;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.gama-launcher-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 14px 34px rgba(11, 43, 64, 0.45), 0 0 24px rgba(212, 175, 55, 0.55);
}

.gama-launcher-avatar {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--gama-bg);
  position: relative;
}

.gama-launcher-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Launcher Animations (Customizable from Admin) */
.gama-launcher-btn.gama-anim-float {
  animation: gamaFloat 3.6s ease-in-out infinite;
}

.gama-launcher-btn.gama-anim-pulse {
  animation: gamaPulseAura 2.2s infinite;
}

.gama-launcher-btn.gama-anim-bounce {
  animation: gamaBounceMascot 4s ease infinite;
}

@keyframes gamaFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes gamaPulseAura {
  0%, 100% { box-shadow: 0 8px 24px rgba(11, 43, 64, 0.35), 0 0 0 0 rgba(212, 175, 55, 0.7); }
  50% { box-shadow: 0 12px 32px rgba(11, 43, 64, 0.45), 0 0 0 12px rgba(212, 175, 55, 0); }
}

@keyframes gamaBounceMascot {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-9px); }
  60% { transform: translateY(-4px); }
}

.gama-launcher-pulse {
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 2px solid var(--gama-accent);
  opacity: 0.6;
  animation: gamaPulseRing 2.6s infinite;
  pointer-events: none;
}

@keyframes gamaPulseRing {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.16); opacity: 0; }
  100% { transform: scale(1); opacity: 0; }
}

.gama-unread-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #EF4444;
  color: #FFFFFF;
  border-radius: 12px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  border: 2px solid #FFFFFF;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* 2. Welcome Callout Bubble */
.gama-launcher-callout {
  position: absolute;
  bottom: 84px;
  right: 0;
  width: 270px;
  background: var(--gama-bg);
  border: 1.5px solid var(--gama-accent);
  border-radius: 16px;
  padding: 14px 18px;
  box-shadow: 0 10px 30px rgba(11, 43, 64, 0.15);
  color: var(--gama-primary);
  animation: gamaSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: block;
}

.gama-position-bottom-left .gama-launcher-callout {
  right: auto;
  left: 0;
}

.gama-callout-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: var(--gama-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.gama-callout-close:hover {
  color: var(--gama-primary);
  background: rgba(0, 0, 0, 0.05);
}

.gama-callout-title {
  margin: 0 0 4px 0;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--gama-primary);
}

.gama-callout-body {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--gama-text);
}

/* 3. Chat Window Modal */
.gama-chat-window {
  position: absolute;
  bottom: 88px;
  right: 0;
  width: 420px;
  max-width: calc(100vw - 32px);
  height: 630px;
  max-height: calc(100vh - 110px);
  background: var(--gama-bg);
  border: 1.5px solid rgba(212, 175, 55, 0.4);
  border-radius: 20px;
  box-shadow: var(--gama-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: gamaWindowIn 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.gama-position-bottom-left .gama-chat-window {
  right: auto;
  left: 0;
  transform-origin: bottom left;
}

@keyframes gamaWindowIn {
  from { opacity: 0; transform: translateY(24px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

/* Header */
.gama-chat-header {
  background: linear-gradient(135deg, var(--gama-primary) 0%, #0F3C59 60%, var(--gama-secondary) 100%);
  color: #FFFFFF;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--gama-accent);
}

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

.gama-header-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--gama-accent);
  background: var(--gama-bg);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.gama-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gama-online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: #10B981;
  border: 2px solid var(--gama-primary);
  border-radius: 50%;
}

.gama-mascot-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.2;
  letter-spacing: 0.3px;
}

.gama-mascot-subtitle {
  font-size: 11.5px;
  color: #E2E8F0;
  opacity: 0.92;
}

.gama-header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.gama-header-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}

.gama-header-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

/* In-Widget Confirmation Dialog */
.gama-confirm-modal {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(11, 43, 64, 0.65);
  backdrop-filter: blur(3px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: gamaFadeIn 0.2s ease;
}

@keyframes gamaFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.gama-confirm-card {
  background: var(--gama-bg);
  border: 2px solid var(--gama-accent);
  border-radius: 16px;
  padding: 22px;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  max-width: 320px;
}

.gama-confirm-card h4 {
  margin: 0 0 8px 0;
  color: var(--gama-primary);
  font-size: 17px;
  font-weight: 700;
}

.gama-confirm-card p {
  margin: 0 0 18px 0;
  font-size: 13px;
  color: var(--gama-text);
  line-height: 1.45;
}

.gama-confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.gama-btn-confirm-yes {
  background: #DC2626;
  color: #FFFFFF;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.gama-btn-confirm-no {
  background: var(--gama-primary);
  color: #FFFFFF;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

/* Messages Stream */
.gama-messages-stream {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  background: radial-gradient(circle at top right, rgba(212, 175, 55, 0.05), transparent 60%), var(--gama-bg);
}

.gama-msg-row {
  display: flex;
  flex-direction: column;
  max-width: 88%;
}

.gama-msg-user {
  align-self: flex-end;
}

.gama-msg-assistant {
  align-self: flex-start;
}

.gama-msg-bubble {
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.5;
  border-radius: 16px;
  word-break: break-word;
}

.gama-msg-user .gama-msg-bubble {
  background: var(--gama-primary);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
  box-shadow: 0 3px 10px rgba(11, 43, 64, 0.18);
}

.gama-msg-assistant .gama-msg-bubble {
  background: var(--gama-surface);
  color: var(--gama-text);
  border: 1px solid var(--gama-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.gama-msg-assistant .gama-msg-bubble a {
  color: #0369A1;
  font-weight: 600;
  text-decoration: underline;
}

.gama-msg-assistant .gama-msg-bubble strong {
  color: var(--gama-primary);
}

.gama-msg-assistant .gama-msg-bubble ul,
.gama-msg-assistant .gama-msg-bubble ol {
  margin: 6px 0;
  padding-left: 20px;
}

.gama-msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: 11px;
  color: var(--gama-muted);
  margin-top: 4px;
}

.gama-feedback-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 5px;
  font-size: 12px;
  color: var(--gama-muted);
  border-radius: 4px;
  transition: all 0.2s;
}

.gama-feedback-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--gama-primary);
}

/* Product Recommendation Cards */
.gama-cards-carousel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  width: 100%;
}

.gama-product-card {
  display: flex;
  background: var(--gama-surface);
  border: 1px solid var(--gama-border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.04);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.gama-product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(11, 43, 64, 0.12);
  border-color: var(--gama-accent);
}

.gama-card-thumb {
  width: 86px;
  min-width: 86px;
  background: #F1F5F9;
  position: relative;
}

.gama-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gama-card-body {
  padding: 10px 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.gama-card-title {
  margin: 0 0 2px 0;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--gama-primary);
}

.gama-card-author {
  font-size: 11.5px;
  color: var(--gama-muted);
  margin-bottom: 4px;
}

.gama-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  gap: 8px;
}

.gama-card-price {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--gama-secondary);
}

.gama-card-actions {
  display: flex;
  gap: 6px;
}

.gama-btn-card-cart,
.gama-btn-card-view {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
  white-space: nowrap;
  transition: all 0.2s;
}

.gama-btn-card-cart {
  background: var(--gama-primary);
  color: #FFFFFF !important;
  border: 1px solid var(--gama-accent);
}

.gama-btn-card-cart:hover {
  background: var(--gama-primary-dark);
}

.gama-btn-card-view {
  background: var(--gama-bg);
  color: var(--gama-primary) !important;
  border: 1px solid var(--gama-border);
}

.gama-btn-card-view:hover {
  background: #EFE9DE;
  border-color: var(--gama-accent);
}

/* Quick Action Suggestion Carousel */
.gama-quick-prompts-wrap {
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.75);
  border-top: 1px solid var(--gama-border);
}

.gama-quick-prompts-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gama-muted);
  margin-bottom: 6px;
}

.gama-quick-prompts {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.gama-quick-prompts::-webkit-scrollbar {
  display: none;
}

.gama-prompt-pill {
  background: var(--gama-surface);
  border: 1.2px solid var(--gama-border);
  color: var(--gama-primary);
  border-radius: 16px;
  padding: 6px 13px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

.gama-prompt-pill:hover {
  background: var(--gama-bg);
  border-color: var(--gama-accent);
  color: var(--gama-primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(212, 175, 55, 0.2);
}

/* Typing Indicator */
.gama-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 14px;
  background: var(--gama-surface);
  border-radius: 14px;
  align-self: flex-start;
  margin: 0 16px 8px 16px;
  width: fit-content;
  border: 1px solid var(--gama-border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.gama-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--gama-primary);
  border-radius: 50%;
  animation: gamaBounceDot 1.4s infinite ease-in-out both;
}

.gama-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.gama-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes gamaBounceDot {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.gama-typing-text {
  font-size: 11.5px;
  color: var(--gama-muted);
  margin-left: 6px;
}

/* Chat Input Bar */
.gama-chat-form {
  padding: 10px 14px 8px 14px;
  background: var(--gama-surface);
  border-top: 1px solid var(--gama-border);
}

.gama-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gama-bg);
  border: 1.5px solid var(--gama-border);
  border-radius: 26px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.gama-input-wrapper:focus-within {
  border-color: var(--gama-accent);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.22);
}

.gama-input-field {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--gama-text);
  resize: none;
  max-height: 80px;
  line-height: 1.4;
  padding: 6px 0;
}

.gama-btn-mic,
.gama-btn-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}

.gama-btn-mic {
  background: transparent;
  color: var(--gama-muted);
}

.gama-btn-mic:hover {
  color: var(--gama-primary);
  background: rgba(0, 0, 0, 0.05);
}

.gama-btn-mic.listening {
  color: #EF4444;
  animation: gamaPulseRing 1s infinite;
}

.gama-btn-send {
  background: var(--gama-primary);
  color: #FFFFFF;
}

.gama-btn-send:hover {
  background: var(--gama-secondary);
  transform: scale(1.05);
}

.gama-footer-tagline {
  text-align: center;
  font-size: 10.5px;
  color: var(--gama-muted);
  margin-top: 6px;
  letter-spacing: 0.2px;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  .gama-position-bottom-right,
  .gama-position-bottom-left {
    bottom: 16px;
    right: 16px;
    left: auto;
  }

  .gama-chat-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }

  .gama-chat-form {
    padding-bottom: max(10px, env(safe-area-inset-bottom, 12px));
  }
}
