#maika {
  --maika-bg: rgba(8, 15, 31, .98);
  --maika-panel: rgba(15, 27, 51, .96);
  --maika-line: rgba(148, 163, 184, .20);
  --maika-text: #f8fbff;
  --maika-muted: #a9b8d2;
  --maika-accent: #22d3ee;
  --maika-accent-2: #3b82f6;

  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100000;
  font-family: "DM Sans", system-ui, sans-serif;
}

#maika *,
#maika *::before,
#maika *::after {
  box-sizing: border-box;
}


/* ═══════════════════════════════════════
   TOMBOL MAIKA — HANYA GAMBAR/GIF
   ═══════════════════════════════════════ */

.maika-toggle {
  display: block;
  width: 76px;
  height: 76px;
  padding: 0;
  margin: 0;

  border: none;
  outline: none;
  border-radius: 0;

  background: transparent;
  box-shadow: none;

  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;

  transition: transform .2s ease;
}

.maika-toggle img,
.maika-toggle video {
  display: block;

  width: 76px;
  height: 76px;

  object-fit: contain;

  border: none;
  border-radius: 0;

  background: transparent;
  box-shadow: none;
}

.maika-toggle:hover {
  transform: translateY(-3px) scale(1.05);

  border: none;
  background: transparent;
  box-shadow: none;
}

.maika-toggle:active {
  transform: scale(.96);
}

.maika-toggle:focus {
  outline: none;
}

.maika-toggle:focus-visible {
  outline: 2px solid rgba(34, 211, 238, .7);
  outline-offset: 4px;
}


/* ═══════════════════════════════════════
   PANEL CHAT MAIKA
   ═══════════════════════════════════════ */

.maika-panel {
  position: absolute;
  right: 0;
  bottom: 82px;

  display: flex;
  flex-direction: column;

  width: min(390px, calc(100vw - 32px));
  max-height: min(650px, calc(100vh - 100px));

  overflow: hidden;

  border: 1px solid var(--maika-line);
  border-radius: 22px;

  color: var(--maika-text);

  background:
    linear-gradient(
      rgba(8, 15, 31, .72),
      rgba(8, 15, 31, .90)
    ),
    url('/assets/img/mascot-cloud.webp') center / cover no-repeat;

  box-shadow:
    0 28px 80px rgba(2, 6, 23, .58),
    0 0 38px rgba(34, 211, 238, .11);

  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);

  transform-origin: bottom right;

  animation: maika-pop .22s ease both;
}

.maika-panel[hidden] {
  display: none;
}

@keyframes maika-pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}


/* ═══════════════════════════════════════
   HEADER
   ═══════════════════════════════════════ */

.maika-head {
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 15px 16px;

  border-bottom: 1px solid var(--maika-line);

  background:
    linear-gradient(
      135deg,
      rgba(14, 165, 233, .16),
      rgba(15, 23, 42, .15)
    );
}


/* Avatar GIF di dalam header */

.maika-head-avatar {
  position: relative;

  width: 40px;
  height: 40px;

  padding: 2px;

  overflow: hidden;

  border-radius: 13px;

  background:
    linear-gradient(
      135deg,
      #22d3ee,
      #2563eb
    );

  box-shadow:
    0 0 12px rgba(34, 211, 238, .35),
    0 0 28px rgba(37, 99, 235, .18);
}

.maika-head-avatar img,
.maika-head-avatar video {
  display: block;

  width: 100%;
  height: 100%;

  object-fit: cover;

  border-radius: 10px;
}


/* Judul header */

.maika-head-copy {
  min-width: 0;
  flex: 1;
}

.maika-head-copy strong {
  display: block;
  font-size: 14px;
}

.maika-status {
  display: block;

  margin-top: 2px;

  color: var(--maika-muted);

  font-size: 11px;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* Tombol tutup */

.maika-close,
.maika-clear {
  border: 0;

  color: var(--maika-muted);

  background: transparent;

  cursor: pointer;
}

.maika-close {
  width: 34px;
  height: 34px;

  border-radius: 10px;

  font-size: 19px;
}

.maika-close:hover,
.maika-clear:hover {
  color: var(--maika-text);
  background: rgba(255, 255, 255, .08);
}


/* ═══════════════════════════════════════
   PESAN
   ═══════════════════════════════════════ */

.maika-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;

  min-height: 190px;
  max-height: 390px;

  padding: 16px;

  overflow-y: auto;

  overscroll-behavior: contain;
}

