/* ==========================================================================
   Global Village Tunisia 2027 — AI Concierge
   Floating launcher + chat panel (desktop), full-screen chat (phones).
   Markup is built by assets/js/concierge.js.
   ========================================================================== */

#gv-concierge-root {
  --gv-gold: #D4AF37;
  --gv-gold-light: #F3E5AB;
  --gv-gold-deep: #A8842A;
  --gv-ink: #0B0C10;
  --gv-panel: #13141A;
  --gv-line: rgba(255, 255, 255, 0.08);
  --gv-gold-line: rgba(212, 175, 55, 0.28);
  --gv-text: #ECE9E2;
  --gv-muted: rgba(236, 233, 226, 0.58);
  --gv-ease: cubic-bezier(0.16, 1, 0.3, 1);
  font-family: 'Plus Jakarta Sans', 'Tajawal', system-ui, -apple-system, sans-serif;
}

#gv-concierge-root[dir="rtl"] {
  font-family: 'Tajawal', 'Plus Jakarta Sans', system-ui, sans-serif;
}

/* Zero-specificity reset, so each button's own font-size still applies. */
:where(#gv-concierge-root button) {
  font: inherit;
}

/* Keep scroll-to-top button on the left to avoid overlapping with concierge launcher */
#scrollTopBtn {
  left: 20px !important;
  right: auto !important;
  inset-inline-start: 20px !important;
  inset-inline-end: auto !important;
}

@media (max-width: 768px) {
  #scrollTopBtn {
    left: 16px !important;
    right: auto !important;
    inset-inline-start: 16px !important;
    inset-inline-end: auto !important;
  }
}

/* ---------- Launcher ---------- */
#gv-concierge-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 20px 6px 6px;
  border: 1px solid rgba(212, 175, 55, 0.38);
  border-radius: 999px;
  background: linear-gradient(135deg, #191A21 0%, #0C0D11 100%);
  color: #fff;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 14px 30px -10px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(0, 0, 0, 0.4), 0 0 26px rgba(212, 175, 55, 0.16);
  transition: transform 0.3s var(--gv-ease), border-color 0.3s ease, box-shadow 0.3s ease;
}

#gv-concierge-root[dir="rtl"] #gv-concierge-launcher {
  padding: 6px 6px 6px 20px;
}

#gv-concierge-launcher:hover {
  transform: translateY(-3px);
  border-color: rgba(212, 175, 55, 0.7);
  box-shadow: 0 18px 36px -10px rgba(0, 0, 0, 0.85), 0 0 34px rgba(212, 175, 55, 0.3);
}

#gv-concierge-launcher:active {
  transform: translateY(0) scale(0.97);
}

#gv-concierge-launcher:focus-visible {
  outline: 2px solid var(--gv-gold);
  outline-offset: 3px;
}

.gv-launcher-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  color: #17130A;
  background: linear-gradient(140deg, #F6DE8D 0%, #D4AF37 55%, #A8842A 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 4px 12px rgba(212, 175, 55, 0.35);
}

/* Soft gold ring that pulses out of the button while the chat is closed. */
.gv-launcher-icon::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px solid rgba(212, 175, 55, 0.55);
  opacity: 0;
  animation: gv-ring 3.2s ease-out infinite;
  pointer-events: none;
}

@keyframes gv-ring {
  0% { opacity: 0.7; transform: scale(0.9); }
  70%, 100% { opacity: 0; transform: scale(1.35); }
}

.gv-launcher-glyph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transition: opacity 0.25s ease, transform 0.35s var(--gv-ease);
}

.gv-glyph-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}

.gv-launcher-dot {
  position: absolute;
  top: 0;
  right: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22C55E;
  border: 2px solid #0E0F13;
  transition: opacity 0.2s ease;
}

html.gv-concierge-open .gv-glyph-chat {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

html.gv-concierge-open .gv-glyph-close {
  opacity: 1;
  transform: none;
}

html.gv-concierge-open .gv-launcher-dot,
html.gv-concierge-open .gv-launcher-icon::after {
  opacity: 0;
  animation: none;
}

.gv-launcher-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  text-align: start;
}

