/* =============================================
   GOLD SIGNAL CHATBOT v2.0 — Premium Trading UI
   Aesthetic: Luxury dark with gold accents
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@300;400;500;600;700;800&display=swap');

/* ============ WIDGET CONTAINER ============ */
#gs-chat-widget {
  position: fixed;
  bottom: 24px;
  z-index: 999999;
  font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.5;

  --gs-gold: #D4A017;
  --gs-gold-light: #F2D06B;
  --gs-gold-glow: rgba(212, 160, 23, 0.15);
  --gs-gold-dark: #A67C00;
  --gs-gold-darker: #7A5C00;
  --gs-dark-1: #08090D;
  --gs-dark-2: #0F1118;
  --gs-dark-3: #161A24;
  --gs-dark-4: #1D2233;
  --gs-dark-5: #252B3B;
  --gs-border: rgba(212, 160, 23, 0.1);
  --gs-border-hover: rgba(212, 160, 23, 0.25);
  --gs-text: #F0EDE8;
  --gs-text-secondary: #A8AAB2;
  --gs-text-muted: #6B6E78;
  --gs-green: #34D399;
  --gs-green-bg: rgba(52, 211, 153, 0.1);
  --gs-red: #F87171;
  --gs-radius: 20px;
  --gs-radius-sm: 14px;
  --gs-radius-xs: 10px;
  --gs-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), 0 0 1px rgba(212, 160, 23, 0.15);
}

#gs-chat-widget * {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

#gs-chat-widget[data-position="right"] { right: 24px; }
#gs-chat-widget[data-position="left"] { left: 24px; }

/* ============ TOGGLE BUTTON ============ */
#gs-chat-widget .gs-toggle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(145deg, var(--gs-gold), var(--gs-gold-dark));
  color: var(--gs-dark-1);
  box-shadow:
    0 4px 20px rgba(212, 160, 23, 0.4),
    0 0 0 0 rgba(212, 160, 23, 0.3),
    inset 0 1px 0 rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: gs-pulse 3s ease-in-out infinite;
  position: relative;
  overflow: visible;
}

#gs-chat-widget .gs-toggle:hover {
  transform: scale(1.12);
  box-shadow: 0 8px 32px rgba(212, 160, 23, 0.55), inset 0 1px 0 rgba(255,255,255,0.2);
}

#gs-chat-widget .gs-toggle.open {
  animation: none;
  background: var(--gs-dark-4);
  color: var(--gs-text);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

#gs-chat-widget .gs-toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.35s ease;
}

#gs-chat-widget .gs-toggle .gs-toggle-close {
  position: absolute;
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

#gs-chat-widget .gs-toggle.open #gsToggleChat {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

#gs-chat-widget .gs-toggle.open .gs-toggle-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Badge */
#gs-chat-widget .gs-toggle-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--gs-red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--gs-dark-1);
  animation: gs-badge-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: opacity 0.2s;
}

#gs-chat-widget .gs-toggle-badge.hidden,
#gs-chat-widget .gs-toggle.open .gs-toggle-badge {
  opacity: 0;
  transform: scale(0);
}

@keyframes gs-badge-pop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

@keyframes gs-pulse {
  0%, 100% {
    box-shadow: 0 4px 20px rgba(212, 160, 23, 0.4), 0 0 0 0 rgba(212, 160, 23, 0.25);
  }
  50% {
    box-shadow: 0 4px 20px rgba(212, 160, 23, 0.4), 0 0 0 14px rgba(212, 160, 23, 0);
  }
}

/* ============ CHAT WINDOW ============ */
#gs-chat-widget .gs-chat-window {
  position: absolute;
  bottom: 80px;
  width: 440px;
  height: 680px;
  max-height: calc(100vh - 100px);
  background: var(--gs-dark-1);
  border: 1px solid var(--gs-border);
  border-radius: var(--gs-radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--gs-shadow);
  opacity: 0;
  transform: translateY(20px) scale(0.94);
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#gs-chat-widget[data-position="right"] .gs-chat-window { right: 0; }
#gs-chat-widget[data-position="left"] .gs-chat-window { left: 0; }

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

