/* Reset & Full screen */
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  /* Penting: Elak scroll global */
  font-family: "Segoe UI", system-ui, sans-serif;
  /* Latar belakang: Kelabu muda seperti dalam imej Gemini */
  background: #f0f4f9;
}

/* Kontainer Utama (Untuk Menengahkan Semua Kandungan) */
#main-centered-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* Tengah secara menegak (vertical balance) */
  align-items: center;
  /* Tengah secara mendatar */
  padding: 20px;
  box-sizing: border-box;
  transition: all 0.3s ease-in-out;
  /* Untuk transisi UI yang lancar */
}

/* Header Branding */
#header-branding {
  display: flex;
  align-items: center;
  margin-bottom: 24px;
  /* Ruang di bawah logo/nama */
  max-width: 700px;
  width: 100%;
}

#header-branding .logo {
  font-size: 32px;
  margin-right: 15px;
  color: #0078D4;
  /* Warna ikon korporat */
}

#header-branding .name {
  font-size: 36px;
  font-weight: 500;
  color: #202124;
}

/* Kontainer WebChat (Hanya untuk input field) */
#webchat {
  width: 100%;
  /* Lebar input box - sama dengan header */
  max-width: 700px;
  height: 72px;
  /* Increased height to prevent layout shift */
  min-height: 72px;
  /* Ketinggian untuk kotak input sahaja */
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  /* Shadow yang jelas */
  border-radius: 28px;
  /* Lebih bulat ala-Gemini */
  background: white;
  transition: all 0.3s ease-in-out;
  /* Untuk transisi UI yang lancar */
}

/* === WebChat Overrides untuk Gaya Landing Page === */

/* 1. Sembunyikan Header dan Ruang Perbualan */
.webchat__stacked-layout {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.webchat__stacked-layout__header,
.webchat__stacked-layout__main {
  /* Sembunyikan bahagian conversation history */
  display: none !important;
}

/* 2. Style Input Box (Send Box) */
.webchat__send-box {
  position: static;
  /* Buang sticky/float */
  width: 100%;
  padding: 12px 16px;
  box-shadow: none;
  /* Shadow pada #webchat container */
  border-top: none;
  background: transparent;
  height: 100%;
  box-sizing: border-box;
}

/* Input field itu sendiri */
.webchat__send-box__main>input[type="text"] {
  border: none !important;
  font-size: 16px;
  background: transparent !important;
  padding: 0;
}

/* Sembunyikan + Tools button dan dropdown lain (seperti dalam imej) */
.webchat__send-box__main>.webchat__send-box__main__left-filler,
.webchat__send-box__main>.webchat__send-box__main__right-filler {
  display: none !important;
}

/* Sembunyikan "Connecting..." status dalam input box */
.webchat__send-box .webchat__connectivitystatus,
.webchat__send-box [role="status"]:not(#custom-typing-indicator),
.webchat__send-box [class*="connectivityStatus"],
.webchat__send-box [class*="Connectivity"] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  position: absolute !important;
  left: -9999px !important;
}

/* SPECIFIC: Sembunyikan connectivity status sahaja, BUKAN typing indicator */
.webchat__connectivitystatus,
[class*="connectivityStatus"],
[class*="connectivity-status"],
[class*="ConnectivityStatus"] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  height: 0 !important;
  width: 0 !important;
  overflow: hidden !important;
  position: absolute !important;
  left: -9999px !important;
  pointer-events: none !important;
}

/* PENTING: Override hanya untuk show state - base state managed below */
#custom-typing-indicator.show {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}


/* === PERBAIKAN: Kecilkan bayangan butang ikon === */
.webchat__icon-button__shade {
  /* Tetapkan saiz tetap untuk bulatan bayangan */
  width: 40px !important;
  height: 40px !important;
  /* Bulatkan bayangan */
  border-radius: 50% !important;
  /* Pastikan ia berada di tengah ikon */
  transform: translate(-50%, -50%) !important;
  /* Tambahkan transition untuk nampak lebih lancar */
  transition: all 0.2s ease-in-out;
}

/* Pastikan padding ikon dikurangkan */
.webchat__send-box__main__right-filler .webchat__icon-button {
  padding: 5px !important;
}

/* Untuk ikon 'Hantar' di paling kanan */
.webchat__send-box__main__right-filler button {
  margin-right: -4px !important;
  /* Tarik butang ke kanan sedikit */
}


/* Prompt Buttons di bawah input box */
#prompt-buttons {
  margin-top: 20px;
  max-width: 700px;
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  transition: all 0.3s ease-in-out;
  /* Untuk transisi UI yang lancar */
}

.prompt-button {
  background: #ffffff;
  border: 1px solid #dadce0;
  color: #5f6368;
  padding: 10px 16px;
  border-radius: 24px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s, box-shadow 0.2s;
}

.prompt-button:hover {
  background: #f1f3f4;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Responsive untuk skrin kecil (mod Conversation akan ambil alih) */
@media (max-width: 750px) {
  #main-centered-container {
    justify-content: center;
    padding-top: 40px;
    padding-bottom: 40px;
  }

  #webchat,
  #header-branding,
  #prompt-buttons {
    max-width: 100%;
    padding: 0 10px;
  }

  #webchat {
    border-radius: 20px;
  }

  #header-branding {
    padding-left: 10px;
  }

  /* RESPONSIVE FIX: Assalamualaikum Text */
  #header-branding .name {
    font-size: 24px;
    /* Smaller font for mobile */
  }

  #header-branding .logo img {
    width: 36px;
    height: 36px;
  }
}


.webchat__icon-button__shade {
  display: none;
}