.gv-launcher-title {
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #fff;
}

.gv-launcher-subtitle {
  margin-top: 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gv-gold);
}

/* ---------- Chat panel ---------- */
#gv-concierge-window {
  position: fixed;
  right: 24px;
  bottom: 96px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: min(640px, calc(100vh - 128px));
  overflow: hidden;
  color: var(--gv-text);
  border: 1px solid var(--gv-gold-line);
  border-radius: 22px;
  background:
    radial-gradient(130% 50% at 100% 0%, rgba(212, 175, 55, 0.13), rgba(212, 175, 55, 0) 62%),
    linear-gradient(180deg, #15161C 0%, #0C0D11 100%);
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(0, 0, 0, 0.5), 0 0 50px rgba(212, 175, 55, 0.1);
  transform-origin: bottom right;
  transition: opacity 0.28s var(--gv-ease), transform 0.34s var(--gv-ease), visibility 0.34s;
}

/* Gold hairline along the top edge */
#gv-concierge-window::before {
  content: '';
  position: absolute;
  top: 0;
  left: 12%;
  right: 12%;
  height: 1px;
  background: linear-gradient(90deg, rgba(212, 175, 55, 0), rgba(243, 229, 171, 0.9), rgba(212, 175, 55, 0));
  pointer-events: none;
}

#gv-concierge-window.gv-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(14px) scale(0.94);
}

/* Header */
.gv-concierge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  border-bottom: 1px solid var(--gv-line);
}

.gv-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.gv-header-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2A2418, #0E0E12);
  box-shadow: 0 0 0 1.5px rgba(212, 175, 55, 0.65), 0 0 18px rgba(212, 175, 55, 0.25);
}

.gv-header-avatar img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.gv-status-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22C55E;
  border: 2px solid #13141A;
}

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

.gv-header-info h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  color: #fff;
}

.gv-header-status {
  margin: 3px 0 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 11.5px;
  color: var(--gv-muted);
}

.gv-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.gv-header-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--gv-muted);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.gv-header-btn:hover,
.gv-header-btn:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  outline: none;
}

/* Messages feed */
.gv-concierge-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding: 18px 16px 12px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 175, 55, 0.25) transparent;
}

.gv-concierge-messages::-webkit-scrollbar {
  width: 5px;
}

.gv-concierge-messages::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.25);
  border-radius: 10px;
}

/* Welcome card */
.gv-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 2px 4px;
  text-align: center;
  animation: gv-rise 0.4s var(--gv-ease) both;
}

.gv-welcome-emblem {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  margin-bottom: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2C2619, #0E0E12 70%);
  box-shadow: 0 0 0 1.5px rgba(212, 175, 55, 0.55), 0 0 0 7px rgba(212, 175, 55, 0.07), 0 10px 30px rgba(212, 175, 55, 0.2);
}

.gv-welcome-emblem img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.gv-welcome-kicker {
  margin: 0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gv-gold);
}

#gv-concierge-root[dir="rtl"] .gv-welcome-kicker {
  letter-spacing: 0;
  font-size: 12px;
}

.gv-welcome-title {
  margin: 6px 0 0;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.3;
  color: #fff;
}

.gv-welcome-text {
  margin: 6px 0 0;
  max-width: 320px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--gv-muted);
}

.gv-suggestions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  margin-top: 16px;
}

.gv-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 8px 11px;
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  color: #EDE6D3;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  text-align: start;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.gv-chip:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.gv-chip:hover,
.gv-chip:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(212, 175, 55, 0.6);
  background: rgba(212, 175, 55, 0.09);
  color: #fff;
  outline: none;
}

.gv-chip-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 9px;
  color: var(--gv-gold);
  background: rgba(212, 175, 55, 0.12);
}

.gv-busy .gv-chip {
  opacity: 0.55;
  pointer-events: none;
}

/* Messages */
.gv-message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 88%;
  animation: gv-rise 0.28s var(--gv-ease) both;
}

@keyframes gv-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.gv-message-user {
  align-self: flex-end;
}

