/* Floating multi-channel contact widget & manager chat */

/* --- Launcher button --- */
.chat-widget-launcher {
  position: fixed;
  z-index: 1100;
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(18px + env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 22px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: #641f27;
  color: #fff;
  box-shadow: 0 12px 32px rgba(48, 23, 24, 0.24);
  font: 600 14px/1.2 Inter, Arial, sans-serif;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              background 0.2s ease,
              box-shadow 0.2s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.chat-widget-launcher:hover {
  transform: translateY(-2px);
  background: #4e171e;
  box-shadow: 0 16px 36px rgba(48, 23, 24, 0.3);
}
.chat-widget-launcher:active {
  transform: translateY(0) scale(0.98);
}
.chat-widget-launcher.is-menu-open {
  background: #3e1218;
  box-shadow: 0 14px 34px rgba(35, 14, 16, 0.35);
}
.chat-widget-launcher:focus-visible,
.chat-widget-close:focus-visible,
.chat-widget-menu-item:focus-visible,
.chat-widget-manager-action:focus-visible {
  outline: 3px solid #c9a56f;
  outline-offset: 3px;
}
.chat-widget-launcher-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}
.chat-widget-launcher.is-menu-open .chat-widget-launcher-icon {
  transform: rotate(90deg);
}
.chat-widget-launcher-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chat-widget-launcher-text {
  transition: opacity 0.15s ease;
}

/* --- Backdrop --- */
.chat-widget-backdrop,
.chat-widget-menu-backdrop {
  position: fixed;
  z-index: 1390;
  inset: 0;
  background: rgba(31, 24, 22, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.chat-widget-backdrop:not([hidden]),
.chat-widget-menu-backdrop:not([hidden]) {
  opacity: 1;
  pointer-events: auto;
}
.chat-widget-backdrop[hidden],
.chat-widget-menu-backdrop[hidden],
.chat-widget-panel[hidden],
.chat-widget-menu[hidden] {
  display: none !important;
}

/* --- Channels flyout menu --- */
.chat-widget-menu {
  position: fixed;
  z-index: 1395;
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(84px + env(safe-area-inset-bottom));
  width: min(340px, calc(100vw - 36px));
  padding: 16px;
  border: 1px solid rgba(89, 54, 47, 0.16);
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 20px 56px rgba(32, 18, 16, 0.22), 0 4px 16px rgba(32, 18, 16, 0.06);
  animation: chatMenuIn 0.24s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transform-origin: bottom right;
}
@keyframes chatMenuIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.chat-widget-menu-header {
  margin-bottom: 12px;
  padding: 4px 6px 10px;
  border-bottom: 1px solid #f1eae4;
}
.chat-widget-menu-title {
  display: block;
  color: #2b1f1c;
  font: 600 16px/1.25 "Playfair Display", Georgia, serif;
}
.chat-widget-menu-subtitle {
  display: block;
  margin-top: 4px;
  color: #88786e;
  font: 400 11.5px/1.3 Inter, Arial, sans-serif;
}
.chat-widget-menu-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-widget-menu-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 10px 12px;
  border: 1px solid #ede5de;
  border-radius: 13px;
  background: #faf8f5;
  color: #2e2320;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.chat-widget-menu-item:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 6px 18px rgba(45, 25, 20, 0.08);
}

/* WhatsApp channel item */
.chat-widget-item-wa:hover {
  background: #f4fbf6;
  border-color: #c9eed7;
}
.chat-widget-icon-wa {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 11px;
  background: #e7f7ed;
  color: #1fa855;
}
.chat-widget-icon-wa svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* Telegram channel item */
.chat-widget-item-tg:hover {
  background: #f2f8fd;
  border-color: #cde4f7;
}
.chat-widget-icon-tg {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 11px;
  background: #e8f3fc;
  color: #2481cc;
}
.chat-widget-icon-tg svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* MAX channel item */
.chat-widget-item-max {
  cursor: pointer;
}
.chat-widget-item-max:hover {
  background: #f6f3ee;
  border-color: #dfd7cd;
}
.chat-widget-icon-max {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 1px solid #dcd4cb;
  border-radius: 11px;
  background: #efebe5;
  color: #63554b;
  font: 700 11px/1 Inter, Arial, sans-serif;
  letter-spacing: 0.5px;
}

/* On-site Chat item */
.chat-widget-item-site {
  width: 100%;
  border-color: #eedfe3;
  background: #fdf7f8;
  text-align: left;
}
.chat-widget-item-site:hover {
  background: #f9eef1;
  border-color: #dfb8c2;
}
.chat-widget-icon-site {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 11px;
  background: #f6e6e9;
  color: #641f27;
}
.chat-widget-icon-site svg {
  width: 21px;
  height: 21px;
  stroke: currentColor;
}

/* Item copy & badges */
.chat-widget-item-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}
.chat-widget-item-title {
  color: #2b1f1c;
  font: 600 14px/1.2 Inter, Arial, sans-serif;
}
.chat-widget-item-desc {
  color: #827267;
  font: 400 11.5px/1.25 Inter, Arial, sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-widget-item-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  font: 600 10.5px/1 Inter, Arial, sans-serif;
  letter-spacing: 0.2px;
  flex: 0 0 auto;
}
.chat-widget-badge-online {
  background: #e2f5e9;
  color: #178340;
}
.chat-widget-badge-tg {
  background: #e3f2fd;
  color: #1976d2;
}
.chat-widget-badge-soon {
  background: #ebe5dc;
  color: #796c61;
}
.chat-widget-item-arrow {
  color: #641f27;
  font-size: 15px;
  font-weight: 600;
  transition: transform 0.18s ease;
  flex: 0 0 auto;
}
.chat-widget-item-site:hover .chat-widget-item-arrow {
  transform: translateX(3px);
}

/* Toast alert for pending services (e.g. MAX) */
.chat-widget-toast {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 9px;
  background: #fff8eb;
  border: 1px solid #fae2b8;
  color: #7d5b1e;
  font: 500 11.5px/1.4 Inter, Arial, sans-serif;
  text-align: center;
  animation: chatMenuIn 0.18s ease-out;
}

/* --- Chat iframe panel --- */
.chat-widget-panel {
  position: fixed;
  z-index: 1401;
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(84px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  width: min(420px, calc(100vw - 36px));
  height: min(680px, calc(100dvh - 112px - env(safe-area-inset-bottom)));
  min-height: 360px;
  overflow: hidden;
  border: 1px solid rgba(89, 54, 47, 0.16);
  border-radius: 18px;
  background: #fffdfa;
  box-shadow: 0 24px 72px rgba(30, 20, 18, 0.28);
}
.chat-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 66px;
  padding: 12px 16px 12px 20px;
  background: #fffdfa;
  border-bottom: 1px solid #eee5dc;
}
.chat-widget-heading {
  margin: 0;
  color: #332824;
  font: 500 19px/1.2 "Playfair Display", Georgia, serif;
}
.chat-widget-caption {
  margin: 4px 0 0;
  color: #85776e;
  font: 11px/1.4 Inter, Arial, sans-serif;
}
.chat-widget-close {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid #eadfd8;
  border-radius: 50%;
  background: #fff;
  color: #641f27;
  font: 400 23px/1 Arial, sans-serif;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
}
.chat-widget-close:hover {
  background: #fbf5f2;
  transform: rotate(90deg);
}
.chat-widget-frame-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #faf7f3;
}
.chat-widget-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fffdfa;
}
.chat-widget-fallback {
  margin: 0;
  padding: 9px 14px;
  background: #fff8ed;
  color: #6f5b42;
  text-align: center;
  font: 12px/1.45 Inter, Arial, sans-serif;
}
.chat-widget-fallback[hidden] {
  display: none;
}
.chat-widget-fallback a {
  color: #641f27;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Manager catalog action */
.chat-widget-manager-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  margin: 8px 0 0;
  padding: 8px 13px;
  border: 1px solid #6a252c;
  border-radius: 5px;
  background: #6a252c;
  color: #fff;
  text-decoration: none;
  text-align: center;
  font: 600 12px/1.3 Inter, Arial, sans-serif;
  cursor: pointer;
}
.chat-widget-manager-action:hover {
  background: #4e171e;
  border-color: #4e171e;
}
.palette-card .chat-widget-manager-action {
  width: 100%;
}

