/* =============================================================
   Gleaming Glitz — Premium Chat Widget
   File: assets/css/gg-chat.css
   Fully scoped — no conflicts with Bootstrap or existing CSS
   ============================================================= */

/* ── CSS Variables ─────────────────────────────────────────── */
.gg-chat-root {
  --ggc-gold:        #C9A24D;
  --ggc-gold2:       #F0D48B;
  --ggc-gold-grad:   linear-gradient(135deg, #C9A24D, #F0D48B);
  --ggc-bg:          #FDFCF9;
  --ggc-white:       #ffffff;
  --ggc-ivory:       #FAF9F6;
  --ggc-text:        #111827;
  --ggc-muted:       #6b7280;
  --ggc-border:      #e8e4dc;
  --ggc-dark:        #0b0b0c;
  --ggc-radius:      20px;
  --ggc-radius-sm:   12px;
  --ggc-shadow:      0 24px 60px rgba(0,0,0,.16), 0 8px 20px rgba(0,0,0,.08);
  --ggc-shadow-fab:  0 8px 32px rgba(201,162,77,.35), 0 4px 12px rgba(0,0,0,.18);
  --ggc-font:        'Poppins', system-ui, -apple-system, sans-serif;
  --ggc-font-serif:  'Playfair Display', Georgia, serif;
  --ggc-z:           9000;
  --ggc-transition:  cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: var(--ggc-font);
}

/* ── Reset within widget ───────────────────────────────────── */
.gg-chat-root *,
.gg-chat-root *::before,
.gg-chat-root *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.gg-chat-root button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--ggc-font);
}

.gg-chat-root a {
  text-decoration: none;
  color: inherit;
}

/* ── FAB (Floating Action Button) ─────────────────────────── */
#gg-chat-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;       /* standard position — WhatsApp button removed */
  z-index: var(--ggc-z);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--ggc-gold-grad);
  box-shadow: var(--ggc-shadow-fab);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: transform 0.25s var(--ggc-transition), box-shadow 0.25s ease;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

#gg-chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(201,162,77,.50), 0 6px 16px rgba(0,0,0,.22);
}

#gg-chat-fab:focus-visible {
  outline: 3px solid var(--ggc-gold);
  outline-offset: 3px;
}

#gg-chat-fab svg {
  width: 26px;
  height: 26px;
  color: #141414;
  transition: transform 0.3s ease;
}

#gg-chat-fab.gg-chat-fab--open svg {
  transform: rotate(90deg) scale(0.85);
}

/* FAB notification badge */
#gg-chat-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.3s ease, transform 0.3s var(--ggc-transition);
  pointer-events: none;
}

#gg-chat-badge.gg-chat-badge--visible {
  opacity: 1;
  transform: scale(1);
  animation: ggBadgePulse 2s infinite;
}

@keyframes ggBadgePulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1.15); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* ── Proactive Teaser Bubble ──────────────────────────────── */
#gg-chat-teaser {
  position: fixed;
  right: 94px;
  bottom: 30px;
  z-index: calc(var(--ggc-z) + 1);
  background: #1c1a17;
  color: #fff;
  border: 1px solid rgba(201,162,77, 0.6);
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  box-shadow: 0 10px 35px rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px) scale(0.95);
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  max-width: 260px;
}

#gg-chat-teaser.gg-chat-teaser--visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.gg-chat-teaser-close {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  border-radius: 50%;
  margin-left: 4px;
}
.gg-chat-teaser-close:hover {
  color: var(--ggc-gold);
}

/* ── Chat Window ───────────────────────────────────────────── */
#gg-chat-window {
  position: fixed;
  right: 24px;
  bottom: 98px;       /* fab bottom(24) + fab height(60) + gap(14) */
  z-index: var(--ggc-z);
  width: 380px;
  height: 600px;
  max-height: 80vh;
  background: var(--ggc-bg);
  border-radius: var(--ggc-radius);
  box-shadow: var(--ggc-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(201,162,77,.18);

  /* Animation */
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s var(--ggc-transition);
}

#gg-chat-window.gg-chat-window--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Chat Header ───────────────────────────────────────────── */
.gg-chat-header {
  background: var(--ggc-dark);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  border-bottom: 1px solid rgba(201,162,77,.2);
}