.gv-message-model {
  align-self: flex-start;
}

.gv-msg-avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  margin-bottom: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2A2418, #0E0E12);
  box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.5);
}

.gv-msg-avatar img {
  width: 19px;
  height: 19px;
  object-fit: contain;
}

.gv-msg-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.gv-message-bubble {
  padding: 11px 14px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.gv-message-model .gv-message-bubble {
  border: 1px solid var(--gv-line);
  border-end-start-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--gv-text);
}

.gv-message-user .gv-message-bubble {
  border-end-end-radius: 6px;
  background: linear-gradient(135deg, #EDCB6C 0%, #D4AF37 55%, #B8932B 100%);
  color: #19140A;
  font-weight: 600;
  box-shadow: 0 6px 18px -8px rgba(212, 175, 55, 0.55);
}

.gv-message-bubble p {
  margin: 0 0 7px;
}

.gv-message-bubble p:last-child {
  margin-bottom: 0;
}

.gv-message-model .gv-message-bubble strong {
  color: var(--gv-gold-light);
  font-weight: 700;
}

.gv-message-model .gv-message-bubble em {
  color: rgba(255, 255, 255, 0.78);
}

.gv-message-model .gv-message-bubble a {
  color: var(--gv-gold);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: rgba(212, 175, 55, 0.45);
  text-underline-offset: 3px;
}

.gv-message-model .gv-message-bubble a:hover {
  color: #fff;
  text-decoration-color: #fff;
}

/* Replies use short bullet lists: gold dots instead of the default disc
   (Tailwind's preflight strips list markers anyway). */
.gv-message-bubble ul {
  margin: 6px 0;
  padding: 0;
  list-style: none;
}

.gv-message-bubble li {
  position: relative;
  margin-bottom: 5px;
  padding-inline-start: 15px;
}

.gv-message-bubble li:last-child {
  margin-bottom: 0;
}

.gv-message-bubble li::before {
  content: '';
  position: absolute;
  top: 0.62em;
  inset-inline-start: 2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gv-gold);
}

.gv-message-time {
  margin-top: 5px;
  padding: 0 6px;
  font-size: 10px;
  color: rgba(236, 233, 226, 0.35);
}

.gv-message-user .gv-message-time {
  align-self: flex-end;
}

/* Error reply */
.gv-message-error .gv-message-bubble {
  display: flex;
  gap: 8px;
  border-color: rgba(248, 113, 113, 0.32);
  background: rgba(248, 113, 113, 0.07);
  color: #FBCACA;
}

.gv-error-icon {
  flex-shrink: 0;
  margin-top: 2px;
  color: #F87171;
}

/* Typing indicator */
.gv-typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 16px;
}

.gv-typing .gv-msg-avatar {
  margin-bottom: 0;
}

.gv-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gv-gold);
  animation: gv-bounce 1.3s infinite ease-in-out both;
}

.gv-typing-dot:nth-child(1) { animation-delay: -0.3s; }
.gv-typing-dot:nth-child(2) { animation-delay: -0.15s; }

@keyframes gv-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* Input */
.gv-concierge-input-area {
  padding: 12px 14px 12px;
  border-top: 1px solid var(--gv-line);
  background: rgba(9, 10, 13, 0.75);
}

.gv-concierge-input-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px;
  padding-inline-start: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.gv-concierge-input-form:focus-within {
  border-color: rgba(212, 175, 55, 0.6);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.12);
}

#gv-concierge-input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 14px;
  line-height: 30px;
}

#gv-concierge-input::placeholder {
  color: rgba(236, 233, 226, 0.42);
}

/* The form already highlights itself on focus; drop the site-wide focus
   ring / glow (index.html applies them to every input with !important). */
#gv-concierge-input:focus,
#gv-concierge-input:focus-visible {
  outline: none !important;
  box-shadow: none !important;
  border: none;
}

#gv-concierge-send {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(140deg, #F6DE8D 0%, #D4AF37 55%, #A8842A 100%);
  color: #17130A;
  cursor: pointer;
  box-shadow: 0 4px 14px -4px rgba(212, 175, 55, 0.6);
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

