/* ============================================
   GROWTH SOLUTIONS — CHATBOX
   Prefix: .gs-chat-*
   Palette inherits navy #00023D, blue #042EC3,
           gold #D8AA6F, white #FFFFFF
   ============================================ */

.gs-chat,
.gs-chat *,
.gs-chat *::before,
.gs-chat *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.gs-chat {
  --gs-navy: #00023D;
  --gs-blue: #042EC3;
  --gs-blue-bright: #0437DD;
  --gs-gold: #D8AA6F;
  --gs-white: #FFFFFF;
  --gs-border: rgba(0, 2, 61, 0.12);
  --gs-muted: rgba(0, 2, 61, 0.55);
}

/* ============ BUBBLE (flat) ============ */
.gs-chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #0437DD;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  transition: background 0.2s ease, opacity 0.2s ease, transform 0.12s ease;
}

.gs-chat-bubble:hover {
  background: var(--gs-navy);
}

.gs-chat-bubble:active {
  transform: scale(0.95);
}

.gs-chat-bubble svg {
  width: 26px;
  height: 26px;
  fill: var(--gs-white);
}

.gs-chat-bubble.gs-chat-bubble-hidden {
  opacity: 0;
  pointer-events: none;
}

/* ============ WINDOW ============ */
.gs-chat-window {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 380px;
  height: 560px;
  max-height: calc(100vh - 48px);
  background: var(--gs-white);
  border: 1px solid var(--gs-border);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.92) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.18s ease;
}

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

/* ============ HEADER ============ */
.gs-chat-header {
  background: var(--gs-navy);
  color: var(--gs-white);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.gs-chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--gs-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.gs-chat-avatar svg {
  width: 24px;
  height: 28px;
}

.gs-chat-avatar-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22C55E;
  border: 2px solid var(--gs-navy);
}

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

.gs-chat-header-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.gs-chat-header-status {
  font-size: 12px;
  opacity: 0.7;
  margin-top: 2px;
}

.gs-chat-header-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.gs-chat-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--gs-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.15s ease;
}

.gs-chat-icon-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.gs-chat-icon-btn:active {
  transform: scale(0.92);
}

.gs-chat-icon-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* ============ BODY ============ */
.gs-chat-body {
  flex: 1;
  overflow-y: auto;
  background: #FAFAF7;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

.gs-chat-body::-webkit-scrollbar {
  width: 6px;
}

.gs-chat-body::-webkit-scrollbar-thumb {
  background: rgba(0, 2, 61, 0.2);
  border-radius: 3px;
}

/* ============ PRE-CHAT FORM ============ */
.gs-chat-prechat {
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.gs-chat-prechat-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--gs-navy);
  line-height: 1.4;
  letter-spacing: -0.2px;
}

.gs-chat-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gs-chat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--gs-navy);
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.gs-chat-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--gs-navy);
  background: var(--gs-white);
  border: 1px solid var(--gs-border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.gs-chat-input:focus {
  border-color: var(--gs-blue);
  box-shadow: 0 0 0 3px rgba(4, 46, 195, 0.1);
}

.gs-chat-input::placeholder {
  color: rgba(0, 2, 61, 0.35);
}

.gs-chat-input.gs-chat-input-error {
  border-color: #DC2626;
}

.gs-chat-field-error {
  font-size: 12px;
  color: #DC2626;
  margin-top: 2px;
  display: none;
}

.gs-chat-field-error.gs-chat-field-error-visible {
  display: block;
}

.gs-chat-prechat-submit {
  margin-top: 4px;
  width: 100%;
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  color: var(--gs-white);
  background: var(--gs-navy);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.2px;
  transition: background 0.2s ease, transform 0.15s ease;
}

.gs-chat-prechat-submit:hover:not(:disabled) {
  background: var(--gs-blue-bright);
}

.gs-chat-prechat-submit:active:not(:disabled) {
  transform: scale(0.98);
}

.gs-chat-prechat-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============ MESSAGES ============ */
.gs-chat-messages {
  flex: 1;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gs-chat-msg {
  max-width: 78%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.45;
  border-radius: 16px;
  word-wrap: break-word;
  animation: gs-chat-msg-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes gs-chat-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.gs-chat-msg-agent {
  align-self: flex-start;
  background: var(--gs-white);
  color: var(--gs-navy);
  border: 1px solid var(--gs-border);
  border-bottom-left-radius: 4px;
}

.gs-chat-msg-user {
  align-self: flex-end;
  background: var(--gs-navy);
  color: var(--gs-white);
  border-bottom-right-radius: 4px;
}

.gs-chat-msg-time {
  font-size: 10px;
  opacity: 0.55;
  margin-top: 4px;
}

/* Typing indicator */
.gs-chat-typing {
  align-self: flex-start;
  background: var(--gs-white);
  border: 1px solid var(--gs-border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: none;
  gap: 4px;
  align-items: center;
}

.gs-chat-typing.gs-chat-typing-visible {
  display: flex;
}

.gs-chat-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(0, 2, 61, 0.4);
  animation: gs-chat-typing-bounce 1.3s ease-in-out infinite;
}

.gs-chat-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.gs-chat-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes gs-chat-typing-bounce {
  0%, 60%, 100% { transform: translateY(0);   opacity: 0.4; }
  30%           { transform: translateY(-4px); opacity: 1;   }
}

/* ============ INPUT BAR ============ */
.gs-chat-inputbar {
  display: none;
  padding: 12px 14px;
  border-top: 1px solid var(--gs-border);
  background: var(--gs-white);
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

.gs-chat-inputbar.gs-chat-inputbar-visible {
  display: flex;
}

.gs-chat-msg-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--gs-border);
  border-radius: 18px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--gs-navy);
  background: #FAFAF7;
  outline: none;
  max-height: 100px;
  min-height: 38px;
  line-height: 1.4;
  transition: border-color 0.2s ease;
}

.gs-chat-msg-input:focus {
  border-color: var(--gs-blue);
}

.gs-chat-msg-input::placeholder {
  color: rgba(0, 2, 61, 0.35);
}

.gs-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--gs-gold);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease, transform 0.15s ease;
}

.gs-chat-send:hover:not(:disabled) {
  background: #C99858;
}

.gs-chat-send:active:not(:disabled) {
  transform: scale(0.92);
}

.gs-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.gs-chat-send svg {
  width: 16px;
  height: 16px;
  fill: var(--gs-navy);
}

/* ============ FOOTER NOTE ============ */
.gs-chat-footer-note {
  padding: 8px 14px;
  background: var(--gs-white);
  border-top: 1px solid var(--gs-border);
  font-size: 10px;
  color: var(--gs-muted);
  text-align: center;
  letter-spacing: 0.2px;
  flex-shrink: 0;
}

/* ============ MOBILE ============ */
@media (max-width: 480px) {
  .gs-chat-bubble {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }

  .gs-chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    max-width: 100%;
    border-radius: 0;
    border: none;
    transform-origin: center;
    transform: translateY(12px);
  }

  .gs-chat-window.gs-chat-window-open {
    transform: translateY(0);
  }
}
