/* ─── GRAND VISTA CHAT WIDGET ──────────────────────────────────────── */
:root {
  --gv-color: #c9a84c;
  --gv-navy: #1a2744;
  --gv-navy2: #1e2f52;
  --gv-dark: #0f1829;
  --gv-text: #e8e4dd;
  --gv-muted: rgba(232,228,221,.55);
  --gv-border: rgba(201,168,76,.18);
  --gv-bubble-user: #c9a84c;
  --gv-bubble-bot: rgba(255,255,255,.07);
  --gv-radius: 16px;
  --gv-shadow: 0 24px 80px rgba(0,0,0,.45);
  --gv-transition: .3s cubic-bezier(.4,0,.2,1);
}

/* ─── TRIGGER BUTTON ────────────────────────────────────────────────── */
#gv-trigger {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9998;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--gv-navy);
  border: 2px solid var(--gv-color);
  box-shadow: 0 8px 32px rgba(0,0,0,.35), 0 0 0 0 rgba(201,168,76,.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--gv-transition), box-shadow var(--gv-transition);
  animation: gvPulse 3s 2s infinite;
}

#gv-trigger:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 40px rgba(0,0,0,.45), 0 0 0 8px rgba(201,168,76,.15);
  animation: none;
}

#gv-trigger svg {
  width: 26px;
  height: 26px;
  fill: var(--gv-color);
  transition: transform var(--gv-transition);
}

#gv-trigger.open svg { transform: scale(0.85) rotate(15deg); }

@keyframes gvPulse {
  0%,100% { box-shadow: 0 8px 32px rgba(0,0,0,.35), 0 0 0 0 rgba(201,168,76,.4); }
  50%      { box-shadow: 0 8px 32px rgba(0,0,0,.35), 0 0 0 12px rgba(201,168,76,0); }
}

/* ─── UNREAD BADGE ──────────────────────────────────────────────────── */
#gv-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e53e3e;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-family: sans-serif;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

/* ─── CHAT WINDOW ───────────────────────────────────────────────────── */
#gv-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9999;
  width: 380px;
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--gv-dark);
  border-radius: var(--gv-radius);
  border: 1px solid var(--gv-border);
  box-shadow: var(--gv-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform var(--gv-transition), opacity var(--gv-transition);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

/* ─── HEADER ────────────────────────────────────────────────────────── */
#gv-header {
  background: linear-gradient(135deg, var(--gv-navy) 0%, var(--gv-navy2) 100%);
  border-bottom: 1px solid var(--gv-border);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.gv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gv-color), #8b6914);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  border: 2px solid rgba(201,168,76,.4);
}

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

.gv-header-name {
  font-size: .95rem;
  font-weight: 600;
  color: var(--gv-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gv-header-sub {
  font-size: .75rem;
  color: var(--gv-muted);
  margin-top: 1px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.gv-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #48bb78;
  flex-shrink: 0;
  animation: gvBlink 2s infinite;
}

@keyframes gvBlink {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

#gv-close {
  background: rgba(255,255,255,.08);
  border: none;
  color: var(--gv-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--gv-transition), color var(--gv-transition);
  flex-shrink: 0;
}

#gv-close:hover { background: rgba(255,255,255,.15); color: var(--gv-text); }

/* ─── MESSAGES AREA ─────────────────────────────────────────────────── */
#gv-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

#gv-messages::-webkit-scrollbar { width: 4px; }
#gv-messages::-webkit-scrollbar-track { background: transparent; }
#gv-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }

/* ─── MESSAGE BUBBLES ───────────────────────────────────────────────── */
.gv-msg {
  display: flex;
  gap: 10px;
  animation: gvMsgIn .3s ease forwards;
}

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

.gv-msg.user { flex-direction: row-reverse; }
.gv-msg > div:not(.gv-msg-avatar) { min-width: 0; max-width: calc(100% - 44px); }

.gv-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  margin-top: auto;
}

.gv-msg.bot .gv-msg-avatar {
  background: linear-gradient(135deg, var(--gv-color), #8b6914);
}

.gv-msg.user .gv-msg-avatar {
  background: var(--gv-navy2);
  color: var(--gv-color);
  font-weight: 700;
}

.gv-bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: .88rem;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  hyphens: none;
}

.gv-msg.bot .gv-bubble {
  background: var(--gv-bubble-bot);
  border: 1px solid var(--gv-border);
  color: var(--gv-text);
  border-bottom-left-radius: 4px;
}

.gv-msg.user .gv-bubble {
  background: var(--gv-bubble-user);
  color: var(--gv-navy);
  font-weight: 500;
  border-bottom-right-radius: 4px;
}

.gv-msg-time {
  font-size: .7rem;
  color: var(--gv-muted);
  margin-top: 4px;
  text-align: right;
  padding: 0 4px;
}

.gv-msg.bot .gv-msg-time { text-align: left; }

/* ─── TYPING INDICATOR ──────────────────────────────────────────────── */
#gv-typing {
  display: none;
  padding: 0 16px 8px;
  flex-shrink: 0;
}

#gv-typing.show { display: flex; }

.gv-typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--gv-bubble-bot);
  border: 1px solid var(--gv-border);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
}

.gv-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gv-color);
  animation: gvDot 1.4s infinite;
}

.gv-typing-dots span:nth-child(2) { animation-delay: .2s; }
.gv-typing-dots span:nth-child(3) { animation-delay: .4s; }

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

/* ─── INPUT AREA ────────────────────────────────────────────────────── */
#gv-footer {
  border-top: 1px solid var(--gv-border);
  padding: 12px 16px;
  flex-shrink: 0;
  background: rgba(255,255,255,.02);
}

#gv-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

#gv-input {
  flex: 1;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--gv-border);
  border-radius: 12px;
  color: var(--gv-text);
  font-size: .88rem;
  font-family: 'Inter', sans-serif;
  padding: 10px 14px;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  outline: none;
  transition: border-color var(--gv-transition), background var(--gv-transition);
  line-height: 1.5;
}

#gv-input::placeholder { color: var(--gv-muted); }
#gv-input:focus { border-color: var(--gv-color); background: rgba(255,255,255,.1); }

#gv-send {
  background: var(--gv-color);
  border: none;
  border-radius: 12px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--gv-transition);
  flex-shrink: 0;
}

#gv-send:hover { background: #e8c96e; transform: scale(1.05); }
#gv-send:disabled { opacity: .45; cursor: not-allowed; transform: none; }

#gv-send svg {
  width: 18px;
  height: 18px;
  fill: var(--gv-navy);
}

.gv-branding {
  text-align: center;
  font-size: .68rem;
  color: var(--gv-muted);
  margin-top: 8px;
  letter-spacing: .04em;
}

/* ─── MOBILE FULLSCREEN ─────────────────────────────────────────────── */
@media (max-width: 480px) {
  #gv-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    transform: translateY(100%);
    opacity: 1;
  }

  #gv-window.open { transform: translateY(0); }

  #gv-trigger {
    bottom: 20px;
    right: 20px;
  }
}
