/* =====================================================
   Maka AI Widget — Premium UAE Style v2.0
   Mobile-first · RTL · Conversion-focused
   ===================================================== */

:root {
  --maka-primary: #f7941d;
  --maka-primary-dk: #e07d0a;
  --maka-secondary: #1a2332;
  --maka-wa-green: #25d366;
  --maka-wa-dark: #128c7e;
  --maka-danger: #e74c3c;
  --maka-white: #ffffff;
  --maka-bg: #f8fafc;
  --maka-border: #e5e7eb;
  --maka-text: #1a2332;
  --maka-text-light: #64748b;
  --maka-radius: 16px;
  --maka-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  --maka-font: "Tajawal", "Cairo", system-ui, -apple-system, sans-serif;
}

/* ── Root container ── */
.maka-ai-root {
  position: fixed;
  z-index: 999999;
  font-family: var(--maka-font);
  direction: rtl;
}
.maka-pos-bottom-left {
  bottom: 120px;
  right: 20px;
}
.maka-pos-bottom-right {
  bottom: 90px;
  right: 20px;
}

/* ── Toggle bubble ── */
.maka-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(
    135deg,
    var(--maka-primary),
    var(--maka-primary-dk)
  );
  color: var(--maka-white);
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(247, 148, 29, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease;
  position: relative;
  padding: 0;
}
.maka-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 30px rgba(247, 148, 29, 0.65);
}
.maka-toggle:active {
  transform: scale(0.94);
}
.maka-toggle svg {
  width: 26px;
  height: 26px;
}
.maka-toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* pulse animation */
.maka-toggle::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: rgba(247, 148, 29, 0.25);
  animation: maka-pulse-ring 2s infinite;
}
@keyframes maka-pulse-ring {
  0% {
    transform: scale(0.9);
    opacity: 0.7;
  }
  70% {
    transform: scale(1.2);
    opacity: 0;
  }
  100% {
    transform: scale(0.9);
    opacity: 0;
  }
}

/* unread badge */
.maka-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--maka-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  animation: maka-badge-bounce 0.4s ease;
}
@keyframes maka-badge-bounce {
  0% {
    transform: scale(0);
  }
  70% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* ── Panel ── */
.maka-panel {
  position: absolute;
  bottom: 80px;
  width: 360px;
  max-height: 580px;
  background: var(--maka-white);
  border-radius: var(--maka-radius);
  box-shadow: var(--maka-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: maka-slide-up 0.3s ease;
  border: 1px solid var(--maka-border);
}
.maka-pos-bottom-left .maka-panel {
  right: 100px;
}
.maka-pos-bottom-right .maka-panel {
  right: 0;
}
@keyframes maka-slide-up {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Header ── */
.maka-header {
  background: linear-gradient(135deg, var(--maka-secondary) 0%, #1e3a5f 100%);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.maka-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.maka-header-info {
  flex: 1;
  min-width: 0;
}
.maka-header-name {
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}
.maka-header-status {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.maka-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2ecc71;
  animation: maka-blink 1.5s infinite;
}
@keyframes maka-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}
.maka-close {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}
.maka-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ── Messages ── */
.maka-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  background: var(--maka-bg);
}
.maka-messages::-webkit-scrollbar {
  width: 4px;
}
.maka-messages::-webkit-scrollbar-track {
  background: transparent;
}
.maka-messages::-webkit-scrollbar-thumb {
  background: var(--maka-border);
  border-radius: 4px;
}

/* ── Message bubbles ── */
.maka-msg {
  max-width: 88%;
  display: flex;
  flex-direction: column;
  animation: maka-msg-in 0.25s ease;
}
@keyframes maka-msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.maka-msg-bot {
  align-self: flex-end;
}
.maka-msg-user {
  align-self: flex-start;
}

.maka-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
}
.maka-msg-bot .maka-bubble {
  background: var(--maka-white);
  color: var(--maka-text);
  border: 1px solid var(--maka-border);
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.maka-msg-user .maka-bubble {
  background: linear-gradient(
    135deg,
    var(--maka-primary),
    var(--maka-primary-dk)
  );
  color: #fff;
  border-bottom-left-radius: 4px;
}

.maka-msg-time {
  font-size: 10px;
  color: var(--maka-text-light);
  margin-top: 3px;
  padding: 0 4px;
}
.maka-msg-bot .maka-msg-time {
  text-align: right;
}
.maka-msg-user .maka-msg-time {
  text-align: left;
}

/* ── Typing indicator ── */
.maka-typing .maka-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}
.maka-dot-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--maka-text-light);
  animation: maka-dot-pulse 1.4s infinite;
}
.maka-dot-pulse:nth-child(2) {
  animation-delay: 0.2s;
}
.maka-dot-pulse:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes maka-dot-pulse {
  0%,
  60%,
  100% {
    transform: scale(1);
    opacity: 0.4;
  }
  30% {
    transform: scale(1.4);
    opacity: 1;
  }
}

