/* MEEM Ai — floating widget. Tema: EMAS + HITAM, latar sembang cerah macam WhatsApp. Jangan gaya body/header laman host. */
.meem-fab,
.meem-panel {
  --gold: #c6a15b;
  --gold-hi: #e4c98a;
  --gold-lite: #f3e2b8;
  --gold-deep: #8a6a2f;
  --gold-btn-lo: #b8893a;
  --gold-btn-hi: #d4af67;
  --black: #0c0c0c;
  --black-2: #161616;
  --ink: #111111;
  --wa: #efeae2;
  --wa-bar: #f0f2f5;
  --wa-ink: #111b21;
  --wa-muted: #667781;
  --gold-line: rgba(198, 161, 91, 0.55);
  --gold-line-soft: rgba(198, 161, 91, 0.28);
  font-family: Figtree, "Segoe UI", system-ui, sans-serif;
  box-sizing: border-box;
}
.meem-fab *,
.meem-panel * { box-sizing: border-box; }

/* ── Butang bulat (FAB) — hitam berbingkai emas ──────────────── */
.meem-fab {
  position: fixed;
  right: max(14px, env(safe-area-inset-right, 0px));
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1.5px solid var(--gold-btn-hi);
  cursor: pointer;
  color: var(--gold-lite);
  font-weight: 800;
  font-size: 0.92rem;
  letter-spacing: 0.2px;
  padding: 12px 18px 12px 12px;
  border-radius: 999px;
  background: linear-gradient(160deg, #2a2a2a 0%, var(--black) 42%, #000 100%);
  box-shadow:
    inset 0 1px 0 rgba(243, 226, 184, 0.28),
    0 0 0 1px #000,
    0 14px 26px -12px rgba(0, 0, 0, 0.9),
    0 0 22px rgba(198, 161, 91, 0.42);
  max-width: calc(100% - 28px);
  animation: meemfab-idle 4.2s ease-in-out infinite, meemfab-glow 3.1s ease-in-out infinite;
}
.meem-fab-label { text-shadow: 0 1px 0 rgba(0, 0, 0, 0.65); }

/* Sapuan kilau emas merentas butang */
.meem-fab-shine {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
}
.meem-fab-shine::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -70%;
  width: 44%;
  height: 200%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(228, 201, 138, 0.2) 35%,
    rgba(255, 248, 220, 0.95) 50%,
    rgba(228, 201, 138, 0.2) 65%,
    transparent
  );
  transform: rotate(18deg);
  animation: meem-shine 2.6s ease-in-out infinite;
}
.meem-fab:hover {
  animation: none;
  transform: translateY(-3px) scale(1.03);
  color: var(--ink);
  background: linear-gradient(135deg, var(--gold-lite) 0%, var(--gold-btn-hi) 48%, var(--gold-btn-lo) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 253, 244, 0.7),
    0 0 0 1px #111,
    0 18px 30px -12px rgba(0, 0, 0, 0.85),
    0 0 28px rgba(212, 175, 103, 0.72);
}
.meem-fab:hover .meem-fab-shine::after { animation-duration: 1.1s; }
.meem-fab:hover .meem-fab-label { text-shadow: none; color: var(--ink); }

/* Gelombang emas mengelilingi butang */
.meem-fab-ring,
.meem-fab-ring-2 {
  position: absolute;
  inset: -5px;
  border-radius: inherit;
  border: 2px solid rgba(212, 175, 103, 0.75);
  pointer-events: none;
  animation: meemfab-ping 2.6s ease-out infinite;
}
.meem-fab-ring-2 { animation-delay: 1.3s; }

/* Titik notifikasi emas */
.meem-fab-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold-btn-hi);
  box-shadow: 0 0 8px rgba(212, 175, 103, 0.95);
  border: 2px solid var(--black);
}

/* Syiling emas atas bulatan hitam */
.meem-fab-ico {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 26%, #2a2a2a, var(--black) 72%);
  display: grid;
  place-items: center;
  flex: none;
  box-shadow: inset 0 0 0 1.5px var(--gold-btn-hi), 0 2px 8px rgba(0, 0, 0, 0.45);
}
.meem-fab-ico svg { width: 20px; height: 20px; display: block; }
.meem-fab-ico svg circle:first-of-type { fill: var(--gold-hi); }
.meem-fab-ico svg circle:nth-of-type(2) { stroke: var(--ink); }
.meem-fab-ico svg path { fill: var(--ink); }
.meem-fab.is-open { display: none; }

