@charset "utf-8";
/* ===================================================
   Connolly Group – Advanced Chatbot Widget Styles
   v2.1 – Mobile & Tablet Optimized
   =================================================== */

/* ---------- CUSTOM PROPERTIES ---------- */
:root {
  --cg-navy:       #0a1628;
  --cg-navy-mid:   #162a4a;
  --cg-gold:       #c9a84c;
  --cg-gold-dark:  #a8893a;
  --cg-white:      #ffffff;
  --cg-off-white:  #f7f8fa;
  --cg-cream:      #f0ebe0;
  --cg-border:     #e2e4e8;
  --cg-text:       #1a1a2e;
  --cg-text-light: #777;
  --cg-text-muted: #999;
  --cg-green:      #2ecc71;
  --cg-red:        #e63946;
  --cg-radius:     16px;
  --cg-shadow:     0 10px 50px rgba(0, 0, 0, 0.22);
  --cg-safe-top:    env(safe-area-inset-top, 0px);
  --cg-safe-bottom: env(safe-area-inset-bottom, 0px);
  --cg-safe-left:   env(safe-area-inset-left, 0px);
  --cg-safe-right:  env(safe-area-inset-right, 0px);
}

/* ---------- TOGGLE BUTTON ---------- */
#cg-chatbot-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cg-navy), var(--cg-navy-mid));
  border: 2px solid var(--cg-gold);
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.3s, box-shadow 0.3s;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
#cg-chatbot-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 32px rgba(0, 0, 0, 0.45);
}
#cg-chatbot-toggle:active {
  transform: scale(0.95);
}
#cg-chatbot-toggle img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  pointer-events: none;
}

/* notification badge */
.cg-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background: var(--cg-red);
  border: 2px solid var(--cg-white);
  border-radius: 50%;
  font-size: 10px;
  color: var(--cg-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  animation: cg-pulse 2s infinite;
}
@keyframes cg-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ---------- CHAT WINDOW ---------- */
#cg-chatbot-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 400px;
  max-height: 580px;
  background: var(--cg-white);
  border-radius: var(--cg-radius);
  box-shadow: var(--cg-shadow);
  z-index: 9998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
#cg-chatbot-window.open {
  display: flex;
  animation: cg-slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes cg-slideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- HEADER ---------- */
.cg-chat-header {
  background: linear-gradient(135deg, var(--cg-navy) 0%, var(--cg-navy-mid) 100%);
  color: var(--cg-white);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 2px solid var(--cg-gold);
  flex-shrink: 0;
  min-height: 56px;
}
.cg-chat-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--cg-gold);
  flex-shrink: 0;
  background: var(--cg-navy);
  position: relative;
}
.cg-chat-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.cg-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: var(--cg-green);
  border: 2px solid var(--cg-navy);
  border-radius: 50%;
}
.cg-chat-header-info {
  flex: 1;
  min-width: 0;
}
.cg-chat-header-info h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;

  overflow: hidden;
  text-overflow: ellipsis;
}
.cg-chat-header-info p {
  margin: 2px 0 0;
  font-size: 11px;
  opacity: 0.75;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cg-header-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}
.cg-header-btn {
  background: none;
  border: none;
  color: var(--cg-white);
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.2s, background 0.2s;
  padding: 4px 6px;
  font-size: 18px;
  line-height: 1;
  border-radius: 6px;
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.cg-header-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}
.cg-header-btn:active {
  opacity: 1;
  background: rgba(255, 255, 255, 0.18);
}

/* ---------- MESSAGES AREA ---------- */
.cg-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--cg-off-white);
  min-height: 320px;
  max-height: 380px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ---------- MESSAGES ---------- */
