/* Live chat — boutique consultant widget (stage 1 UI) */

.live-chat {
  --lc-radius: 18px;
  --lc-radius-sm: 12px;
  --lc-radius-bubble: 14px;
  position: fixed;
  right: 22px;
  bottom: 104px;
  z-index: 45;
  width: min(380px, calc(100vw - 28px));
  pointer-events: none;
}

.live-chat:not([hidden]) {
  pointer-events: auto;
}

.live-chat__panel {
  display: flex;
  flex-direction: column;
  height: min(560px, calc(100vh - 140px));
  overflow: hidden;
  border: 1px solid var(--color-line);
  border-radius: var(--lc-radius);
  background: var(--color-white);
  box-shadow:
    0 8px 24px rgba(44, 36, 28, 0.08),
    0 28px 64px rgba(44, 36, 28, 0.16);
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transition:
    opacity 0.28s ease,
    transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.live-chat.is-open .live-chat__panel {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.live-chat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  background:
    linear-gradient(180deg, var(--color-cream) 0%, var(--color-white) 100%);
  border-bottom: 1px solid var(--color-line);
}

.live-chat__person {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.live-chat__avatar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
}

.live-chat__avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
  display: block;
  background: var(--color-image-bg);
  box-shadow: 0 0 0 2px var(--color-white), 0 0 0 3px rgba(224, 170, 0, 0.45);
}

.live-chat__online {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #9a938c;
  border: 2px solid var(--color-white);
}

.live-chat__online.is-on {
  background: #3d9a5f;
  box-shadow: 0 0 0 3px rgba(61, 154, 95, 0.18);
}

.live-chat__meta {
  min-width: 0;
}

.live-chat__name {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--color-ink);
  line-height: 1.25;
}

.live-chat__role {
  margin: 3px 0 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--color-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-chat__status {
  color: #3d9a5f;
  font-weight: 500;
}

.live-chat__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.2s ease, background 0.2s ease;
}

.live-chat__close:hover {
  color: var(--color-ink);
  background: var(--color-cream);
}

.live-chat__close .icon {
  width: 18px;
  height: 18px;
}

.live-chat__body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background:
    radial-gradient(ellipse at top left, rgba(224, 170, 0, 0.06), transparent 55%),
    var(--color-cream);
  padding: 16px 14px 12px;
  -webkit-overflow-scrolling: touch;
}

.live-chat__thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.live-chat__day {
  align-self: center;
  margin: 4px 0 8px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
  background: rgba(255, 255, 255, 0.65);
}

html[data-theme="dark"] .live-chat__day {
  background: rgba(28, 24, 21, 0.55);
}

.live-chat__bubble {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: var(--lc-radius-bubble);
  font-size: 14px;
  line-height: 1.45;
  color: var(--color-ink);
  word-break: break-word;
  animation: live-chat-in 0.28s ease both;
}

@keyframes live-chat-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.live-chat__bubble--agent {
  align-self: flex-start;
  border-bottom-left-radius: 6px;
  background: var(--color-white);
  border: 1px solid var(--color-line);
  box-shadow: 0 4px 14px rgba(44, 36, 28, 0.05);
}

.live-chat__bubble--user {
  align-self: flex-end;
  border-bottom-right-radius: 6px;
  background: linear-gradient(160deg, #efc44a 0%, var(--color-accent) 55%, var(--color-accent-strong) 100%);
  color: #1c1916;
  border: 0;
}

.live-chat__bubble-time {
  display: block;
  margin-top: 6px;
  font-size: 10px;
  letter-spacing: 0.04em;
  opacity: 0.65;
}

.live-chat__typing {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 12px 14px;
  border-radius: var(--lc-radius-bubble);
  border-bottom-left-radius: 6px;
  background: var(--color-white);
  border: 1px solid var(--color-line);
}

.live-chat__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-muted);
  animation: live-chat-dot 1.2s ease-in-out infinite;
}