/* ============ HEADER ============ */
#gs-chat-widget .gs-header {
  background: var(--gs-dark-2);
  border-bottom: 1px solid var(--gs-border);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
}

#gs-chat-widget .gs-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gs-gold-glow), transparent);
}

#gs-chat-widget .gs-header-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

#gs-chat-widget .gs-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--gs-radius-xs);
  background: linear-gradient(145deg, var(--gs-gold), var(--gs-gold-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--gs-dark-1);
  letter-spacing: 0.5px;
}

#gs-chat-widget .gs-online-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gs-green);
  border: 2.5px solid var(--gs-dark-2);
  animation: gs-blink 2.5s ease-in-out infinite;
}

@keyframes gs-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

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

#gs-chat-widget .gs-header-info h3 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--gs-text);
  margin: 0 0 1px 0;
  padding: 0;
  line-height: 1.3;
  letter-spacing: 0.2px;
}

#gs-chat-widget .gs-header-status {
  font-size: 0.72rem;
  color: var(--gs-green);
  font-weight: 500;
  letter-spacing: 0.1px;
}

#gs-chat-widget .gs-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--gs-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

#gs-chat-widget .gs-close-btn:hover {
  background: rgba(255,255,255,0.06);
  color: var(--gs-text);
}

/* ============ MESSAGES ============ */
#gs-chat-widget .gs-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  -webkit-user-select: auto;
  user-select: auto;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(212, 160, 23, 0.03) 0%, transparent 60%),
    var(--gs-dark-1);
}

#gs-chat-widget .gs-messages::-webkit-scrollbar { width: 3px; }
#gs-chat-widget .gs-messages::-webkit-scrollbar-track { background: transparent; }
#gs-chat-widget .gs-messages::-webkit-scrollbar-thumb {
  background: var(--gs-dark-5);
  border-radius: 3px;
}

/* Message Bubbles */
#gs-chat-widget .gs-msg {
  max-width: 82%;
  animation: gs-msgIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  word-wrap: break-word;
}

@keyframes gs-msgIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

#gs-chat-widget .gs-msg-content {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.86rem;
  line-height: 1.65;
}

#gs-chat-widget .gs-msg.bot {
  align-self: flex-start;
}

#gs-chat-widget .gs-msg.bot .gs-msg-content {
  background: var(--gs-dark-3);
  border: 1px solid var(--gs-border);
  color: var(--gs-text);
  border-bottom-left-radius: 6px;
}

#gs-chat-widget .gs-msg.user {
  align-self: flex-end;
}

#gs-chat-widget .gs-msg.user .gs-msg-content {
  background: linear-gradient(145deg, var(--gs-gold), var(--gs-gold-dark));
  color: var(--gs-dark-1);
  font-weight: 500;
  border-bottom-right-radius: 6px;
  box-shadow: 0 2px 12px rgba(212, 160, 23, 0.2);
}

#gs-chat-widget .gs-msg-time {
  font-size: 0.66rem;
  margin-top: 5px;
  padding: 0 4px;
  opacity: 0.5;
}

#gs-chat-widget .gs-msg.bot .gs-msg-time { color: var(--gs-text-muted); }
#gs-chat-widget .gs-msg.user .gs-msg-time { color: var(--gs-text-muted); text-align: right; }

/* ============ TYPING ============ */
#gs-chat-widget .gs-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 18px;
  align-self: flex-start;
  background: var(--gs-dark-3);
  border: 1px solid var(--gs-border);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  animation: gs-msgIn 0.3s ease;
}

#gs-chat-widget .gs-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gs-gold);
  animation: gs-bounce 1.4s ease-in-out infinite;
}

#gs-chat-widget .gs-typing span:nth-child(2) { animation-delay: 0.16s; }
#gs-chat-widget .gs-typing span:nth-child(3) { animation-delay: 0.32s; }

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

/* ============ QUICK ACTIONS ============ */
#gs-chat-widget .gs-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 4px 18px 14px;
  flex-shrink: 0;
}