.cg-message {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  animation: cg-fadeIn 0.3s ease;
}
.cg-message.user { flex-direction: row-reverse; }
@keyframes cg-fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* avatars */
.cg-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  margin-top: 2px;
  background: var(--cg-navy);
}
.cg-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.cg-msg-avatar.user-av {
  background: linear-gradient(135deg, var(--cg-gold), var(--cg-gold-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cg-white);
  font-size: 12px;
  font-weight: 700;
}

/* bubbles */
.cg-msg-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.cg-message.bot .cg-msg-bubble {
  background: var(--cg-white);
  color: var(--cg-text);
  border: 1px solid var(--cg-border);
  border-top-left-radius: 4px;
}
.cg-message.user .cg-msg-bubble {
  background: linear-gradient(135deg, var(--cg-navy), var(--cg-navy-mid));
  color: var(--cg-white);
  border-top-right-radius: 4px;
}
.cg-msg-time {
  font-size: 10px;
  color: var(--cg-text-muted);
  margin-top: 4px;
}
.cg-message.user .cg-msg-time {
  text-align: right;
}

/* ---------- TYPING INDICATOR ---------- */
.cg-typing {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  align-items: flex-end;
}
.cg-typing-dots {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--cg-white);
  border: 1px solid var(--cg-border);
  border-radius: 14px;
  border-top-left-radius: 4px;
}
.cg-typing-dots span {
  width: 7px;
  height: 7px;
  background: var(--cg-navy);
  border-radius: 50%;
  animation: cg-bounce 1.4s infinite;
  opacity: 0.35;
}
.cg-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.cg-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes cg-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ---------- QUICK REPLY CHIPS ---------- */
.cg-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.cg-chip {
  background: var(--cg-cream);
  border: 1px solid var(--cg-gold);
  color: var(--cg-navy);
  padding: 6px 14px;
  border-radius: 18px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.1s;
  font-family: inherit;
  font-weight: 500;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.cg-chip:hover {
  background: var(--cg-gold);
  color: var(--cg-white);
}
.cg-chip:active {
  transform: scale(0.95);
}

/* ---------- ACTION CARDS ---------- */
.cg-action-card {
  background: var(--cg-white);
  border: 1px solid var(--cg-border);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 10px;
  max-width: 100%;
}
.cg-action-card-header {
  background: linear-gradient(135deg, var(--cg-navy), var(--cg-navy-mid));
  padding: 10px 14px;
  color: var(--cg-gold);
  font-size: 13px;
  font-weight: 600;
}
.cg-action-card-body {
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  color: #333;
}
.cg-action-card-actions {
  padding: 8px 14px 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.cg-action-btn {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.1s;
  border: none;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.cg-action-btn:active {
  transform: scale(0.96);
}
.cg-action-btn-primary {
  background: var(--cg-navy);
  color: var(--cg-gold);
}
.cg-action-btn-primary:hover {
  background: var(--cg-navy-mid);
}
.cg-action-btn-secondary {
  background: var(--cg-cream);
  color: var(--cg-navy);
  border: 1px solid var(--cg-gold);
}
.cg-action-btn-secondary:hover {
  background: var(--cg-gold);
  color: var(--cg-white);
}

/* ---------- CONFIRMATION CARD ---------- */
.cg-confirm-card {
  background: var(--cg-white);
  border: 1px solid var(--cg-gold);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 10px;
}
.cg-confirm-card-header {
  background: linear-gradient(135deg, var(--cg-navy), var(--cg-navy-mid));
  padding: 10px 14px;
  color: var(--cg-gold);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cg-confirm-rows {
  padding: 10px 14px;
}
.cg-confirm-row {
  display: flex;
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
  gap: 8px;
}
.cg-confirm-row:last-child {
  border-bottom: none;
}
.cg-confirm-label {
  color: var(--cg-text-light);
  width: 90px;
  flex-shrink: 0;
  font-weight: 500;
}
.cg-confirm-value {
  color: var(--cg-text);
  font-weight: 500;
  word-break: break-word;
}

/* ---------- DIVIDER ---------- */
.cg-divider {
  text-align: center;
  font-size: 10px;
  color: #aaa;
  margin: 16px 0;
  position: relative;
}
.cg-divider::before,
.cg-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: #ddd;
}
.cg-divider::before { left: 0; }
.cg-divider::after  { right: 0; }

/* ---------- INPUT AREA ---------- */
.cg-chat-input-area {
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--cg-safe-bottom));
  background: var(--cg-white);
  border-top: 1px solid #e8e8e8;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.cg-chat-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 10px 16px;
  /* 16px prevents iOS auto-zoom on input focus */
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  color: var(--cg-text);
}
.cg-chat-input:focus {
  border-color: var(--cg-gold);
  box-shadow: 0 0 0 2px rgba(201, 168, 76, 0.15);
}
.cg-chat-input::placeholder { color: var(--cg-text-muted); }
.cg-chat-input:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}
.cg-chat-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--cg-navy);
  border: none;
  color: var(--cg-gold);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.cg-chat-send:hover { background: var(--cg-navy-mid); }
.cg-chat-send:active { transform: scale(0.92); }
.cg-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- POWERED BY ---------- */
.cg-chat-footer {
  text-align: center;
  padding: 4px 0 6px;
  padding-bottom: calc(6px + var(--cg-safe-bottom));
  font-size: 9px;
  color: #bbb;
  background: var(--cg-white);
  border-top: 1px solid #f0f0f0;
  flex-shrink: 0;
}

/* ---------- BODY SCROLL LOCK (mobile) ---------- */
body.cg-chat-open-mobile {
  overflow: hidden !important;
  position: fixed !important;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
}

