/* ═══════════════════════════════════════════════════
   MARI CONCIERGE — Widget Styles
   Brand: Redwood #A05B4E · Sandstone #E3C09F · Earthy
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600&family=DM+Sans:wght@300;400;500&display=swap');

:root {
  --mari-redwood:      #A05B4E;
  --mari-redwood-deep: #7d4439;
  --mari-sand:         #E3C09F;
  --mari-sand-light:   #f5ede0;
  --mari-cream:        #faf7f3;
  --mari-deep:         #2a1c16;
  --mari-mid:          #6b4c40;
  --mari-mist:         #b8997e;
  --mari-sage:         #7a8c6e;
  --mari-white:        #fefcf9;
  --mari-shadow:       rgba(42, 28, 22, 0.14);
  --mari-radius:       22px;
  --mari-font-body:    'DM Sans', sans-serif;
  --mari-font-display: 'Cormorant Garamond', Georgia, serif;
}

#mari-root * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--mari-font-body);
}

/* ── TRIGGER BUBBLE ──────────────────────────────── */
.mari-trigger {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--mari-redwood), var(--mari-redwood-deep));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 32px rgba(160, 91, 78, 0.45), 0 2px 8px rgba(42, 28, 22, 0.15);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s;
  z-index: 99999;
  overflow: visible;
}
.mari-trigger:hover {
  transform: scale(1.1);
  box-shadow: 0 14px 40px rgba(160, 91, 78, 0.55);
}
.mari-trigger.open svg {
  transform: rotate(180deg);
}
.mari-trigger svg {
  transition: transform 0.3s ease;
  position: relative;
  z-index: 2;
}

/* Pulse animation */
.mari-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--mari-redwood);
  opacity: 0;
  animation: mari-pulse 3s ease-out infinite;
}
@keyframes mari-pulse {
  0%   { transform: scale(0.9); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* ── CHAT WINDOW ─────────────────────────────────── */
.mari-window {
  position: fixed;
  bottom: 106px;
  right: 28px;
  width: 375px;
  max-height: 580px;
  background: var(--mari-white);
  border-radius: var(--mari-radius);
  box-shadow:
    0 30px 80px rgba(42, 28, 22, 0.2),
    0 8px 24px rgba(42, 28, 22, 0.1),
    0 0 0 1px rgba(227, 192, 159, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99998;
  transform: scale(0.88) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transform-origin: bottom right;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.28s ease;
}
.mari-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── HEADER ──────────────────────────────────────── */
.mari-header {
  background: linear-gradient(135deg, var(--mari-deep) 0%, #3d2820 60%, #52352a 100%);
  padding: 20px 18px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

/* Decorative wave layer */
.mari-header-wave {
  position: absolute;
  bottom: -20px;
  left: -10%;
  width: 120%;
  height: 50px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 80'%3E%3Cpath d='M0,40 C150,70 350,10 600,40 C850,70 1050,10 1200,40 L1200,80 L0,80 Z' fill='rgba(160,91,78,0.15)'/%3E%3C/svg%3E") center/cover;
  pointer-events: none;
}

.mari-header::after {
  content: '';
  position: absolute;
  top: -30px;
  right: -20px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(160,91,78,0.25) 0%, transparent 70%);
  pointer-events: none;
}

.mari-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mari-redwood), #c48060);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  box-shadow: 0 3px 12px rgba(160,91,78,0.5), 0 0 0 2px rgba(227,192,159,0.25);
}

.mari-header-text {
  flex: 1;
  position: relative;
  z-index: 1;
}
.mari-header-name {
  font-family: var(--mari-font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--mari-sand-light);
  letter-spacing: 0.02em;
}
.mari-header-status {
  font-size: 11px;
  font-weight: 300;
  color: var(--mari-mist);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  letter-spacing: 0.01em;
}
.mari-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.mari-status-dot.open   { background: #8bc34a; animation: mari-blink 2.5s ease-in-out infinite; }
.mari-status-dot.closed { background: var(--mari-mist); }
@keyframes mari-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.mari-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}
.mari-close-btn:hover {
  background: rgba(255,255,255,0.2);
  color: white;
}

/* ── MESSAGES AREA ───────────────────────────────── */
.mari-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.mari-messages::-webkit-scrollbar { width: 3px; }
.mari-messages::-webkit-scrollbar-thumb {
  background: var(--mari-sand);
  border-radius: 3px;
}

/* ── MESSAGE BUBBLES ──────────────────────────────── */
.mari-msg {
  display: flex;
  gap: 9px;
  animation: mari-fadeup 0.32s ease forwards;
}
@keyframes mari-fadeup {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.mari-msg.user { flex-direction: row-reverse; }

.mari-msg-av {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--mari-sand-light);
  border: 1px solid var(--mari-sand);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
  color: var(--mari-redwood);
}
.mari-msg.user .mari-msg-av {
  background: linear-gradient(135deg, var(--mari-redwood), #c48060);
  border-color: transparent;
  color: white;
}

.mari-bubble {
  max-width: 80%;
  padding: 12px 15px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--mari-deep);
  word-break: break-word;
}
.mari-msg.bot .mari-bubble {
  background: var(--mari-cream);
  border: 1px solid rgba(227, 192, 159, 0.5);
  border-bottom-left-radius: 4px;
}
.mari-msg.user .mari-bubble {
  background: linear-gradient(135deg, var(--mari-redwood), var(--mari-redwood-deep));
  color: white;
  border-bottom-right-radius: 4px;
}
.mari-msg.bot .mari-bubble a {
  color: var(--mari-redwood);
  font-weight: 500;
}
.mari-msg.user .mari-bubble a {
  color: rgba(255,255,255,0.85);
}

/* System messages */
.mari-msg.sys {
  justify-content: center;
}
.mari-msg.sys .mari-bubble {
  background: transparent;
  border: 1px solid var(--mari-sand);
  color: var(--mari-mist);
  font-size: 11.5px;
  text-align: center;
  padding: 5px 14px;
  border-radius: 20px;
  max-width: 100%;
}

/* ── TYPING DOTS ──────────────────────────────────── */
.mari-typing {
  display: flex;
  gap: 5px;
  padding: 3px 2px;
  align-items: center;
}
.mari-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mari-redwood);
  opacity: 0.4;
  animation: mari-bounce 1.3s ease-in-out infinite;
}
.mari-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.mari-typing-dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes mari-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-6px); opacity: 1; }
}