/* Buang padding/margin default right-filler */
.webchat__send-box__main>.webchat__send-box__main__right-filler {
  /* ... */
  padding: 0 !important;
  margin: 0 !important;
}

/* KEKALKAN SAIZ DAN LOKASI BUTANG IKON KECIL */
.webchat__icon-button {
  /* ... */
  /* Pastikan butang rapat ke tepi kanan kotak input */
  margin-right: 0 !important;
  margin-left: 0 !important;
  padding: 0 !important;
}

.webchat__stacked-layout__message {
  max-width: 1000px;
}

/* === MAIN CONVERSATION AREA === */
.webchat__stacked-layout__main {
  flex-grow: 1;
  overflow-y: auto;
  /* Padding bawah sederhana supaya nampak kemas tapi tak jauh sangat */
  padding: 15px 15px 60px 15px;
  display: block !important;
  /* Paparkan kembali Conversation Area */
}

/* ============================================ */
/* TYPING INDICATOR - Animasi Dots yang Cantik */
/* ============================================ */

/* Styling untuk typing indicator bubble */
.webchat__typing-indicator,
.webchat__stacked-layout__main [class*="typing"],
.webchat__basic-transcript [class*="typing"] {
  display: flex !important;
  align-items: center;
  padding: 12px 16px;
  background: #f0f0f0;
  border-radius: 18px;
  margin: 8px 0;
  width: fit-content;
  max-width: 80px;
}

/* Container untuk animated dots */
.webchat__typing-indicator::before,
[class*="typing"]::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0078D4;
  margin-right: 6px;
  animation: typingDot1 1.4s infinite;
}

.webchat__typing-indicator::after,
[class*="typing"]::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0078D4;
  margin-left: 6px;
  animation: typingDot3 1.4s infinite;
}

/* Dot tengah - menggunakan pseudo element lain */
.webchat__typing-indicator,
[class*="typing"] {
  position: relative;
}

.webchat__typing-indicator::before {
  animation: typingDot1 1.4s infinite;
}

/* Keyframes untuk animasi dots */
@keyframes typingDot1 {

  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: scale(0.8);
  }

  30% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes typingDot2 {

  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: scale(0.8);
  }

  40% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes typingDot3 {

  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: scale(0.8);
  }

  50% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Styling tambahan untuk memastikan typing indicator kelihatan */
.webchat__basic-transcript__activity:has([class*="typing"]) {
  margin-bottom: 10px;
}

/* Pastikan typing indicator tidak disembunyikan */
.webchat__stacked-layout [class*="typing"],
.webchat__basic-transcript [class*="typing"] {
  visibility: visible !important;
  opacity: 1 !important;
  display: flex !important;
}

/* Custom Typing Indicator - Simple & Clean Design */
/* Custom Typing Indicator - Fixed Position */
/* === MODERN TYPING INDICATOR (GLASSMORPHISM) === */
#custom-typing-indicator {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 10px 16px;

  /* Modern Glass Look */
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  /* Soft shadow */
  border: 1px solid rgba(0, 0, 0, 0.05);
  /* Subtle border */
  border-radius: 50px;
  /* FIXED POSITION: Sentiasa di bawah kiri, atas input box */
  position: fixed;
  left: 20px;
  bottom: 70px;
  /* Turunkan lagi supaya rapat sikit (tadi 80px) */
  z-index: 99999;
  width: fit-content;
  transform-origin: bottom left;
}

#custom-typing-indicator.show {
  display: flex !important;
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  /* Bouncy pop-in */
}

/* Modern Clean Dots */
.modern-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0078D4, #005a9e);
  /* Gradient Blue */
  animation: wave 1.3s ease-in-out infinite;
}

.modern-dot:nth-child(1) {
  animation-delay: 0s;
}

.modern-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.modern-dot:nth-child(3) {
  animation-delay: 0.3s;
}

/* Smooth Wave Animation */
@keyframes wave {

  0%,
  100% {
    transform: translateY(0);
    opacity: 0.6;
  }

  50% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* Entrance Animation */
@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* TRANSITION ANIMATIONS */
.fade-out-up {
  opacity: 0;
  transform: translateY(-20px);
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

#header-branding,
#prompt-buttons {
  transition: opacity 0.4s ease, transform 0.4s ease;
}

#main-centered-container {
  transition: padding 0.5s ease, justify-content 0.5s ease;
}

/* FROM JS INJECTION - MOVED TO CSS */
/* ULTRA SPECIFIC: Force send button container to far right */
.webchat__send-box__main {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
}

.webchat__send-box__main>input[type="text"] {
  flex: 1 !important;
  padding-right: 50px !important;
}

/* ONLY hide connecting spinner in send box - NOT typing indicator */
.webchat__send-box__main>.webchat__connectivitystatus,
.webchat__send-box__main>[role="status"],
.webchat__send-box [class*="connectivityStatus"],
.webchat__send-box [class*="Connectivity"] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  position: absolute !important;
  left: -9999px !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

/* ALLOW typing indicator to show in conversation area */
.webchat__stacked-layout__main [class*="typing"],
.webchat__basic-transcript [class*="typing"],
.webchat__stacked-layout [class*="typing"] {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Position send button container at far right */
.webchat__send-box__main>.webchat__send-box__main__right-filler {
  position: absolute !important;
  right: 8px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  width: auto !important;
  max-width: 40px !important;
  z-index: 100 !important;
}

/* CRITICAL: Override button width */
.webchat__send-box__main .webchat__icon-button,
.webchat__send-box__main button.webchat__icon-button,
.webchat__send-box__main .webchat__send-box__main__right-filler button {
  width: 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  height: 40px !important;
  padding: 8px !important;
  margin: 0 !important;
}