.gg-chat-header-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(201,162,77,.5);
  flex-shrink: 0;
}

.gg-chat-header-logo-fallback {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ggc-gold-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--ggc-font-serif);
  font-weight: 800;
  font-size: 15px;
  color: #141414;
  letter-spacing: 0.5px;
}

.gg-chat-header-info {
  flex: 1;
  min-width: 0;
}

.gg-chat-header-brand {
  font-family: var(--ggc-font-serif);
  font-weight: 700;
  font-size: 15px;
  color: #ffffff;
  letter-spacing: 0.2px;
  line-height: 1.2;
}

.gg-chat-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
}

.gg-chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  animation: gg-pulse 2.5s ease infinite;
  flex-shrink: 0;
}

@keyframes gg-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.65; transform: scale(0.85); }
}

.gg-chat-status-text {
  font-size: 11px;
  color: rgba(255,255,255,.65);
  font-weight: 500;
}

.gg-chat-header-subtitle {
  font-size: 10px;
  color: var(--ggc-gold);
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-top: 2px;
}

.gg-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.gg-chat-header-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.7);
  background: transparent;
  transition: background 0.18s ease, color 0.18s ease;
  border: none;
  cursor: pointer;
}

.gg-chat-header-btn:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.gg-chat-header-btn:focus-visible {
  outline: 2px solid var(--ggc-gold);
  outline-offset: 2px;
}

.gg-chat-header-btn svg {
  width: 16px;
  height: 16px;
}

/* Dropdown menu */
.gg-chat-menu {
  position: absolute;
  top: 58px;
  right: 12px;
  background: var(--ggc-white);
  border-radius: var(--ggc-radius-sm);
  box-shadow: 0 8px 30px rgba(0,0,0,.15);
  border: 1px solid var(--ggc-border);
  overflow: hidden;
  z-index: 10;
  min-width: 180px;
  opacity: 0;
  transform: translateY(-8px) scale(0.95);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.gg-chat-menu.gg-chat-menu--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

.gg-chat-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ggc-text);
  cursor: pointer;
  transition: background 0.15s ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.gg-chat-menu-item:hover {
  background: var(--ggc-ivory);
}

.gg-chat-menu-item svg {
  width: 16px;
  height: 16px;
  color: var(--ggc-muted);
  flex-shrink: 0;
}

.gg-chat-menu-divider {
  height: 1px;
  background: var(--ggc-border);
  margin: 4px 0;
}

/* Language section in menu */
.gg-chat-lang-section {
  padding: 8px 12px;
  border-top: 1px solid var(--ggc-border);
}

.gg-chat-lang-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--ggc-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 4px 4px 8px;
}

.gg-chat-lang-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.gg-chat-lang-pill {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--ggc-border);
  background: var(--ggc-ivory);
  font-size: 11px;
  font-weight: 600;
  color: var(--ggc-text);
  cursor: pointer;
  transition: all 0.18s ease;
}

.gg-chat-lang-pill:hover,
.gg-chat-lang-pill.active {
  border-color: var(--ggc-gold);
  background: rgba(201,162,77,.1);
  color: #8a6b25;
}

/* ── Messages Area ─────────────────────────────────────────── */
.gg-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: var(--ggc-ivory);
}

.gg-chat-messages::-webkit-scrollbar {
  width: 4px;
}

.gg-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.gg-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(201,162,77,.3);
  border-radius: 999px;
}

/* Date separator */
.gg-chat-date-sep {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--ggc-muted);
  letter-spacing: 0.5px;
  margin: 6px 0;
  position: relative;
}

.gg-chat-date-sep::before,
.gg-chat-date-sep::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 50px);
  height: 1px;
  background: var(--ggc-border);
}

.gg-chat-date-sep::before { left: 0; }
.gg-chat-date-sep::after  { right: 0; }

/* ── Message Bubbles ───────────────────────────────────────── */
.gg-chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: gg-msg-in 0.3s var(--ggc-transition) both;
}

@keyframes gg-msg-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Bot message — left aligned */
.gg-chat-msg--bot {
  align-self: flex-start;
  align-items: flex-start;
}