#gs-chat-widget .gs-quick-btn {
  padding: 8px 16px;
  border-radius: 24px;
  border: 1px solid var(--gs-border);
  background: var(--gs-dark-3);
  color: var(--gs-text-secondary);
  font-size: 0.76rem;
  font-weight: 500;
  font-family: 'Be Vietnam Pro', sans-serif;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
  letter-spacing: 0.1px;
}

#gs-chat-widget .gs-quick-btn:hover {
  border-color: var(--gs-gold);
  color: var(--gs-gold-light);
  background: var(--gs-gold-glow);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(212, 160, 23, 0.1);
}

/* ============ INPUT AREA ============ */
#gs-chat-widget .gs-input-area {
  padding: 14px 18px;
  border-top: 1px solid var(--gs-border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
  background: var(--gs-dark-2);
}

#gs-chat-widget .gs-input {
  flex: 1;
  background: var(--gs-dark-4);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--gs-radius-xs);
  padding: 11px 16px;
  color: var(--gs-text);
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 0.86rem;
  resize: none;
  outline: none;
  max-height: 100px;
  line-height: 1.5;
  transition: all 0.25s ease;
}

#gs-chat-widget .gs-input::placeholder {
  color: var(--gs-text-muted);
}

#gs-chat-widget .gs-input:focus {
  border-color: var(--gs-gold);
  background: var(--gs-dark-5);
  box-shadow: 0 0 0 3px rgba(212, 160, 23, 0.08);
}

/* Send Button with "Gửi" text */
#gs-chat-widget .gs-send-btn {
  height: 42px;
  padding: 0 18px;
  border-radius: var(--gs-radius-xs);
  border: none;
  background: linear-gradient(145deg, var(--gs-gold), var(--gs-gold-dark));
  color: var(--gs-dark-1);
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.25s ease;
  flex-shrink: 0;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 8px rgba(212, 160, 23, 0.2);
}

#gs-chat-widget .gs-send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(212, 160, 23, 0.35);
}

#gs-chat-widget .gs-send-btn:active {
  transform: translateY(0);
}

#gs-chat-widget .gs-send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

#gs-chat-widget .gs-send-btn svg {
  flex-shrink: 0;
}

/* ============ FOOTER ============ */
#gs-chat-widget .gs-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px;
  font-size: 0.65rem;
  color: var(--gs-text-muted);
  opacity: 0.5;
  flex-shrink: 0;
  background: var(--gs-dark-2);
  border-top: 1px solid rgba(255,255,255,0.02);
}

/* ============ MOBILE ============ */
@media (max-width: 480px) {
  #gs-chat-widget .gs-chat-window {
    width: calc(100vw - 16px);
    height: calc(100vh - 100px);
    max-height: calc(100vh - 100px);
    border-radius: 16px;
  }

  #gs-chat-widget[data-position="right"] .gs-chat-window { right: -16px; }
  #gs-chat-widget[data-position="left"] .gs-chat-window { left: -16px; }

  #gs-chat-widget .gs-quick-actions {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
  }

  #gs-chat-widget .gs-quick-actions::-webkit-scrollbar { display: none; }
}

/* ============ ANIMATIONS FOR WINDOW OPEN ============ */
#gs-chat-widget .gs-chat-window.visible .gs-header {
  animation: gs-slideDown 0.4s ease 0.05s both;
}

#gs-chat-widget .gs-chat-window.visible .gs-messages {
  animation: gs-slideDown 0.4s ease 0.1s both;
}

#gs-chat-widget .gs-chat-window.visible .gs-quick-actions {
  animation: gs-slideDown 0.4s ease 0.15s both;
}

#gs-chat-widget .gs-chat-window.visible .gs-input-area {
  animation: gs-slideDown 0.4s ease 0.2s both;
}

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

/* ============ CONSULTATION FORM ============ */
#gs-chat-widget .gs-form-card {
  margin: 8px 0;
  background: var(--gs-dark-3);
  border: 1px solid var(--gs-border-hover);
  border-radius: var(--gs-radius-sm);
  overflow: visible;
  animation: gs-msgIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  width: 100%;
  position: relative;
  z-index: 100;
  pointer-events: auto !important;
}