#gv-concierge-root[dir="rtl"] #gv-concierge-send svg {
  transform: scaleX(-1);
}

#gv-concierge-send:hover:not(:disabled) {
  transform: scale(1.06);
}

#gv-concierge-send:focus-visible {
  outline: 2px solid var(--gv-gold-light);
  outline-offset: 2px;
}

#gv-concierge-send:disabled {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(236, 233, 226, 0.35);
  box-shadow: none;
  cursor: default;
}

.gv-concierge-footer-note {
  margin: 8px 0 0;
  text-align: center;
  font-size: 10.5px;
  color: rgba(236, 233, 226, 0.34);
}

/* ---------- Tablet & phone ----------
   index.html shows a bottom navigation dock below lg (1024px): lift the
   launcher and panel above it there. pro.html has no dock. */
@media (max-width: 1023px) {
  #gv-concierge-launcher {
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  #gv-concierge-window {
    right: 16px;
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    height: min(620px, calc(100dvh - 120px));
  }

  .gv-has-dock #gv-concierge-launcher {
    bottom: calc(max(0.65rem, env(safe-area-inset-bottom, 0px)) + 72px);
  }

  .gv-has-dock #gv-concierge-window {
    bottom: calc(max(0.65rem, env(safe-area-inset-bottom, 0px)) + 144px);
    height: min(620px, calc(100dvh - 176px));
  }

  /* Chat open: hide the dock and scroll-to-top button behind it */
  html.gv-concierge-open #mobileBottomDock,
  html.gv-concierge-open #scrollTopBtn {
    opacity: 0 !important;
    pointer-events: none !important;
  }
}

/* Phones: round launcher, full-screen chat */
@media (max-width: 640px) {
  #gv-concierge-launcher {
    padding: 5px !important;
    gap: 0;
  }

  #gv-concierge-launcher .gv-launcher-text {
    display: none;
  }

  .gv-launcher-icon {
    width: 48px;
    height: 48px;
  }

  #gv-concierge-window {
    top: 0;
    left: 0;
    right: 0;
    bottom: auto !important;
    width: 100%;
    max-width: none;
    /* dvh = visible height (excludes the browser bars); concierge.js
       overrides it with the visual viewport height while the keyboard is open. */
    height: 100vh !important;
    height: 100dvh !important;
    max-height: none;
    border: 0;
    border-radius: 0;
    transform-origin: bottom center;
  }

  #gv-concierge-window::before {
    display: none;
  }

  #gv-concierge-window.gv-hidden {
    transform: translateY(24px);
  }

  html.gv-concierge-open,
  html.gv-concierge-open body {
    overflow: hidden !important;
    overscroll-behavior: none;
  }

  html.gv-concierge-open #gv-concierge-launcher {
    opacity: 0;
    pointer-events: none;
  }

  .gv-concierge-header {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }

  .gv-header-btn {
    width: 42px;
    height: 42px;
  }

  .gv-concierge-messages {
    padding: 20px 14px 12px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .gv-welcome {
    padding-top: 10px;
  }

  .gv-welcome-emblem {
    width: 68px;
    height: 68px;
  }

  .gv-welcome-emblem img {
    width: 46px;
    height: 46px;
  }

  .gv-welcome-title {
    font-size: 20px;
  }

  .gv-welcome-text {
    font-size: 14px;
  }

  .gv-chip {
    min-height: 54px;
    font-size: 13.5px;
  }

  .gv-message {
    max-width: 92%;
  }

  .gv-message-bubble {
    font-size: 15px;
  }

  .gv-concierge-input-area {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  /* 16px+ stops iOS Safari from zooming the page when the input gets focus */
  #gv-concierge-input {
    font-size: 16px;
    height: 34px;
    line-height: 34px;
  }

  #gv-concierge-send {
    width: 42px;
    height: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {

  #gv-concierge-root *,
  #gv-concierge-root *::before,
  #gv-concierge-root *::after,
  #gv-concierge-window {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}