/* Customer message — right aligned */
.gg-chat-msg--user {
  align-self: flex-end;
  align-items: flex-end;
}

.gg-chat-bubble {
  padding: 11px 14px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
  max-width: 100%;
}

/* Bot bubble */
.gg-chat-msg--bot .gg-chat-bubble {
  background: var(--ggc-white);
  color: var(--ggc-text);
  border: 1px solid var(--ggc-border);
  border-bottom-left-radius: 5px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}

/* Customer bubble */
.gg-chat-msg--user .gg-chat-bubble {
  background: var(--ggc-gold-grad);
  color: #141414;
  border-bottom-right-radius: 5px;
  box-shadow: 0 4px 12px rgba(201,162,77,.25);
}

.gg-chat-msg-time {
  font-size: 10px;
  color: var(--ggc-muted);
  margin-top: 4px;
  padding: 0 4px;
}

/* ── Typing Indicator ──────────────────────────────────────── */
.gg-chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
  background: var(--ggc-white);
  border: 1px solid var(--ggc-border);
  border-radius: 18px;
  border-bottom-left-radius: 5px;
  width: fit-content;
  align-self: flex-start;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  animation: gg-msg-in 0.3s var(--ggc-transition) both;
}

.gg-chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ggc-gold);
  display: block;
}

.gg-chat-typing span:nth-child(1) { animation: gg-dot 1.2s 0.0s ease-in-out infinite; }
.gg-chat-typing span:nth-child(2) { animation: gg-dot 1.2s 0.2s ease-in-out infinite; }
.gg-chat-typing span:nth-child(3) { animation: gg-dot 1.2s 0.4s ease-in-out infinite; }

@keyframes gg-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Quick Replies ─────────────────────────────────────────── */
.gg-chat-quick-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
  padding-bottom: 2px;
  align-self: flex-start;
  max-width: 100%;
  animation: gg-msg-in 0.35s var(--ggc-transition) 0.1s both;
}

.gg-chat-quick-btn {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid rgba(201,162,77,.5);
  background: rgba(255,255,255,.9);
  color: #8a6b25;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
  font-family: var(--ggc-font);
  backdrop-filter: blur(4px);
}

.gg-chat-quick-btn:hover {
  background: rgba(201,162,77,.1);
  border-color: var(--ggc-gold);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(201,162,77,.2);
}

.gg-chat-quick-btn:focus-visible {
  outline: 2px solid var(--ggc-gold);
  outline-offset: 2px;
}

/* ── Welcome Prompt Area ───────────────────────────────────── */
.gg-chat-welcome-actions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 4px;
  width: 100%;
  animation: gg-msg-in 0.4s var(--ggc-transition) 0.15s both;
}

.gg-chat-welcome-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--ggc-radius-sm);
  border: 1px solid var(--ggc-border);
  background: var(--ggc-white);
  color: var(--ggc-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--ggc-font);
  text-align: left;
  width: 100%;
  box-shadow: 0 2px 6px rgba(0,0,0,.03);
}

.gg-chat-welcome-btn:hover {
  border-color: rgba(201,162,77,.5);
  background: rgba(201,162,77,.04);
  transform: translateX(3px);
  box-shadow: 0 4px 12px rgba(201,162,77,.12);
}

.gg-chat-welcome-btn:focus-visible {
  outline: 2px solid var(--ggc-gold);
  outline-offset: 2px;
}

.gg-chat-welcome-btn .emoji {
  font-size: 17px;
  flex-shrink: 0;
  line-height: 1;
}

.gg-chat-welcome-btn .label {
  flex: 1;
}

.gg-chat-welcome-btn .arrow {
  color: var(--ggc-muted);
  font-size: 12px;
  flex-shrink: 0;
  transition: transform 0.18s ease;
}

.gg-chat-welcome-btn:hover .arrow {
  transform: translateX(3px);
  color: var(--ggc-gold);
}

/* WhatsApp welcome button */
.gg-chat-welcome-btn--wa {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
}

.gg-chat-welcome-btn--wa:hover {
  background: #dcfce7;
  border-color: #86efac;
}