/* =============================================
   MOBILE — max-width: 640px
   ============================================= */
@media (max-width: 640px) {
  #cg-chatbot-toggle {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }
  #cg-chatbot-toggle img {
    width: 30px;
    height: 30px;
  }

  /* Full-screen takeover */
  #cg-chatbot-window {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 100%;
    height: 100%;
    border-radius: 0;
    box-shadow: none;
  }
  #cg-chatbot-window.open {
    animation: cg-slideUpMobile 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
  @keyframes cg-slideUpMobile {
    from { opacity: 0; transform: translateY(100%); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* Messages fill available space */
  .cg-chat-messages {
    max-height: none;
    min-height: 0;
    flex: 1;
    padding: 14px 12px;
  }

  /* Header: respect top safe area (notch) */
  .cg-chat-header {
    padding-top: calc(16px + var(--cg-safe-top));
    padding-left: calc(16px + var(--cg-safe-left));
    padding-right: calc(16px + var(--cg-safe-right));
  }

  /* Larger touch targets */
  .cg-header-btn {
    min-width: 40px;
    min-height: 40px;
    font-size: 22px;
    border-radius: 10px;
  }

  .cg-chip {
    padding: 9px 16px;
    font-size: 13px;
    border-radius: 20px;
  }

  .cg-action-btn {
    padding: 10px 18px;
    font-size: 13px;
  }

  /* Bubbles use more width on mobile */
  .cg-msg-bubble {
    max-width: 85%;
    font-size: 14px;
  }

  .cg-confirm-card {
    max-width: 90%;
  }

  /* Input area: safe area insets on sides too */
  .cg-chat-input-area {
    padding-left: calc(12px + var(--cg-safe-left));
    padding-right: calc(12px + var(--cg-safe-right));
  }

  /* Slightly larger send button */
  .cg-chat-send {
    width: 44px;
    height: 44px;
  }

  /* Footer safe area sides */
  .cg-chat-footer {
    padding-left: var(--cg-safe-left);
    padding-right: var(--cg-safe-right);
  }
}

/* =============================================
   TABLET — 641px to 1024px
   ============================================= */
@media (min-width: 641px) and (max-width: 1024px) {
  #cg-chatbot-window {
    width: 420px;
    max-height: 620px;
  }
  .cg-chat-messages {
    max-height: 440px;
  }
  .cg-chip {
    padding: 8px 15px;
    font-size: 13px;
  }
  .cg-action-btn {
    padding: 9px 17px;
    font-size: 13px;
  }
}

/* =============================================
   LANDSCAPE PHONES — short viewport
   ============================================= */
@media (max-width: 640px) and (max-height: 500px) {
  .cg-chat-header {
    padding-top: calc(8px + var(--cg-safe-top));
    padding-bottom: 8px;
    min-height: 44px;
    gap: 8px;
  }
  .cg-chat-header-avatar {
    width: 32px;
    height: 32px;
  }
  .cg-chat-header-info h3 {
    font-size: 14px;
  }
  .cg-chat-messages {
    padding: 10px;
  }
  .cg-msg-bubble {
    padding: 8px 12px;
    font-size: 13px;
  }
  .cg-chip {
    padding: 6px 12px;
    font-size: 12px;
  }
  .cg-chat-input-area {
    padding: 8px 10px;
    padding-bottom: calc(8px + var(--cg-safe-bottom));
  }
  .cg-chat-footer {
    padding: 3px 0 4px;
  }
}

/* =============================================
   PREFERS REDUCED MOTION
   ============================================= */
@media (prefers-reduced-motion: reduce) {
  #cg-chatbot-window.open {
    animation: none;
  }
  #cg-chatbot-toggle,
  .cg-chip,
  .cg-action-btn,
  .cg-chat-send,
  .cg-header-btn,
  .cg-msg-bubble,
  .cg-message,
  .cg-badge {
    transition: none !important;
    animation: none !important;
  }
}

/* =============================================
   DARK MODE SUPPORT (optional — follows OS pref)
   ============================================= */
@media (prefers-color-scheme: dark) {
  /* Uncomment the block below to enable auto dark mode:
  #cg-chatbot-window {
    background: #1a1a2e;
  }
  .cg-chat-messages {
    background: #111827;
  }
  .cg-message.bot .cg-msg-bubble {
    background: #1e293b;
    color: #e5e7eb;
    border-color: #374151;
  }
  .cg-chat-input-area {
    background: #1a1a2e;
    border-top-color: #374151;
  }
  .cg-chat-input {
    background: #111827;
    border-color: #374151;
    color: #e5e7eb;
  }
  .cg-chat-footer {
    background: #1a1a2e;
    border-top-color: #374151;
  }
  */
}