/* Selection bar adjustments */
body:has(.selection-bar:not([hidden])) .chat-widget-launcher {
  bottom: calc(108px + env(safe-area-inset-bottom));
}
body:has(.selection-bar:not([hidden])) .chat-widget-menu {
  bottom: calc(174px + env(safe-area-inset-bottom));
}
body:has(.selection-bar:not([hidden])) .chat-widget-panel {
  bottom: calc(174px + env(safe-area-inset-bottom));
}

/* --- Mobile screens --- */
@media (max-width: 640px) {
  .chat-widget-launcher {
    right: max(14px, env(safe-area-inset-right));
    bottom: calc(14px + env(safe-area-inset-bottom));
    min-height: 50px;
    padding: 0 18px;
    font-size: 13.5px;
  }
  .chat-widget-menu {
    right: max(14px, env(safe-area-inset-right));
    bottom: calc(76px + env(safe-area-inset-bottom));
    width: min(320px, calc(100vw - 28px));
    padding: 14px;
  }
  .chat-widget-panel {
    inset: auto 0 0;
    width: 100%;
    height: min(88dvh, 760px);
    min-height: min(420px, 75dvh);
    border-radius: 18px 18px 0 0;
  }
  .chat-widget-backdrop {
    background: rgba(31, 24, 22, 0.54);
  }
  .chat-widget-header {
    min-height: 60px;
    padding: 10px 13px 10px 16px;
  }
  body:has(.selection-bar:not([hidden])) .chat-widget-launcher {
    bottom: calc(98px + env(safe-area-inset-bottom));
  }
  body:has(.selection-bar:not([hidden])) .chat-widget-menu {
    bottom: calc(156px + env(safe-area-inset-bottom));
  }
  body:has(.selection-bar:not([hidden])) .chat-widget-panel {
    bottom: calc(154px + env(safe-area-inset-bottom));
  }
}
@media (min-width: 641px) and (max-height: 500px) {
  .chat-widget-panel {
    bottom: calc(72px + env(safe-area-inset-bottom));
    height: calc(100dvh - 90px - env(safe-area-inset-bottom));
    min-height: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .chat-widget-launcher,
  .chat-widget-menu,
  .chat-widget-close {
    transition: none;
    animation: none;
  }
}
