/* ==========================================================================
   Mas Airaga — chat assistant widget (see chat-widget.js)
   Uses the site's tokens from styles.css (--sage, --accent, --bg, --panel…),
   with fallbacks so the widget still renders if a token is missing.
   Stacking (bottom-right): scroll-to-top 30px, WhatsApp 90px, chat 164px;
   phones: 20px / 70px / 130px, all round buttons (WhatsApp: styles.css).
   html.mas-floats-hidden (set by script.js over the calendar and booking form) hides them.
   ========================================================================== */

.mac-root {
  --mac-sage: var(--sage, #395846);
  --mac-sage-dark: #2b4436;
  --mac-accent: var(--accent, #c68b00);
  --mac-accent-dark: var(--accent-dark, #a87300);
  --mac-bg: var(--bg, #faf8f5);
  --mac-panel: var(--panel, #f1ede8);
  --mac-text: var(--text, #2d3436);
  --mac-muted: var(--muted, #636e72);
  --mac-border: var(--border, rgba(57, 88, 70, 0.15));
  --mac-shadow: var(--shadow, 0 15px 40px rgba(0, 0, 0, 0.08));
  font-family: var(--font-base, "Manrope", system-ui, -apple-system, sans-serif);
  color: var(--mac-text);
  line-height: 1.5;
}

.mac-root *,
.mac-root *::before,
.mac-root *::after {
  box-sizing: border-box;
}

.mac-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.mac-root [hidden] {
  display: none !important;
}

/* ---------- launcher ---------- */
.mac-launcher {
  position: fixed;
  right: 30px;
  bottom: 164px;
  z-index: 998;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 20px 0 16px;
  border: none;
  border-radius: 28px;
  background: var(--mac-sage);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(57, 88, 70, 0.35);
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, visibility 0.2s;
}

.mac-launcher:hover {
  background: var(--mac-sage-dark);
  transform: scale(1.04);
}

.mac-launcher:focus-visible,
.mac-root button:focus-visible,
.mac-root a:focus-visible,
.mac-input:focus-visible {
  outline: 3px solid var(--mac-accent);
  outline-offset: 2px;
}

.mac-launcher svg {
  flex-shrink: 0;
}

.mac-root--open .mac-launcher {
  display: none;
}

html.mas-floats-hidden .mac-launcher,
html.mas-floats-hidden .mac-teaser {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(16px);
}

/* ---------- teaser ---------- */
.mac-teaser {
  position: fixed;
  right: 30px;
  bottom: 232px;
  z-index: 998;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  max-width: 270px;
  padding: 12px 8px 12px 14px;
  background: #fff;
  border: 1px solid var(--mac-border);
  border-radius: 14px;
  box-shadow: var(--mac-shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}

.mac-teaser::after {
  content: "";
  position: absolute;
  right: 34px;
  bottom: -7px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-right: 1px solid var(--mac-border);
  border-bottom: 1px solid var(--mac-border);
  transform: rotate(45deg);
}

.mac-teaser--in {
  opacity: 1;
  transform: none;
}

.mac-teaser__text {
  flex: 1;
  padding: 0;
  border: none;
  background: none;
  color: var(--mac-text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.mac-teaser__close {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--mac-muted);
  cursor: pointer;
}

.mac-teaser__close svg {
  width: 16px;
  height: 16px;
}

.mac-teaser__close:hover {
  background: var(--mac-panel);
}

/* ---------- panel (right drawer) ---------- */
.mac-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  width: 380px;
  max-width: 100vw;
  background: var(--mac-bg);
  border-left: 1px solid var(--mac-border);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.12);
  animation: mac-slide-in 0.25s ease;
}

@keyframes mac-slide-in {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.mac-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 16px 16px 20px;
  background: var(--mac-sage);
  color: #fff;
}

.mac-header__title {
  margin: 0;
  font-family: var(--font-display, "Playfair Display", Georgia, serif);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
  color: #fff;
}

.mac-header__title:focus {
  outline: none;
}

.mac-header__subtitle {
  margin: 4px 0 0;
  font-size: 12.5px;
  opacity: 0.88;
}

.mac-header__actions {
  display: flex;
  gap: 4px;
}

.mac-icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.mac-icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ---------- messages ---------- */
.mac-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overscroll-behavior: contain;
}

.mac-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mac-item--user {
  align-items: flex-end;
}

.mac-item--assistant {
  align-items: flex-start;
}

.mac-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  overflow-wrap: anywhere;
}

.mac-msg p {
  margin: 0;
}

.mac-msg p + p,
.mac-msg p + ul,
.mac-msg ul + p {
  margin-top: 8px;
}

.mac-msg ul {
  margin: 0;
  padding-left: 18px;
}

.mac-msg a {
  color: var(--mac-sage);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.mac-msg--user {
  background: var(--mac-sage);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.mac-msg--assistant {
  background: #fff;
  border: 1px solid var(--mac-border);
  border-bottom-left-radius: 4px;
}

.mac-msg--error {
  align-self: flex-start;
  background: #fff7e6;
  border-color: rgba(198, 139, 0, 0.35);
}

.mac-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.mac-contact__btn {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border: 1px solid var(--mac-sage);
  border-radius: 999px;
  color: var(--mac-sage) !important;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none !important;
}

.mac-contact__btn--wa {
  background: #25d366;
  border-color: #25d366;
  color: #0b3d1e !important;
}

/* ---------- quote card ---------- */
.mac-quote {
  width: 88%;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--mac-border);
  border-left: 4px solid var(--mac-accent);
  border-radius: 12px;
  font-size: 13.5px;
}

.mac-quote p {
  margin: 0;
}

.mac-quote__title {
  font-family: var(--font-display, "Playfair Display", Georgia, serif);
  font-size: 16px;
  font-weight: 600;
}

.mac-quote__dates {
  margin-top: 2px !important;
  font-weight: 600;
}

.mac-quote__meta {
  color: var(--mac-muted);
}

.mac-quote__rows {
  margin: 10px 0 8px;
}

.mac-quote__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
}

.mac-quote__row dt,
.mac-quote__row dd {
  margin: 0;
}

.mac-quote__row dd {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.mac-quote__row--sub {
  border-top: 1px dashed var(--mac-border);
  margin-top: 3px;
  padding-top: 6px;
}

.mac-quote__row--total {
  border-top: 1px solid var(--mac-border);
  margin-top: 4px;
  padding-top: 7px;
  font-weight: 700;
  font-size: 15px;
}

.mac-quote__row--muted {
  color: var(--mac-muted);
}

.mac-quote__long {
  margin: 4px 0 6px !important;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(198, 139, 0, 0.1);
  color: #6b4a00;
  font-weight: 600;
}

.mac-quote__note {
  color: var(--mac-muted);
  font-size: 12px;
}

.mac-action {
  padding: 9px 14px;
  border: 1px solid var(--mac-sage);
  border-radius: 999px;
  background: rgba(57, 88, 70, 0.08);
  color: var(--mac-sage);
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}

.mac-action:hover {
  background: var(--mac-sage);
  color: #fff;
}

.mac-badge {
  margin: 0;
  color: var(--mac-sage);
  font-size: 13px;
  font-weight: 700;
}

/* ---------- typing, chips, composer ---------- */
.mac-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px 8px;
  color: var(--mac-muted);
  font-size: 13px;
}

.mac-typing__dots {
  display: inline-flex;
  gap: 3px;
}

.mac-typing__dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mac-sage);
  animation: mac-blink 1.2s infinite ease-in-out;
}

.mac-typing__dots i:nth-child(2) { animation-delay: 0.15s; }
.mac-typing__dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes mac-blink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

.mac-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 10px;
}

.mac-chip {
  padding: 7px 12px;
  border: 1px solid var(--mac-border);
  border-radius: 999px;
  background: #fff;
  color: var(--mac-text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.mac-chip:hover {
  border-color: var(--mac-sage);
  color: var(--mac-sage);
}

.mac-composer {
  padding: 10px 12px 4px;
  border-top: 1px solid var(--mac-border);
  background: #fff;
}

.mac-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.mac-input {
  flex: 1;
  min-height: 44px;
  max-height: 140px;
  padding: 11px 14px;
  border: 1px solid var(--mac-border);
  border-radius: 22px;
  background: var(--mac-bg);
  color: var(--mac-text);
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  resize: none;
}

.mac-send {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--mac-sage);
  color: #fff;
  cursor: pointer;
}

.mac-send:hover {
  background: var(--mac-sage-dark);
}

.mac-send:disabled {
  opacity: 0.5;
  cursor: wait;
}

.mac-counter {
  display: block;
  padding: 4px 6px 0;
  text-align: right;
  color: var(--mac-muted);
  font-size: 12px;
}

.mac-disclaimer {
  margin: 0;
  padding: 6px 16px 12px;
  background: #fff;
  color: var(--mac-muted);
  font-size: 11.5px;
  line-height: 1.4;
}

.mac-privacy {
  color: var(--mac-sage);
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}

/* ---------- mobile: full-screen panel, compact launcher + teaser ---------- */
@media (max-width: 640px) {
  .mac-launcher {
    right: 20px;
    bottom: 130px;
    width: 52px;
    height: 52px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }

  .mac-launcher__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .mac-teaser {
    right: 82px;
    bottom: 128px;
    max-width: min(230px, calc(100vw - 100px));
    padding: 8px 4px 8px 10px;
    border-radius: 12px;
  }

  .mac-teaser::after {
    right: -7px;
    bottom: 22px;
    border: none;
    border-top: 1px solid var(--mac-border);
    border-right: 1px solid var(--mac-border);
  }

  .mac-teaser__text {
    font-size: 13px;
  }

  .mac-panel {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-left: none;
    box-shadow: none;
    animation: mac-rise 0.22s ease;
  }

  @keyframes mac-rise {
    from { transform: translateY(16px); opacity: 0; }
    to { transform: none; opacity: 1; }
  }

  .mac-header {
    padding: 14px 10px 12px 16px;
  }

  .mac-icon-btn {
    width: 44px;
    height: 44px;
  }

  .mac-input {
    font-size: 16px; /* no zoom on iOS */
  }
}

html.mac-lock,
html.mac-lock body {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .mac-panel,
  .mac-teaser,
  .mac-launcher,
  .mac-typing__dots i {
    animation: none !important;
    transition: none !important;
  }
}

@media print {
  .mac-root {
    display: none !important;
  }
}
