/* ── GamerTech AI Chat Widget Styles ──────────────────────────────────────── */

#gt-chat-root {
  --gt-color: #5c6bc0;
  --gt-color-dark: #3f4fa8;
  --gt-radius: 16px;
  --gt-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --gt-shadow: 0 8px 32px rgba(0,0,0,0.18);
  font-family: var(--gt-font);
  position: fixed;
  z-index: 2147483647;
}

#gt-chat-root.gt-position-bottom-right {
  bottom: 24px;
  right: 24px;
}

#gt-chat-root.gt-position-bottom-left {
  bottom: 24px;
  left: 24px;
}

/* ── Toggle Button ──────────────────────────────────────────────────────────── */

#gt-toggle {
  width: 64px !important;
  height: 64px !important;
  min-width: 64px !important;
  min-height: 64px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, var(--gt-color), var(--gt-color-dark)) !important;
  border: none !important;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(0,0,0,0.25), 0 0 0 0 rgba(92,107,192,0.4) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  outline: none;
  padding: 0 !important;
  margin: 0 !important;
  box-sizing: content-box !important;
  line-height: 1 !important;
  text-align: center !important;
  flex-shrink: 0;
  animation: gt-pulse 2.5s ease-in-out infinite;
}

@keyframes gt-pulse {
  0%, 100% { box-shadow: 0 6px 24px rgba(0,0,0,0.25), 0 0 0 0 rgba(92,107,192,0.5); }
  50% { box-shadow: 0 6px 24px rgba(0,0,0,0.25), 0 0 0 10px rgba(92,107,192,0); }
}

#gt-chat-root.gt-open #gt-toggle {
  animation: none;
}

#gt-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 28px rgba(0,0,0,0.3) !important;
}

#gt-toggle svg {
  width: 30px;
  height: 30px;
  fill: #fff;
  transition: opacity 0.2s;
}

#gt-toggle .gt-icon-close {
  display: none;
}

#gt-chat-root.gt-open #gt-toggle .gt-icon-chat {
  display: none;
}

#gt-chat-root.gt-open #gt-toggle .gt-icon-close {
  display: block;
}

/* ── Chat Panel ─────────────────────────────────────────────────────────────── */

#gt-panel {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 48px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: var(--gt-radius);
  box-shadow: var(--gt-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.8) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

#gt-chat-root.gt-position-bottom-left #gt-panel {
  right: auto;
  left: 0;
  transform-origin: bottom left;
}

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

/* ── Header ─────────────────────────────────────────────────────────────────── */

#gt-header {
  background: var(--gt-color);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#gt-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  overflow: hidden;
}

#gt-header-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

#gt-header-info {
  flex: 1;
}

#gt-header-name {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
}

#gt-header-status {
  font-size: 12px;
  opacity: 0.85;
}

/* ── Name Screen ─────────────────────────────────────────────────────────────── */

#gt-name-screen {
  display: none;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#gt-name-prompt {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#gt-name-heading {
  font-size: 15px;
  font-weight: 600;
  color: #222;
  margin: 0;
  text-align: center;
}

#gt-name-input,
#gt-email-input {
  width: 100%;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
  font-family: var(--gt-font);
  background: #fff;
  color: #222;
  min-height: 0;
}

#gt-name-input:focus,
#gt-email-input:focus {
  border-color: var(--gt-color);
}

#gt-name-submit {
  background: var(--gt-color);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
  text-align: center;
}

#gt-name-submit:hover {
  background: var(--gt-color-dark);
}

/* ── Messages ───────────────────────────────────────────────────────────────── */

#gt-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

/* Row wrapper for bot/agent messages (avatar + bubble) */
.gt-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.gt-msg-row.gt-row-user {
  flex-direction: row-reverse;
}

.gt-bot-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gt-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.gt-bot-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

#gt-messages::-webkit-scrollbar {
  width: 4px;
}
#gt-messages::-webkit-scrollbar-track {
  background: transparent;
}
#gt-messages::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 4px;
}

.gt-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.gt-msg-user {
  align-self: flex-end;
  background: var(--gt-color);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.gt-msg-assistant {
  align-self: flex-start;
  background: #f1f3f4;
  color: #1a1a1a;
  border-bottom-left-radius: 4px;
}

.gt-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
  background: #f1f3f4;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.gt-typing span {
  width: 7px;
  height: 7px;
  background: #999;
  border-radius: 50%;
  animation: gt-bounce 1.2s infinite;
}

