/* ============================================================
   Mariba chat widget
   ============================================================ */

#mariba-chat {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

/* ── Toggle button ─────────────────────────────────────── */
.mariba-chat-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #F5C500;
  color: #0C0C0C;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(0,0,0,.28);
  transition: transform .2s, box-shadow .2s;
  position: relative;
}
.mariba-chat-btn:hover {
  transform: scale(1.07);
  box-shadow: 0 6px 22px rgba(0,0,0,.34);
}
.mariba-chat-btn svg { width: 26px; height: 26px; }

/* Unread dot */
.mc-dot {
  position: absolute;
  top: 2px; right: 2px;
  width: 12px; height: 12px;
  background: #DC2626;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
}
.mc-dot.show { display: block; }

/* ── Panel ─────────────────────────────────────────────── */
.mariba-chat-panel {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 340px;
  max-height: 560px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 36px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: mc-slide-up .2s ease;
}

@keyframes mc-slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ────────────────────────────────────────────── */
.mariba-chat-header {
  background: #0C0C0C;
  color: #fff;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-shrink: 0;
}
.mch-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #F5C500;
  color: #0C0C0C;
  font-weight: 800;
  font-size: .95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.mch-info { flex: 1; min-width: 0; }
.mch-name { font-weight: 700; font-size: .88rem; white-space: nowrap; }
.mch-sub  { font-size: .7rem; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.mch-online {
  display: inline-block;
  width: 7px; height: 7px;
  background: #22c55e;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.mch-btns {
  display: flex;
  align-items: center;
  gap: .2rem;
  flex-shrink: 0;
}

.mch-icon-btn {
  background: none;
  border: none;
  color: #999;
  font-size: .85rem;
  cursor: pointer;
  padding: .2rem .35rem;
  border-radius: 4px;
  line-height: 1;
  transition: color .15s, background .15s;
  white-space: nowrap;
}
.mch-icon-btn:hover { color: #fff; background: rgba(255,255,255,.12); }
.mch-end-btn { font-size: .7rem; letter-spacing: .03em; }

.mariba-chat-close {
  background: none;
  border: none;
  color: #777;
  font-size: 1rem;
  cursor: pointer;
  padding: .2rem .35rem;
  border-radius: 4px;
  line-height: 1;
  transition: color .15s;
}
.mariba-chat-close:hover { color: #fff; }

/* ── Messages ──────────────────────────────────────────── */
.mariba-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: .85rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.mariba-chat-messages::-webkit-scrollbar { width: 4px; }
.mariba-chat-messages::-webkit-scrollbar-thumb {
  background: #e0e0e0;
  border-radius: 2px;
}

.mc-msg {
  max-width: 88%;
  padding: .6rem .85rem;
  border-radius: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.mc-msg.bot {
  background: #f2f2f2;
  color: #1a1a1a;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.mc-msg.bot a {
  color: #0C0C0C;
  text-decoration: underline;
  word-break: break-all;
}
.mc-msg.user {
  background: #F5C500;
  color: #0C0C0C;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.mc-msg.img-preview {
  padding: 3px;
  background: transparent;
}
.mc-msg.img-preview img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}

/* Typing dots */
.mc-typing {
  align-self: flex-start;
  background: #f2f2f2;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  padding: .65rem 1rem;
  display: flex;
  gap: 4px;
  align-items: center;
}
.mc-typing span {
  display: inline-block;
  width: 6px; height: 6px;
  background: #bbb;
  border-radius: 50%;
  animation: mc-bounce .9s infinite;
}
.mc-typing span:nth-child(2) { animation-delay: .18s; }
.mc-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes mc-bounce {
  0%,60%,100% { transform: translateY(0); }
  30%         { transform: translateY(-5px); }
}

/* ── Input footer ──────────────────────────────────────── */
.mariba-chat-footer {
  border-top: 1px solid #efefef;
  padding: .5rem .65rem;
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-shrink: 0;
  background: #fff;
}

.mc-attach-btn {
  background: none;
  border: none;
  font-size: 1.15rem;
  cursor: pointer;
  color: #999;
  padding: .25rem;
  flex-shrink: 0;
  transition: color .15s;
  line-height: 1;
}
.mc-attach-btn:hover { color: #0C0C0C; }
.mc-attach-btn:disabled { opacity: .35; cursor: default; }

.mariba-chat-footer input[type=text] {
  flex: 1;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  padding: .5rem .9rem;
  font-size: 16px; /* prevent iOS zoom */
  outline: none;
  background: #f8f8f8;
  color: #0C0C0C;
  transition: border-color .15s, background .15s;
  min-width: 0;
}
.mariba-chat-footer input[type=text]:focus {
  border-color: #F5C500;
  background: #fff;
}
.mariba-chat-footer input[type=text]:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.mc-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #F5C500;
  color: #0C0C0C;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity .15s, transform .1s;
}
.mc-send-btn:hover  { opacity: .85; transform: scale(1.05); }
.mc-send-btn:disabled { opacity: .35; cursor: default; transform: none; }
.mc-send-btn svg { width: 15px; height: 15px; }

/* ── Ended banner ──────────────────────────────────────── */
.mc-ended-bar {
  padding: .55rem .85rem;
  background: #f8f8f8;
  border-top: 1px solid #efefef;
  font-size: .75rem;
  color: #666;
  text-align: center;
  flex-shrink: 0;
}
.mc-ended-bar a { color: #0C0C0C; font-weight: 600; }
.mc-newchat-link {
  background: none;
  border: none;
  cursor: pointer;
  font-size: inherit;
  color: #0C0C0C;
  font-weight: 600;
  padding: 0;
  text-decoration: underline;
}

/* ── Mobile ────────────────────────────────────────────── */
@media (max-width: 420px) {
  .mariba-chat-panel {
    width: calc(100vw - 2rem);
    right: -1rem;
    max-height: 70vh;
  }
  #mariba-chat {
    bottom: 1rem;
    right: 1rem;
  }
}
