/*
 * Gator Carpet & Tile — Chatbot Widget Styles
 * Gary the Gator avatar edition. Mobile-first.
 *
 * IMAGE FILES NEEDED in /chatbot/assets/images/:
 *   gary-avatar-green.png  — circular green avatar (chat widget avatar, left)
 *   gary-avatar-orange.png — circular orange avatar (chat widget avatar, right)
 *   gary-happy.png         — happy expression (head only)
 *   gary-thinking.png      — thinking expression (head only)
 *   gary-excited.png       — excited expression (head only)
 *   gary-helpful.png       — helpful/thumbs-up expression (head only)
 *   gary-wink.png          — wink expression (head only)
 *   gary-full-body-1.png   — full body pose 1
 *   gary-full-body-2.png   — full body pose 2 (pointing)
 */

/* ── LAUNCHER BUTTON ─────────────────────────────────────────────────────── */
#gct-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: #1d6b3a;
  color: #fff;
  border: none;
  border-radius: 99px;
  /* Extra left padding cut — Gary's avatar protrudes left */
  padding: 6px 1.25rem 6px 6px;
  box-shadow: 0 4px 20px rgba(29,107,58,0.4);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  transition: transform 0.2s, box-shadow 0.2s;
  user-select: none;
}
#gct-chat-launcher:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(29,107,58,0.55);
}

/* Gary's circular avatar in the launcher */
#gct-chat-launcher .launcher-gary {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.4);
  flex-shrink: 0;
  animation: gct-bounce 3s ease-in-out infinite;
  /* Fallback background if image hasn't loaded */
  background: #155229 url('images/gary-avatar-green.png') center/cover no-repeat;
}

/* Notification badge */
#gct-chat-launcher .launcher-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #f07c20;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  animation: gct-pulse 2s ease-in-out infinite;
}

@keyframes gct-bounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25%       { transform: translateY(-4px) rotate(-2deg); }
  75%       { transform: translateY(-2px) rotate(2deg); }
}
@keyframes gct-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.15); }
}

/* ── CHAT WINDOW ─────────────────────────────────────────────────────────── */
#gct-chat-window {
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 9999;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 110px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  transform: scale(0.9) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s;
}
#gct-chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── HEADER ──────────────────────────────────────────────────────────────── */
.gct-chat-header {
  background: linear-gradient(135deg, #1d6b3a 0%, #155229 100%);
  color: #fff;
  padding: 0.75rem 1rem 0.75rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  position: relative;
  overflow: visible;
}

/* Gary's avatar in the header — larger, slightly overflows bottom */
.gct-chat-header__avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 2.5px solid rgba(255,255,255,0.5);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  /* Fallback */
  background: #155229 url('images/gary-avatar-green.png') center/cover no-repeat;
  /* Expression swap via JS — default is gary-avatar-green */
  transition: opacity 0.2s;
}

/* Name + status text */
.gct-chat-header__info { flex: 1; }
.gct-chat-header__name  { font-weight: 700; font-size: 0.95rem; line-height: 1.2; }
.gct-chat-header__subtitle {
  font-size: 0.72rem;
  opacity: 0.8;
  font-style: italic;
  margin-bottom: 0.15rem;
}
.gct-chat-header__status {
  font-size: 0.71rem;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.gct-chat-header__status::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5fdd9d;
  animation: gct-pulse 2.5s ease-in-out infinite;
}

.gct-chat-close {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.75);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.3rem 0.4rem;
  line-height: 1;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.gct-chat-close:hover { background: rgba(255,255,255,0.15); color: #fff; }

/* ── MESSAGES AREA ───────────────────────────────────────────────────────── */
.gct-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  scroll-behavior: smooth;
}

.gct-msg {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: 88%;
  animation: gct-msgIn 0.25s ease;
}
@keyframes gct-msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.gct-msg--bot { align-self: flex-start; }
.gct-msg--user { align-self: flex-end; flex-direction: row-reverse; }

/* Gary's small avatar next to each bot message bubble */
.gct-msg__avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid #d0e8d8;
  /* Fallback bg while image loads */
  background: #1d6b3a url('images/gary-avatar-green.png') center/cover no-repeat;
}
/* Expression variants applied by JS */
.gct-msg__avatar--thinking { background-image: url('images/gary-thinking.png'); }
.gct-msg__avatar--excited  { background-image: url('images/gary-excited.png'); }
.gct-msg__avatar--helpful  { background-image: url('images/gary-helpful.png'); }
.gct-msg__avatar--wink     { background-image: url('images/gary-wink.png'); }
.gct-msg__avatar--happy    { background-image: url('images/gary-happy.png'); }