/* Tooltip */
.meem-fab::after,
.meem-fab::before {
  position: absolute;
  right: 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.meem-fab::after {
  content: attr(data-tip);
  bottom: calc(100% + 12px);
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--black);
  color: var(--gold-lite);
  border: 1px solid var(--gold-line);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  transform: translateY(4px);
}
.meem-fab::before {
  content: "";
  bottom: calc(100% + 6px);
  width: 8px;
  height: 8px;
  background: var(--black);
  border-right: 1px solid var(--gold-line);
  border-bottom: 1px solid var(--gold-line);
  transform: translateY(4px) rotate(45deg);
}
.meem-fab:hover::after,
.meem-fab:focus-visible::after { opacity: 1; transform: translateY(0); }
.meem-fab:hover::before,
.meem-fab:focus-visible::before { opacity: 1; transform: translateY(0) rotate(45deg); }

@keyframes meemfab-idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@keyframes meemfab-glow {
  0%, 100% {
    box-shadow:
      inset 0 1px 0 rgba(243, 226, 184, 0.22),
      0 0 0 1px #000,
      0 14px 26px -12px rgba(0, 0, 0, 0.9),
      0 0 16px rgba(198, 161, 91, 0.32);
  }
  50% {
    box-shadow:
      inset 0 1px 0 rgba(243, 226, 184, 0.45),
      0 0 0 1px var(--gold-deep),
      0 14px 26px -12px rgba(0, 0, 0, 0.9),
      0 0 32px rgba(212, 175, 103, 0.7);
  }
}
@keyframes meemfab-ping {
  0% { transform: scale(1); opacity: 0.75; }
  70%, 100% { transform: scale(1.22); opacity: 0; }
}
@keyframes meem-shine {
  0%, 12% { left: -70%; }
  48%, 100% { left: 150%; }
}
@media (hover: none) {
  .meem-fab::after,
  .meem-fab::before { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .meem-fab,
  .meem-fab-ring,
  .meem-fab-ring-2,
  .meem-fab-shine::after { animation: none; }
}

/* ── Panel — bingkai hitam + emas, isi cerah ─────────────────── */
.meem-panel {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 10000;
  width: min(390px, calc(100% - 24px));
  height: min(580px, calc(100dvh - 24px));
  display: none;
  flex-direction: column;
  background: var(--wa);
  border: 1px solid #111;
  border-radius: 24px;
  box-shadow:
    0 0 0 1px rgba(198, 161, 91, 0.72),
    0 28px 60px -28px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  color: var(--wa-ink);
}
.meem-panel.is-open { display: flex; }

.meem-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(118deg, #000 0%, #1a1a1a 52%, #050505 100%);
  color: var(--gold-lite);
  border-bottom: 1px solid var(--gold-line);
}
.meem-head::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-btn-hi), transparent);
}
.meem-head-ico {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: radial-gradient(circle at 32% 26%, #2a2a2a, #000 72%);
  display: grid;
  place-items: center;
  flex: none;
  box-shadow: inset 0 0 0 1.5px var(--gold-btn-hi);
}
.meem-head-ico svg { width: 22px; height: 22px; display: block; }
.meem-head-ico svg circle:first-of-type { fill: var(--gold-hi); }
.meem-head-ico svg circle:nth-of-type(2) { stroke: var(--ink); }
.meem-head-ico svg path { fill: var(--ink); }
.meem-head-txt { flex: 1; min-width: 0; }
.meem-head h3 {
  width: fit-content;
  margin: 0;
  text-align: left;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  background: linear-gradient(100deg, #f6e7c1 0%, #d4af67 48%, #a6843a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.meem-head p {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: #cbb693;
}
.meem-x {
  border: 1px solid var(--gold-line);
  background: transparent;
  color: var(--gold-lite);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}
.meem-x:hover { background: rgba(212, 175, 103, 0.18); }

/* Log sembang — beige cerah macam WhatsApp */
.meem-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 8px;
  background-color: var(--wa);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='88' fill='none' stroke='%238a6a2f' stroke-opacity='0.16' stroke-width='1.2'%3E%3Ccircle cx='14' cy='16' r='3.2'/%3E%3Cpath d='M50 20l3.2 3.2-3.2 3.2-3.2-3.2z'/%3E%3Ccircle cx='68' cy='58' r='2.2'/%3E%3Cpath d='M28 62h8M32 58v8'/%3E%3C/svg%3E");
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-btn-hi) transparent;
}
.meem-log::-webkit-scrollbar { width: 8px; }
.meem-log::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--gold-btn-hi), var(--gold-deep));
  border-radius: 8px;
  border: 2px solid var(--wa);
}
.meem-msg {
  max-width: 90%;
  padding: 10px 12px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.meem-msg a {
  color: var(--gold-deep);
  font-weight: 700;
  overflow-wrap: anywhere;
  text-decoration-color: rgba(138, 106, 47, 0.45);
}
.meem-bot {
  align-self: flex-start;
  background: #fff;
  border: 0;
  border-left: 3px solid var(--gold);
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  color: var(--wa-ink);
}
.meem-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #f8efd4 0%, #e7cd86 55%, #d4af67 100%);
  color: var(--ink);
  font-weight: 600;
  border: 1px solid rgba(17, 17, 17, 0.12);
  border-bottom-right-radius: 6px;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}