.maika-message {
  max-width: 88%;

  padding: 10px 12px;

  border: 1px solid var(--maika-line);

  border-radius: 14px 14px 14px 4px;

  color: #e8f0ff;

  background: rgba(255, 255, 255, .065);

  font-size: 13px;
  line-height: 1.55;

  overflow-wrap: anywhere;
}

.maika-message.user {
  align-self: flex-end;

  border-color: rgba(34, 211, 238, .26);

  border-radius: 14px 14px 4px 14px;

  background: rgba(14, 165, 233, .16);
}

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

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

.maika-message a {
  color: #8be9ff;
  font-weight: 700;
}

.maika-message ul {
  margin: 7px 0 0 18px;
  padding: 0;
}


/* ═══════════════════════════════════════
   SARAN PERTANYAAN
   ═══════════════════════════════════════ */

.maika-suggestions {
  display: flex;
  gap: 7px;

  padding: 0 16px 12px;

  overflow-x: auto;

  scrollbar-width: thin;
}

.maika-suggestion {
  flex: 0 0 auto;

  padding: 7px 10px;

  border: 1px solid rgba(34, 211, 238, .25);
  border-radius: 999px;

  color: #b9f5ff;

  background: rgba(34, 211, 238, .07);

  cursor: pointer;

  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
}

.maika-suggestion:hover {
  background: rgba(34, 211, 238, .15);
}


/* ═══════════════════════════════════════
   FORM CHAT
   ═══════════════════════════════════════ */

.maika-form {
  display: flex;
  gap: 8px;

  padding: 12px;

  border-top: 1px solid var(--maika-line);

  background: rgba(2, 6, 23, .24);
}

.maika-input {
  min-width: 0;
  flex: 1;

  height: 42px;

  padding: 0 12px;

  border: 1px solid var(--maika-line);
  border-radius: 12px;

  color: var(--maika-text);

  background: rgba(255, 255, 255, .07);

  font-family: inherit;
  font-size: 13px;
}

.maika-input::placeholder {
  color: #8291ab;
}

.maika-input:focus {
  border-color: var(--maika-accent);

  outline: 0;

  box-shadow:
    0 0 0 3px rgba(34, 211, 238, .12);
}

.maika-send {
  flex: 0 0 auto;

  min-width: 64px;

  border: 0;
  border-radius: 12px;

  color: #06111f;

  background:
    linear-gradient(
      135deg,
      #67e8f9,
      #38bdf8
    );

  cursor: pointer;

  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
}


/* ═══════════════════════════════════════
   BERSIHKAN CHAT
   ═══════════════════════════════════════ */

.maika-clear {
  align-self: flex-end;

  margin: 0 14px 9px;

  padding: 3px 6px;

  border-radius: 6px;

  font-family: inherit;
  font-size: 11px;
}

.maika-typing {
  color: var(--maika-muted);

  font-size: 11px;
  font-style: italic;
}


/* ═══════════════════════════════════════
   FOCUS
   ═══════════════════════════════════════ */

.maika-close:focus-visible,
.maika-suggestion:focus-visible,
.maika-send:focus-visible,
.maika-clear:focus-visible {
  outline: 2px solid var(--maika-accent);
  outline-offset: 3px;
}


/* ═══════════════════════════════════════
   MOBILE
   ═══════════════════════════════════════ */

@media (max-width: 640px) {

  #maika {
    right: 14px;
    bottom: 14px;
  }

  .maika-toggle {
    width: 62px;
    height: 62px;
  }

  .maika-toggle img,
  .maika-toggle video {
    width: 62px;
    height: 62px;
  }

  .maika-panel {
    right: -2px;
    bottom: 68px;

    width: min(
      390px,
      calc(100vw - 28px)
    );

    max-height: calc(100vh - 82px);

    border-radius: 18px;
  }

  .maika-messages {
    max-height: min(52vh, 360px);
  }
}


/* ═══════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════ */

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

  .maika-panel,
  .maika-toggle {
    animation: none;
    transition: none;
  }
}