.gct-msg__bubble {
  padding: 0.65rem 0.9rem;
  border-radius: 14px;
  font-size: 0.86rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.gct-msg--bot .gct-msg__bubble {
  background: #f0f4f0;
  color: #2c2c2c;
  border-bottom-left-radius: 4px;
}
.gct-msg--user .gct-msg__bubble {
  background: #1d6b3a;
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* bold within bubbles */
.gct-msg__bubble strong { font-weight: 700; }

/* ── TYPING INDICATOR ────────────────────────────────────────────────────── */
.gct-typing {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  align-self: flex-start;
}
/* Typing uses gary-thinking expression */
.gct-typing .gct-msg__avatar {
  background-image: url('images/gary-thinking.png');
}
.gct-typing__dots {
  background: #f0f4f0;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  padding: 0.65rem 0.9rem;
  display: flex;
  gap: 4px;
  align-items: center;
}
.gct-typing__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #999;
  animation: gct-dot 1.2s ease-in-out infinite;
}
.gct-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.gct-typing__dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes gct-dot {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.4; }
  40%            { transform: scale(1.1); opacity: 1; }
}

/* ── QUICK REPLIES ───────────────────────────────────────────────────────── */
.gct-quick-replies {
  padding: 0.5rem 1rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.gct-qr-btn {
  background: transparent;
  border: 1.5px solid #1d6b3a;
  color: #1d6b3a;
  border-radius: 99px;
  padding: 0.35rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
}
.gct-qr-btn:hover {
  background: #1d6b3a;
  color: #fff;
}
/* Special styling for "Get Quote" button */
.gct-qr-btn--cta {
  background: #f07c20;
  border-color: #f07c20;
  color: #fff;
}
.gct-qr-btn--cta:hover {
  background: #c05e0a;
  border-color: #c05e0a;
}

/* ── INPUT AREA ──────────────────────────────────────────────────────────── */
.gct-input-area {
  padding: 0.75rem 1rem;
  border-top: 1px solid #e8ede8;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
  background: #fff;
}
.gct-input {
  flex: 1;
  border: 1.5px solid #dde4dd;
  border-radius: 99px;
  padding: 0.55rem 0.9rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: #2c2c2c;
  outline: none;
  transition: border-color 0.2s;
  background: #f9fbf9;
}
.gct-input:focus { border-color: #1d6b3a; background: #fff; }
.gct-send-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: #1d6b3a;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  transition: background 0.15s;
}
.gct-send-btn:hover { background: #155229; }
.gct-send-btn:disabled { background: #ccc; cursor: default; }

/* ── GARY INTRO CARD (shown as first message) ───────────────────────────── */
.gct-intro-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: linear-gradient(135deg, #1d6b3a, #155229);
  border-radius: 14px;
  padding: 0.75rem 1rem;
  margin: 0.25rem 0;
  align-self: flex-start;
  max-width: 100%;
  animation: gct-msgIn 0.3s ease;
}
.gct-intro-card__img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  flex-shrink: 0;
  background: #155229 url('images/gary-excited.png') center/cover no-repeat;
}
.gct-intro-card__text { color: #fff; }
.gct-intro-card__name { font-weight: 700; font-size: 0.9rem; }
.gct-intro-card__role { font-size: 0.75rem; opacity: 0.85; }

/* ── FOOTER PROMO ────────────────────────────────────────────────────────── */
.gct-chat-footer {
  padding: 0.5rem 1rem;
  border-top: 1px solid #f0f0f0;
  background: #f9fbf9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-shrink: 0;
}
.gct-chat-footer a {
  font-size: 0.75rem;
  font-weight: 700;
  color: #f07c20;
  text-decoration: none;
  white-space: nowrap;
}
.gct-chat-footer a:hover { text-decoration: underline; }
.gct-chat-footer span {
  font-size: 0.7rem;
  color: #aaa;
}

/* ── MOBILE ADJUSTMENTS ──────────────────────────────────────────────────── */
/* ── MOBILE ───────────────────────────────────────────────────────────────
   Full-screen sheet that always fits the visible viewport. Uses dvh so the
   mobile browser address bar can't hide the input/bottom of the chat. */
@media (max-width: 600px) {
  #gct-chat-window {
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;          /* fallback */
    height: 100dvh !important;         /* dynamic viewport height */
    max-height: 100vh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0 !important;
  }

  /* Message area flexes to fill so the input bar stays visible */
  #gct-chat-window .gct-messages { flex: 1 1 auto; min-height: 0; }

  /* Launcher: keep on-screen and let the longer label wrap neatly */
  #gct-chat-launcher {
    right: 12px;
    bottom: 16px;
    max-width: calc(100vw - 24px);
  }
  #gct-chat-launcher > span:not(.launcher-badge) {
    white-space: normal;
    line-height: 1.15;
    text-align: left;
    font-size: 0.82rem;
  }

  /* iOS safe areas (notch / home indicator) */
  #gct-chat-window .gct-input-area {
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
  }
}