#gs-chat-widget .gs-form-card * {
  pointer-events: auto !important;
}

#gs-chat-widget .gs-form-card input,
#gs-chat-widget .gs-form-card select,
#gs-chat-widget .gs-form-card button {
  -webkit-user-select: auto !important;
  user-select: auto !important;
  -webkit-appearance: none;
  touch-action: manipulation;
}

#gs-chat-widget .gs-form-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  background: linear-gradient(145deg, rgba(212, 160, 23, 0.12), rgba(212, 160, 23, 0.04));
  border-bottom: 1px solid var(--gs-border);
}

#gs-chat-widget .gs-form-icon {
  font-size: 1.6rem;
  line-height: 1;
}

#gs-chat-widget .gs-form-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gs-gold-light);
  letter-spacing: 0.2px;
}

#gs-chat-widget .gs-form-subtitle {
  font-size: 0.8rem;
  color: var(--gs-text-muted);
  margin-top: 2px;
}

#gs-chat-widget .gs-form-fields {
  padding: 18px 20px 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#gs-chat-widget .gs-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#gs-chat-widget .gs-form-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--gs-text-secondary);
  letter-spacing: 0.2px;
}

#gs-chat-widget .gs-required {
  color: var(--gs-red);
}

#gs-chat-widget .gs-form-input {
  background: var(--gs-dark-4);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--gs-radius-xs);
  padding: 12px 16px;
  color: var(--gs-text);
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 0.92rem;
  outline: none;
  transition: all 0.25s ease;
  width: 100%;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  pointer-events: auto !important;
  position: relative;
  z-index: 10;
  cursor: text;
}

#gs-chat-widget .gs-form-input::placeholder {
  color: var(--gs-text-muted);
}

#gs-chat-widget .gs-form-input:focus {
  border-color: var(--gs-gold);
  background: var(--gs-dark-5);
  box-shadow: 0 0 0 3px rgba(212, 160, 23, 0.08);
}

#gs-chat-widget .gs-form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%236B6E78'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
  pointer-events: auto !important;
  position: relative;
  z-index: 10;
}

#gs-chat-widget .gs-form-select option {
  background: var(--gs-dark-3);
  color: var(--gs-text);
}

#gs-chat-widget .gs-form-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 40px);
  margin: 10px 20px 14px;
  padding: 14px;
  border: none;
  border-radius: var(--gs-radius-xs);
  background: linear-gradient(145deg, var(--gs-gold), var(--gs-gold-dark));
  color: var(--gs-dark-1);
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 2px 12px rgba(212, 160, 23, 0.25);
  letter-spacing: 0.3px;
}

#gs-chat-widget .gs-form-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(212, 160, 23, 0.4);
}

#gs-chat-widget .gs-form-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

#gs-chat-widget .gs-form-note {
  text-align: center;
  font-size: 0.76rem;
  color: var(--gs-text-muted);
  padding: 0 20px 16px;
  opacity: 0.6;
}

/* Spinner */
#gs-chat-widget .gs-form-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(13, 15, 20, 0.3);
  border-top-color: var(--gs-dark-1);
  border-radius: 50%;
  animation: gs-spin 0.6s linear infinite;
  display: inline-block;
}

@keyframes gs-spin {
  to { transform: rotate(360deg); }
}

/* Shake validation */
#gs-chat-widget .gs-shake {
  animation: gs-shake 0.4s ease;
  border-color: var(--gs-red) !important;
}

@keyframes gs-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* Form Success */
#gs-chat-widget .gs-form-success {
  padding: 32px 24px;
  text-align: center;
  animation: gs-msgIn 0.4s ease;
}

#gs-chat-widget .gs-form-success-icon {
  font-size: 2.6rem;
  margin-bottom: 12px;
  line-height: 1;
}

#gs-chat-widget .gs-form-success-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gs-green);
  margin-bottom: 8px;
}

#gs-chat-widget .gs-form-success-text {
  font-size: 0.9rem;
  color: var(--gs-text-secondary);
  line-height: 1.6;
}