/* ── CTA buttons inside messages ── */
.maka-cta-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.maka-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--maka-font);
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}
.maka-cta-btn:hover {
  transform: translateY(-2px);
}
.maka-cta-whatsapp {
  background: var(--maka-wa-green);
  color: #fff;
  box-shadow: 0 3px 12px rgba(37, 211, 102, 0.4);
}
.maka-cta-whatsapp:hover {
  background: var(--maka-wa-dark);
}
.maka-cta-call {
  background: var(--maka-primary);
  color: #fff;
  box-shadow: 0 3px 12px rgba(247, 148, 29, 0.4);
}
.maka-cta-quote {
  background: transparent;
  color: var(--maka-primary);
  border: 2px solid var(--maka-primary);
}
.maka-cta-emergency {
  background: var(--maka-danger);
  color: #fff;
  animation: maka-pulse-ring 1.5s infinite;
}

/* ── Suggestion chips ── */
.maka-chips {
  padding: 8px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 1px solid var(--maka-border);
  background: var(--maka-white);
}
.maka-chip {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--maka-primary);
  background: #fff8f0;
  color: var(--maka-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--maka-font);
  transition: all 0.2s;
  white-space: nowrap;
}
.maka-chip:hover {
  background: var(--maka-primary);
  color: #fff;
}

/* ── Lead form ── */
.maka-lead-form {
  padding: 14px 16px;
  border-top: 1px solid var(--maka-border);
  background: #fffbf5;
}
.maka-lead-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--maka-text);
  margin-bottom: 10px;
}
.maka-lead-form input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--maka-border);
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--maka-font);
  margin-bottom: 8px;
  direction: rtl;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.maka-lead-form input:focus {
  border-color: var(--maka-primary);
}
.maka-lead-btn {
  width: 100%;
  padding: 10px;
  background: var(--maka-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--maka-font);
  cursor: pointer;
  margin-bottom: 6px;
  transition: background 0.2s;
}
.maka-lead-btn:hover {
  background: var(--maka-primary-dk);
}
.maka-lead-skip {
  background: none;
  border: none;
  color: var(--maka-text-light);
  font-size: 12px;
  cursor: pointer;
  font-family: var(--maka-font);
}

/* ── Input area ── */
.maka-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--maka-border);
  background: var(--maka-white);
  flex-shrink: 0;
}
.maka-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--maka-border);
  border-radius: 22px;
  font-size: 14px;
  font-family: var(--maka-font);
  direction: rtl;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}
.maka-input:focus {
  border-color: var(--maka-primary);
}
.maka-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--maka-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    background 0.2s,
    transform 0.15s;
}
.maka-send:hover {
  background: var(--maka-primary-dk);
}
.maka-send:active {
  transform: scale(0.9);
}
.maka-send svg {
  width: 17px;
  height: 17px;
}
.maka-wa-quick {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--maka-wa-green);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
.maka-wa-quick:hover {
  background: var(--maka-wa-dark);
}

/* ── Branding footer ── */
.maka-footer-branding {
  text-align: center;
  font-size: 10px;
  color: #aab;
  padding: 4px 0 6px;
  background: var(--maka-white);
}

/* ── Mobile ── */
@media (max-width: 480px) {
  .maka-pos-bottom-left,
  .maka-pos-bottom-right {
    bottom: 80px;
    left: 12px;
    right: 12px;
  }
  .maka-panel {
    width: calc(100vw - 24px);
    max-height: 70vh;
    bottom: 76px;
    left: 0 !important;
    right: 0 !important;
  }
  .maka-toggle {
    width: 54px;
    height: 54px;
  }
  .maka-pos-bottom-left .maka-toggle {
    position: absolute;
    right: 0;
    bottom: 30px;
  }
  .maka-pos-bottom-right .maka-toggle {
    position: absolute;
    right: 0;
  }
}