/* ── LEAD FORM ───────────────────────────────────── */
.mari-lead-form {
  padding: 16px;
  background: var(--mari-sand-light);
  border-top: 1px solid var(--mari-sand);
  flex-shrink: 0;
}
.mari-lead-title {
  font-family: var(--mari-font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--mari-deep);
  margin-bottom: 12px;
}
.mari-lead-fields {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 12px;
}
.mari-lf-input {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--mari-sand);
  border-radius: 10px;
  font-size: 13px;
  font-family: var(--mari-font-body);
  background: white;
  color: var(--mari-deep);
  outline: none;
  transition: border-color 0.2s;
}
.mari-lf-input:focus { border-color: var(--mari-redwood); }
.mari-lf-input::placeholder { color: var(--mari-mist); }
.mari-lead-actions {
  display: flex;
  gap: 8px;
}
.mari-lf-skip {
  flex: 0 0 auto;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--mari-sand);
  border-radius: 10px;
  font-size: 12px;
  color: var(--mari-mist);
  cursor: pointer;
  font-family: var(--mari-font-body);
  transition: all 0.2s;
}
.mari-lf-skip:hover { border-color: var(--mari-redwood); color: var(--mari-redwood); }
.mari-lf-submit {
  flex: 1;
  padding: 9px 16px;
  background: linear-gradient(135deg, var(--mari-redwood), var(--mari-redwood-deep));
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: white;
  cursor: pointer;
  font-family: var(--mari-font-body);
  transition: opacity 0.2s, transform 0.2s;
}
.mari-lf-submit:hover { opacity: 0.92; transform: translateY(-1px); }

/* ── QUICK CHIPS ─────────────────────────────────── */
.mari-chips {
  padding: 8px 16px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
  border-top: 1px solid rgba(227,192,159,0.3);
}
.mari-chip {
  background: transparent;
  border: 1px solid var(--mari-sand);
  color: var(--mari-mid);
  font-size: 11.5px;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-family: var(--mari-font-body);
  transition: all 0.22s;
  white-space: nowrap;
}
.mari-chip:hover {
  background: var(--mari-cream);
  border-color: var(--mari-redwood);
  color: var(--mari-redwood-deep);
  transform: translateY(-1px);
}

/* ── INPUT BAR ───────────────────────────────────── */
.mari-input-area {
  padding: 12px 14px;
  border-top: 1px solid rgba(227,192,159,0.4);
  display: flex;
  gap: 9px;
  align-items: flex-end;
  flex-shrink: 0;
  background: var(--mari-white);
}
.mari-input-wrap {
  flex: 1;
  background: var(--mari-cream);
  border: 1.5px solid var(--mari-sand);
  border-radius: 14px;
  padding: 10px 14px;
  transition: border-color 0.2s;
}
.mari-input-wrap:focus-within {
  border-color: var(--mari-redwood);
  background: white;
}
.mari-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13.5px;
  color: var(--mari-deep);
  resize: none;
  max-height: 90px;
  line-height: 1.55;
  font-family: var(--mari-font-body);
}
.mari-input::placeholder { color: var(--mari-mist); }

.mari-send {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--mari-redwood), var(--mari-redwood-deep));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(160,91,78,0.4);
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.mari-send:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 5px 18px rgba(160,91,78,0.5);
}
.mari-send:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── FOOTER BRAND ────────────────────────────────── */
.mari-footer-brand {
  text-align: center;
  font-size: 10px;
  color: var(--mari-mist);
  padding: 5px 0 8px;
  letter-spacing: 0.05em;
  flex-shrink: 0;
  font-family: var(--mari-font-display);
  font-style: italic;
}

/* ── POSITION VARIANT: BOTTOM-LEFT ───────────────── */
.mari-pos-left .mari-trigger { right: auto; left: 28px; }
.mari-pos-left .mari-window  { right: auto; left: 28px; transform-origin: bottom left; }

/* ── RESPONSIVE ──────────────────────────────────── */
@media (max-width: 480px) {
  .mari-window {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 92px;
    max-height: 72vh;
    border-radius: 18px;
  }
  .mari-trigger { right: 16px; bottom: 16px; }
  .mari-pos-left .mari-trigger { right: auto; left: 16px; }
  .mari-pos-left .mari-window  { right: auto; left: 8px; }
}