.meem-user a { color: #3a2c0e; }
.meem-msg img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin-top: 8px;
  border: 1px solid var(--gold-line-soft);
}
.meem-dots { display: inline-flex; gap: 4px; padding: 2px 0 0; }
.meem-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold-deep);
  animation: meemdot 1s infinite ease-in-out;
}
.meem-dots i:nth-child(2) { animation-delay: 0.15s; }
.meem-dots i:nth-child(3) { animation-delay: 0.3s; }
.meem-caret {
  display: inline-block;
  width: 2px;
  height: 0.95em;
  margin-left: 1px;
  background: var(--gold-deep);
  vertical-align: -2px;
  animation: meemcaret 0.7s step-end infinite;
}
@keyframes meemcaret { 50% { opacity: 0; } }
@keyframes meemdot {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* Chip cadangan — putih atas bar cerah */
.meem-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 8px 12px;
  background: var(--wa-bar);
  border-top: 1px solid #e6dfd4;
  overflow-x: auto;
  scrollbar-width: thin;
}
.meem-chip {
  flex: 0 0 auto;
  white-space: nowrap;
  border: 1px solid var(--gold);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 12px;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.meem-chip:hover {
  background: var(--black);
  border-color: var(--black);
  color: var(--gold-lite);
}
.meem-chip-wa {
  background: linear-gradient(135deg, var(--gold-lite) 0%, var(--gold-btn-hi) 50%, var(--gold-btn-lo) 100%);
  color: var(--ink);
  border-color: var(--gold-deep);
  text-decoration: none;
}
.meem-chip-wa:hover { filter: brightness(1.05); color: var(--ink); background: linear-gradient(135deg, var(--gold-lite) 0%, var(--gold-btn-hi) 50%, var(--gold-btn-lo) 100%); }

/* Borang input — bar cerah, medan putih */
.meem-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 6px;
  background: var(--wa-bar);
}
.meem-form input {
  flex: 1 1 auto;
  min-width: 0;
  border: 1.5px solid #e4ddd4;
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-size: 0.86rem;
  color: var(--wa-ink);
  background: #fff;
}
.meem-form input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(198, 161, 91, 0.22);
}
.meem-form input::placeholder { color: var(--wa-muted); }
.meem-send {
  flex: 0 0 auto;
  border: 1px solid var(--gold-btn-hi);
  border-radius: 999px;
  height: 42px;
  padding: 0 16px;
  background: var(--black);
  color: var(--gold-lite);
  font: inherit;
  font-weight: 800;
  font-size: 0.84rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 0 rgba(243, 226, 184, 0.2);
}
.meem-send:hover {
  background: linear-gradient(135deg, var(--gold-lite) 0%, var(--gold-btn-hi) 50%, var(--gold-btn-lo) 100%);
  color: var(--ink);
}
.meem-send:disabled { filter: grayscale(0.35) brightness(0.85); cursor: not-allowed; }
.meem-send-ico { display: none; }

.meem-disclaimer {
  margin: 0;
  padding: 0 14px 10px;
  background: var(--wa-bar);
  color: var(--wa-muted);
  font-size: 11px;
  line-height: 1.35;
}

/* ── Mudah alih ───────────────────────────────────────────────── */
@media (max-width: 820px) {
  .meem-fab {
    right: 12px;
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    padding: 8px;
    gap: 0;
  }
  .meem-fab-label { display: none; }
  .meem-fab-ico { width: 46px; height: 46px; }
  .meem-fab-ico svg { width: 26px; height: 26px; }
  .meem-fab-ring,
  .meem-fab-ring-2 { inset: -3px; animation: none; opacity: 0.45; }
  .meem-panel {
    inset: 0;
    width: 100%;
    max-width: 100%;
    height: 100svh;
    max-height: 100svh;
    border-radius: 0;
    border: 0;
    border-top: 2px solid var(--gold-btn-hi);
    box-shadow: none;
  }
  html.meem-lock,
  html.meem-lock body { overflow: hidden; }
  .meem-form { padding: 8px 12px 4px; }
  .meem-send {
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
  }
  .meem-send-txt { display: none; }
  .meem-send-ico { display: block; }
  .meem-disclaimer { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
}
