/*
 * Chat with the cosmetologist (functions.php → ags_tg_popup_widget, js/telegram-widget.js),
 * in the header's language: a round ink button in the corner that grows out of its centre,
 * and a rounded white card above it, like the search dialog.
 */

.ags-chat {
  --ink: #201600;
  --text: #565049;
  --muted: #6F6A63;
  --gold: #C49564;
  --gold-dark: #A97B4B;
  --line: #E3DED6;
  --surface: #F4F6F5;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: "Neue Haas Unica", sans-serif;
  pointer-events: none;
}

.ags-chat > * {
  pointer-events: auto;
}

.ags-chat :focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

/* The button */

.ags-chat__launcher {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 12px 30px rgba(32, 22, 0, 0.22);
  color: #fff;
  cursor: pointer;
  transform: scale(0);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s;
}

.ags-chat.is-ready .ags-chat__launcher {
  transform: scale(1);
}

.ags-chat__icon {
  grid-area: 1 / 1;
  transition: opacity var(--ags-pop-open, 0.3s) var(--ags-ease, ease-out), transform var(--ags-pop-open, 0.3s) var(--ags-ease, ease-out);
}

.ags-chat__icon--close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}

.ags-chat.is-open .ags-chat__icon--chat {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

.ags-chat.is-open .ags-chat__icon--close {
  opacity: 1;
  transform: none;
}

/* The card */

.ags-chat__panel {
  width: 340px;
  max-width: calc(100vw - 32px);
  padding: 20px;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(32, 22, 0, 0.18), 0 2px 8px rgba(32, 22, 0, 0.06);
  color: var(--text);
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity var(--ags-pop-close, 0.2s) var(--ags-ease-close, ease), transform var(--ags-pop-close, 0.2s) var(--ags-ease-close, ease);
}

/* Motion tokens in css/pages.css, as the header's dropdowns. */
.ags-chat.is-open .ags-chat__panel {
  opacity: 1;
  transform: none;
  transition: opacity var(--ags-pop-open, 0.3s) var(--ags-ease, ease-out), transform var(--ags-pop-open, 0.3s) var(--ags-ease, ease-out);
}

.ags-chat__panel[hidden] {
  display: none;
}

.ags-chat__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.ags-chat__avatar {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
}

/* "Online": a small gold dot on the avatar. */
.ags-chat__avatar::after {
  content: "";
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--gold);
}

.ags-chat__who {
  flex: 1 1 auto;
  min-width: 0;
}

.ags-chat .ags-chat__title {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.3;
}

.ags-chat .ags-chat__status {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.ags-chat__close {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 40px;
  height: 40px;
  margin: -4px -4px 0 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.3s var(--ease);
}

.ags-chat .ags-chat__message {
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: 4px 16px 16px 16px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
}

.ags-chat .ags-chat__button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: 8px;
  background: var(--gold);
  color: #fff;
  font-size: 13px;
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-decoration: none;
  text-transform: uppercase;
  transition: background-color 0.2s;
}

.ags-chat__button svg {
  transition: transform 0.3s var(--ease);
}

@media (hover: hover) {
  .ags-chat__launcher:hover {
    background: #3a2c12;
  }

  .ags-chat__close:hover {
    border-color: var(--ink);
    background: var(--ink);
    color: #fff;
    transform: rotate(90deg);
  }

  .ags-chat .ags-chat__button:hover {
    background: var(--gold-dark);
  }

  .ags-chat .ags-chat__button:hover svg {
    transform: translateX(4px);
  }
}

@media (max-width: 767px) {
  .ags-chat {
    right: 16px;
    bottom: 16px;
  }

  .ags-chat__launcher {
    width: 52px;
    height: 52px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ags-chat *,
  .ags-chat__launcher {
    transition: none !important;
  }
}
