@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --gicu-teal: #0e3b37;
  --gicu-emerald: #1fae83;
  --gicu-coral: #ff6f4c;
  --gicu-coral-dark: #e85c3a;
  --gicu-bg: #f5f6f3;
  --gicu-card: #ffffff;
  --gicu-line: #e7e6de;
  --gicu-ink: #16211d;
  --gicu-ink-muted: #62716a;
  --gicu-radius-lg: 22px;
  --gicu-shadow-panel: 0 20px 48px rgba(14, 59, 55, 0.22), 0 4px 14px rgba(14, 59, 55, 0.12);
  --gicu-shadow-launcher: 0 10px 26px rgba(14, 59, 55, 0.32);
}

.gicu-root {
  position: fixed !important;
  bottom: 22px !important;
  right: 22px !important;
  left: auto !important;
  top: auto !important;
  z-index: 999999 !important;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--gicu-ink);
}

.gicu-root * {
  box-sizing: border-box;
}

.gicu-hidden {
  display: none !important;
}

/* ---------- Launcher bubble ---------- */
/* Full body, dibesarkan lagi: 104x172 -> 160x264. */

.gicu-launcher {
  width: 160px;
  height: 264px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.18s ease;
}

.gicu-launcher-hidden {
  opacity: 0;
  transform: translateY(10px) scale(0.92);
  pointer-events: none;
}

.gicu-launcher:hover {
  transform: translateY(-4px) scale(1.03);
}

.gicu-launcher:active {
  transform: translateY(-1px) scale(0.98);
}

.gicu-launcher:focus-visible {
  outline: 3px solid var(--gicu-coral);
  outline-offset: 4px;
  border-radius: 10px;
}

.gicu-launcher .gicu-avatar-img {
  object-fit: contain; /* full body — pastikan tak terpotong macam header */
  filter: drop-shadow(0 10px 18px rgba(14, 59, 55, 0.35));
}

/* ---------- Panel ---------- */

.gicu-panel {
  position: absolute;
  bottom: 0; /* anchor kat sudut bawah-kanan yang sama dengan launcher, sebab launcher hilang bila panel dibuka */
  right: 0;
  width: 440px;
  height: 660px;
  max-height: calc(100vh - 44px);
  background: var(--gicu-bg);
  border-radius: var(--gicu-radius-lg);
  box-shadow: var(--gicu-shadow-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  transform-origin: bottom right;
}

.gicu-panel.gicu-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

@media (max-width: 470px) {
  .gicu-panel {
    width: calc(100vw - 20px);
    right: -12px;
    height: calc(100vh - 64px);
  }
}

/* ---------- Header ---------- */

.gicu-header {
  background: linear-gradient(120deg, var(--gicu-teal) 0%, var(--gicu-emerald) 130%);
  color: #ffffff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Bulat, crop separuh badan (bahu ke atas) — beza dengan launcher yang
   full body, supaya nampak lebih kemas dalam header yang sempit. */
.gicu-header-mark {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2.5px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
  background: rgba(255, 255, 255, 0.15);
}

.gicu-header-mark .gicu-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center; /* crop badan bawah, tinggalkan muka + bahu */
}

.gicu-header-text {
  flex: 1;
  min-width: 0;
}

.gicu-header-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.25;
  letter-spacing: 0.01em;
}

.gicu-header-sub {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.72);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.gicu-header-sub-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade9b;
  box-shadow: 0 0 0 2px rgba(74, 222, 155, 0.25);
  flex-shrink: 0;
}

.gicu-lang-toggle {
  display: flex;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 100px;
  padding: 2px;
  flex-shrink: 0;
}

.gicu-lang-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.75);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 100px;
  letter-spacing: 0.02em;
  transition: background 0.15s ease, color 0.15s ease;
}

.gicu-lang-btn.gicu-active {
  background: #ffffff;
  color: var(--gicu-teal);
}

.gicu-lang-btn:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 1px;
}

.gicu-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  transition: background 0.15s ease, color 0.15s ease;
}

.gicu-close:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.16);
}

.gicu-close:focus-visible {
  outline: 2px solid #ffffff;
}

.gicu-close svg {
  width: 15px;
  height: 15px;
}

/* ---------- Messages ---------- */

.gicu-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.gicu-row {
  display: flex;
  gap: 8px;
  max-width: 92%;
  animation: gicu-msg-in 0.22s ease both;
}

