/* GodwulfNexus Chatbot Widget
   Brand system: dark backgrounds, forest green (#2D5A3D), ice blue (#A8C5D8)
   Fonts: Cinzel (display), Barlow (body)
   Loaded via Google Fonts on parent page
*/

/* ── Reset & tokens ─────────────────────────────────────────────── */
#gn-chat-root *,
#gn-chat-root *::before,
#gn-chat-root *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

#gn-chat-root {
  --gn-green:        #2D5A3D;
  --gn-green-light:  #3A7050;
  --gn-green-dark:   #1E3D2A;
  --gn-blue:         #A8C5D8;
  --gn-blue-dim:     #7BA3BC;
  --gn-bg:           #0F1A14;
  --gn-surface:      #1A2B20;
  --gn-surface-2:    #223328;
  --gn-border:       #2D5A3D44;
  --gn-text:         #E8EDE9;
  --gn-text-dim:     #8FA898;
  --gn-user-bg:      #2D5A3D;
  --gn-bot-bg:       #1A2B20;
  --gn-radius:       12px;
  --gn-radius-sm:    8px;
  --gn-shadow:       0 8px 32px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
  --gn-font-display: 'Cinzel', 'Georgia', serif;
  --gn-font-body:    'Barlow', 'system-ui', sans-serif;
  font-family: var(--gn-font-body);
}

/* ── Trigger button ─────────────────────────────────────────────── */
#gn-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gn-green);
  border: 1.5px solid var(--gn-green-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--gn-shadow);
  z-index: 9998;
  transition: transform 0.2s ease, background 0.2s ease;
  animation: gn-rise 0.4s ease both;
}

#gn-trigger:hover {
  background: var(--gn-green-light);
  transform: scale(1.06);
}

#gn-trigger:focus-visible {
  outline: 2px solid var(--gn-blue);
  outline-offset: 3px;
}

#gn-trigger svg {
  width: 26px;
  height: 26px;
  fill: var(--gn-blue);
}

@keyframes gn-rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  #gn-trigger { animation: none; }
}

/* ── Chat panel ─────────────────────────────────────────────────── */
#gn-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 110px);
  background: var(--gn-bg);
  border: 1px solid var(--gn-border);
  border-radius: var(--gn-radius);
  box-shadow: var(--gn-shadow);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  transform-origin: bottom right;
  animation: gn-open 0.22s cubic-bezier(0.34,1.56,0.64,1) both;
}

#gn-panel.gn-hidden {
  display: none;
}

@keyframes gn-open {
  from { opacity: 0; transform: scale(0.88) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  #gn-panel { animation: none; }
}

/* Mobile: full screen */
@media (max-width: 479px) {
  #gn-panel {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }
  #gn-trigger {
    bottom: 16px;
    right: 16px;
  }
}

/* ── Panel header ───────────────────────────────────────────────── */
#gn-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--gn-surface);
  border-bottom: 1px solid var(--gn-border);
  flex-shrink: 0;
}

#gn-header-logo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gn-green);
  border: 1px solid var(--gn-green-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#gn-header-logo svg {
  width: 18px;
  height: 18px;
  fill: var(--gn-blue);
}

#gn-header-text {
  flex: 1;
}

#gn-header-title {
  font-family: var(--gn-font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--gn-blue);
  line-height: 1.2;
}

#gn-header-subtitle {
  font-size: 11px;
  color: var(--gn-text-dim);
  margin-top: 1px;
}

#gn-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gn-text-dim);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
  flex-shrink: 0;
}

#gn-close:hover { color: var(--gn-text); }

#gn-close:focus-visible {
  outline: 2px solid var(--gn-blue);
  outline-offset: 2px;
}

#gn-close svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

/* ── Messages area ──────────────────────────────────────────────── */
#gn-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

#gn-messages::-webkit-scrollbar {
  width: 4px;
}
#gn-messages::-webkit-scrollbar-track {
  background: transparent;
}
#gn-messages::-webkit-scrollbar-thumb {
  background: var(--gn-border);
  border-radius: 2px;
}

/* ── Individual messages ────────────────────────────────────────── */
.gn-msg {
  display: flex;
  gap: 8px;
  max-width: 100%;
}

.gn-msg-bot {
  align-items: flex-start;
}

.gn-msg-user {
  align-items: flex-end;
  flex-direction: row-reverse;
}

.gn-bubble {
  padding: 10px 13px;
  border-radius: var(--gn-radius-sm);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--gn-text);
  max-width: 82%;
  word-break: break-word;
}

.gn-msg-bot .gn-bubble {
  background: var(--gn-bot-bg);
  border: 1px solid var(--gn-border);
  border-top-left-radius: 3px;
}

.gn-msg-user .gn-bubble {
  background: var(--gn-user-bg);
  border: 1px solid var(--gn-green-light);
  border-top-right-radius: 3px;
  color: #E8EDE9;
}

/* Links inside bot messages */
.gn-bubble a {
  color: var(--gn-blue);
  text-decoration: underline;
  text-decoration-color: var(--gn-blue-dim);
  text-underline-offset: 2px;
}

.gn-bubble a:hover {
  color: #fff;
}

/* ── Typing indicator ───────────────────────────────────────────── */
.gn-typing {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  align-items: center;
}

.gn-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gn-text-dim);
  animation: gn-pulse 1.2s ease-in-out infinite;
}

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

@keyframes gn-pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40%            { opacity: 1;   transform: scale(1.1); }
}

@media (prefers-reduced-motion: reduce) {
  .gn-typing span { animation: none; opacity: 0.6; }
}

/* ── Input area ─────────────────────────────────────────────────── */
#gn-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  background: var(--gn-surface);
  border-top: 1px solid var(--gn-border);
  flex-shrink: 0;
}

#gn-input {
  flex: 1;
  background: var(--gn-surface-2);
  border: 1px solid var(--gn-border);
  border-radius: 20px;
  padding: 9px 14px;
  font-family: var(--gn-font-body);
  font-size: 13.5px;
  color: var(--gn-text);
  outline: none;
  transition: border-color 0.15s;
  resize: none;
  min-height: 38px;
  max-height: 100px;
  line-height: 1.4;
}

#gn-input::placeholder {
  color: var(--gn-text-dim);
}

#gn-input:focus {
  border-color: var(--gn-green-light);
}

#gn-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gn-green);
  border: 1px solid var(--gn-green-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
  transition: background 0.15s, transform 0.15s;
}

#gn-send:hover:not(:disabled) {
  background: var(--gn-green-light);
  transform: scale(1.05);
}

#gn-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#gn-send:focus-visible {
  outline: 2px solid var(--gn-blue);
  outline-offset: 2px;
}

#gn-send svg {
  width: 16px;
  height: 16px;
  fill: var(--gn-blue);
  margin-left: 1px;
}

/* ── Footer note ────────────────────────────────────────────────── */
#gn-footer {
  text-align: center;
  font-size: 10.5px;
  color: var(--gn-text-dim);
  padding: 6px 14px 10px;
  background: var(--gn-surface);
  border-top: 1px solid var(--gn-border);
  flex-shrink: 0;
}