.gt-typing span:nth-child(2) { animation-delay: 0.2s; }
.gt-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes gt-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ── Input Area ─────────────────────────────────────────────────────────────── */

#gt-input-area {
  padding: 12px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: #fff;
  flex-shrink: 0;
}

#gt-input {
  flex: 1;
  border: 1.5px solid #ddd !important;
  border-radius: 22px !important;
  padding: 10px 16px !important;
  font-size: 14px !important;
  font-family: var(--gt-font) !important;
  resize: none !important;
  outline: none !important;
  max-height: 100px;
  overflow-y: hidden !important;
  line-height: 20px !important;
  transition: border-color 0.15s;
  /* Prevent Shopify theme CSS from overriding textarea height/sizing */
  box-sizing: border-box !important;
  min-height: 0 !important;
  height: 40px !important;
  vertical-align: top !important;
  display: block !important;
  padding-top: 10px !important;
  padding-bottom: 10px !important;
}

#gt-input:focus {
  border-color: var(--gt-color);
}

#gt-input::placeholder {
  color: #aaa;
}

#gt-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--gt-color);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
  outline: none;
}

#gt-send:hover:not(:disabled) {
  background: var(--gt-color-dark);
  transform: scale(1.05);
}

#gt-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#gt-send svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* ── Talk to a Human bar ────────────────────────────────────────────────────── */

#gt-human-bar {
  border-top: 1px solid #eee;
  padding: 6px 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

#gt-human-btn {
  background: none;
  border: none;
  color: #666;
  font-size: 12px;
  font-family: var(--gt-font);
  cursor: pointer;
  padding: 2px 0;
  transition: color 0.15s;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

#gt-human-btn:hover:not(:disabled) {
  color: var(--gt-color);
}

#gt-human-btn:disabled {
  cursor: default;
}

#gt-human-bar.gt-human-bar--connected #gt-human-btn {
  color: #16a34a;
  font-weight: 500;
}

#gt-human-bar.gt-human-bar--waiting #gt-human-btn {
  color: #d97706;
  font-weight: 500;
}

/* ── Contact capture (offline / 2-min timeout flow) ─────────────────────────── */

#gt-contact-capture {
  border-top: 1px solid #eee;
  padding: 10px 12px;
  flex-shrink: 0;
  background: #f9f9f9;
}

#gt-contact-label {
  font-size: 12px;
  color: #555;
  margin: 0 0 8px;
}

#gt-pref-row {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
}

.gt-pref-label {
  font-size: 12px;
  color: #444;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.gt-pref-label input[type="radio"] {
  margin: 0;
  accent-color: var(--gt-color);
}

#gt-contact-email-row,
#gt-contact-phone-row {
  margin-bottom: 8px;
}

#gt-contact-email,
#gt-contact-phone {
  width: 100%;
  box-sizing: border-box;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: var(--gt-font);
  outline: none;
  transition: border-color 0.15s;
}

#gt-contact-email:focus,
#gt-contact-phone:focus {
  border-color: var(--gt-color);
}

#gt-contact-email:disabled,
#gt-contact-phone:disabled {
  background: #f5f5f5;
  color: #aaa;
}

#gt-contact-send {
  background: var(--gt-color);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 16px;
  font-size: 13px;
  font-family: var(--gt-font);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

#gt-contact-send:hover:not(:disabled) {
  background: var(--gt-color-dark);
}

#gt-contact-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Agent message bubble ───────────────────────────────────────────────────── */

.gt-msg-agent {
  align-self: flex-start;
  background: #eef2ff;
  color: #1a1a1a;
  border-bottom-left-radius: 4px;
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.gt-agent-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--gt-color);
  margin-bottom: 3px;
}

/* ── Powered by ─────────────────────────────────────────────────────────────── */

#gt-powered-by {
  text-align: center;
  font-size: 11px;
  color: #bbb;
  padding: 4px 0 8px;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  #gt-panel {
    width: calc(100vw - 32px);
    height: 70vh;
  }
}

/* ── Greeting bubble ─────────────────────────────────────────────────────────── */

#gt-greeting-bubble {
  position: absolute;
  bottom: 12px;
  right: 76px;
  background: #fff;
  color: #111;
  border-radius: 999px;
  padding: 12px 36px 12px 20px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: 0 2px 16px rgba(0,0,0,0.14);
  animation: gt-bubble-in 0.3s ease;
}

#gt-greeting-close {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: #aaa;
  line-height: 1;
  padding: 0;
}

#gt-greeting-close:hover { color: #333; }

@keyframes gt-bubble-in {
  from { opacity: 0; transform: translateY(8px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