@keyframes gicu-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.gicu-row-bot {
  align-self: flex-start;
  align-items: flex-start; /* circle avatar align ke atas mesej, macam chat app biasa */
}

.gicu-row-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

/* Avatar bulat (macam header) untuk setiap mesej bot — konsisten dengan
   header-mark: crop half-body (muka + bahu), bukan full body lagi. */
.gicu-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--gicu-line);
  box-shadow: 0 2px 6px rgba(14, 59, 55, 0.12);
  background: #ffffff;
}

.gicu-avatar svg {
  width: 100%;
  height: 100%;
}

.gicu-avatar .gicu-avatar-img {
  object-fit: cover;
  object-position: top center;
}

.gicu-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  user-select: none;
}

.gicu-bubble {
  padding: 10px 13px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
  min-width: 0;
  overflow-wrap: anywhere;
}

.gicu-bubble a {
  font-weight: 600;
  text-underline-offset: 2px;
  word-break: break-word;
}

.gicu-row-bot .gicu-bubble {
  background: var(--gicu-card);
  color: var(--gicu-ink);
  border-radius: 4px 16px 16px 16px;
  box-shadow: 0 1px 2px rgba(14, 59, 55, 0.06), 0 4px 10px rgba(14, 59, 55, 0.05);
}

.gicu-row-bot .gicu-bubble a {
  color: var(--gicu-emerald);
}

.gicu-row-user .gicu-bubble {
  background: linear-gradient(135deg, var(--gicu-coral) 0%, var(--gicu-coral-dark) 100%);
  color: #ffffff;
  border-radius: 16px 4px 16px 16px;
}

.gicu-row-user .gicu-bubble a {
  color: #ffffff;
}

.gicu-typing {
  display: inline-flex;
  gap: 4px;
  padding: 3px 2px;
}

.gicu-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gicu-emerald);
  animation: gicu-typing-bounce 1.1s infinite ease-in-out;
}

.gicu-typing span:nth-child(2) { animation-delay: 0.15s; }
.gicu-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes gicu-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- Input ---------- */

.gicu-inputbar {
  border-top: 1px solid var(--gicu-line);
  background: var(--gicu-card);
  padding: 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

.gicu-input {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--gicu-line);
  border-radius: 100px;
  padding: 10px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  line-height: 1.4;
  max-height: 90px;
  color: var(--gicu-ink);
  background: var(--gicu-bg);
  transition: border-color 0.15s ease;
}

.gicu-input:focus-visible {
  outline: none;
  border-color: var(--gicu-emerald);
}

.gicu-input::placeholder {
  color: var(--gicu-ink-muted);
}

.gicu-send {
  background: linear-gradient(135deg, var(--gicu-teal) 0%, var(--gicu-emerald) 100%);
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.gicu-send:hover {
  transform: scale(1.06);
}

.gicu-send:active {
  transform: scale(0.96);
}

.gicu-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.gicu-send:focus-visible {
  outline: 2px solid var(--gicu-teal);
  outline-offset: 2px;
}

.gicu-send svg {
  width: 16px;
  height: 16px;
}

/* ---------- Scrollbar ---------- */

.gicu-messages::-webkit-scrollbar {
  width: 6px;
}

.gicu-messages::-webkit-scrollbar-thumb {
  background: var(--gicu-line);
  border-radius: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .gicu-typing span,
  .gicu-panel,
  .gicu-launcher,
  .gicu-row {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Nota bawah input ---------- */

.gicu-note {
  background: var(--gicu-card);
  padding: 0 16px 10px;
  margin-top: -2px;
  font-size: 10px;
  line-height: 1.35;
  text-align: center;
  color: var(--gicu-ink-muted);
  flex-shrink: 0;
}

/* ---------- Cadangan soalan (chip) ---------- */

.gicu-suggestions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 2px 0 6px 54px;
}

.gicu-chip {
  background: var(--gicu-card);
  border: 1.5px solid var(--gicu-emerald);
  color: var(--gicu-emerald);
  font-family: 'Inter', sans-serif;
  font-size: 12.5px;
  line-height: 1.35;
  text-align: left;
  padding: 7px 14px;
  border-radius: 100px;
  cursor: pointer;
  max-width: 100%;
  transition: background 0.15s ease, color 0.15s ease;
}

.gicu-chip:hover,
.gicu-chip:focus-visible {
  background: var(--gicu-emerald);
  color: #fff;
  outline: none;
}