/* ── Info Banner (for errors / notices) ────────────────────── */
.gg-chat-notice {
  margin: 6px 0;
  padding: 10px 14px;
  border-radius: var(--ggc-radius-sm);
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  align-self: stretch;
  animation: gg-msg-in 0.3s ease both;
}

/* ── Input Area ────────────────────────────────────────────── */
.gg-chat-footer {
  background: var(--ggc-white);
  border-top: 1px solid var(--ggc-border);
  padding: 12px 12px;
  flex-shrink: 0;
}

.gg-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--ggc-ivory);
  border: 1.5px solid var(--ggc-border);
  border-radius: 14px;
  padding: 8px 8px 8px 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.gg-chat-input-row:focus-within {
  border-color: rgba(201,162,77,.6);
  box-shadow: 0 0 0 3px rgba(201,162,77,.1);
}

#gg-chat-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--ggc-font);
  font-size: 13.5px;
  color: var(--ggc-text);
  resize: none;
  outline: none;
  max-height: 100px;
  min-height: 22px;
  line-height: 1.5;
  padding: 2px 0;
  overflow-y: auto;
}

#gg-chat-input::placeholder {
  color: #9ca3af;
}

#gg-chat-input::-webkit-scrollbar {
  width: 3px;
}

.gg-chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--ggc-gold-grad);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  align-self: flex-end;
}

.gg-chat-send-btn:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(201,162,77,.4);
}

.gg-chat-send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.gg-chat-send-btn:focus-visible {
  outline: 2px solid var(--ggc-gold);
  outline-offset: 2px;
}

.gg-chat-send-btn svg {
  width: 17px;
  height: 17px;
  color: #141414;
}

.gg-chat-footer-hint {
  font-size: 10px;
  color: var(--ggc-muted);
  text-align: center;
  margin-top: 8px;
  letter-spacing: 0.2px;
}

/* ── WhatsApp CTA Strip ────────────────────────────────────── */
.gg-chat-wa-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 12px;
  background: #f0fdf4;
  border-top: 1px solid #bbf7d0;
  font-size: 12px;
  font-weight: 600;
  color: #15803d;
  cursor: pointer;
  transition: background 0.18s ease;
  text-decoration: none;
  flex-shrink: 0;
}

.gg-chat-wa-strip:hover {
  background: #dcfce7;
}

.gg-chat-wa-strip svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ── Minimised State ───────────────────────────────────────── */
#gg-chat-window.gg-chat-window--minimised .gg-chat-messages,
#gg-chat-window.gg-chat-window--minimised .gg-chat-footer,
#gg-chat-window.gg-chat-window--minimised .gg-chat-wa-strip {
  display: none;
}

#gg-chat-window.gg-chat-window--minimised {
  height: auto;
}

/* ── Mobile Responsive ─────────────────────────────────────── */
@media (max-width: 767px) {

  #gg-chat-fab {
    right: 16px;
    bottom: 16px;
    width: 56px;
    height: 56px;
  }

  #gg-chat-fab svg {
    width: 24px;
    height: 24px;
  }

  #gg-chat-window {
    /* Near-fullscreen on mobile */
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: var(--ggc-radius) var(--ggc-radius) 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform-origin: bottom center;
    /* Slide up animation on mobile */
    transform: translateY(30px) scale(0.98);
  }

  #gg-chat-window.gg-chat-window--open {
    transform: translateY(0) scale(1);
  }

  .gg-chat-messages {
    /* Ensure content doesn't go under device keyboard */
    padding-bottom: 12px;
  }

  .gg-chat-footer {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .gg-chat-welcome-actions {
    gap: 6px;
  }

  .gg-chat-bubble {
    font-size: 14px;
  }
}

/* Very small screens */
@media (max-width: 360px) {
  .gg-chat-welcome-btn {
    font-size: 12px;
    padding: 9px 11px;
  }

  #gg-chat-window {
    border-radius: 0;
  }
}

/* ── Accessibility ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .gg-chat-root,
  .gg-chat-root * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* High-contrast mode */
@media (forced-colors: active) {
  #gg-chat-fab {
    border: 2px solid ButtonText;
  }
  .gg-chat-bubble {
    border: 1px solid ButtonText;
  }
}