.live-chat__typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.live-chat__typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes live-chat-dot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.live-chat__composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 12px 10px;
  border-top: 1px solid var(--color-line);
  background: var(--color-white);
}

.live-chat__input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 110px;
  padding: 11px 14px;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--lc-radius-sm);
  background: var(--color-cream);
  color: var(--color-ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  resize: none;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.live-chat__input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(224, 170, 0, 0.18);
}

.live-chat__input::placeholder {
  color: var(--color-placeholder);
}

.live-chat__send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--lc-radius-sm);
  flex-shrink: 0;
  background: var(--color-ink);
  color: #ffffff;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

html[data-theme="dark"] .live-chat__send {
  color: #14110f;
}

.live-chat__send:hover {
  background: color-mix(in srgb, var(--color-ink) 88%, #000);
  transform: translateY(-1px);
}

.live-chat__send:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.live-chat__channels {
  padding: 0 14px 14px;
  background: var(--color-white);
  border-top: 1px solid var(--color-line);
}

.live-chat__channels-label {
  margin: 10px 0 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
  text-align: center;
}

.live-chat__channels-row {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.live-chat__channel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-cream);
  border: 1px solid var(--color-line);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.live-chat__channel:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(44, 36, 28, 0.1);
}

.live-chat__channel .fixed-widget__brand-icon,
.live-chat__channel img {
  width: 20px;
  height: 20px;
  display: block;
}

/* Launcher — horizontal bar in bottom-right corner */
.fixed-widget__live-bar {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  max-width: min(320px, calc(100vw - 32px));
  padding: 12px 20px 12px 16px;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: var(--color-white);
  color: var(--color-ink);
  cursor: pointer;
  text-align: left;
  box-shadow:
    0 4px 14px rgba(44, 36, 28, 0.08),
    0 16px 38px rgba(44, 36, 28, 0.16);
  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease,
    opacity 0.22s ease,
    visibility 0.22s ease,
    background 0.25s ease;
}

.fixed-widget__live-bar:hover {
  transform: translateY(-2px);
  box-shadow:
    0 6px 18px rgba(44, 36, 28, 0.1),
    0 20px 44px rgba(44, 36, 28, 0.2);
}

.fixed-widget__live-bar:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

.fixed-widget__live-bar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(160deg, #efc44a 0%, var(--color-accent) 48%, var(--color-accent-strong) 100%);
  color: var(--color-white);
  box-shadow: 0 4px 12px rgba(224, 170, 0, 0.28);
}

.fixed-widget__live-bar-icon svg {
  display: block;
  width: 21px;
  height: 21px;
}

.fixed-widget__live-bar-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.fixed-widget__live-bar-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fixed-widget__live-bar-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-muted);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fixed-widget__live-bar-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-line);
}

.fixed-widget__live-bar-dot.is-on {
  background: #3d9a5f;
  box-shadow: 0 0 0 3px rgba(61, 154, 95, 0.18);
}

.fixed-widget--chat-open .fixed-widget__live-bar {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px) scale(0.96);
}

.fixed-widget__unread {
  position: absolute;
  top: -6px;
  right: -4px;
  z-index: 3;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #c0392b;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(192, 57, 43, 0.35);
}

.fixed-widget__unread[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .fixed-widget__live-bar {
    gap: 10px;
    padding: 10px 16px 10px 12px;
  }

  .fixed-widget__live-bar-icon {
    width: 34px;
    height: 34px;
  }

  .fixed-widget__live-bar-icon svg {
    width: 19px;
    height: 19px;
  }

  .fixed-widget__live-bar-title {
    font-size: 13px;
  }

  .fixed-widget__live-bar-note {
    font-size: 11px;
  }

  .live-chat {
    right: 14px;
    bottom: 152px;
    width: min(100vw - 28px, 380px);
  }

  .live-chat__panel {
    height: min(520px, calc(100vh - 200px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .live-chat__panel,
  .live-chat__bubble,
  .live-chat__typing span,
  .fixed-widget__live-bar {
    animation: none !important;
    transition: none !important;
  }
}
