/* /support/widget.css (v2.4 - Синие сообщения + Фикс кнопки) */

:root {
    /* Основной цвет (фиолетовый) - для иконок/ссылок */
    --widget-color: #8a2be2; 
    --widget-color-gradient: linear-gradient(135deg, #8a2be2, #a052e0);
    
    /* Цвет кнопки (черный) */
    --widget-button-bg: #0D0D0D;
    --widget-button-hover: #222;

    --widget-bg: #1C1E2A;
    --widget-border: rgba(255, 255, 255, 0.1);
    --widget-text: #E0E0E0;
    --widget-text-muted: #8E8E93;

    /* Цвета чата */
    --admin-msg-bg: #3A3D4E; /* (Темно-серый для админа) */
    --admin-msg-text: #FFFFFF;
    
    /* Сообщение пользователя (синее) */
    --user-msg-bg: #0071E3; 
    --user-msg-text: #FFFFFF;
}

/* --- 1. Кнопка виджета --- */
.support-widget-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: var(--widget-button-bg);
    border: 1px solid var(--widget-border); 
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 9998;
    transform: scale(0);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease, background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.support-widget-button.visible {
    transform: scale(1);
    opacity: 1;
}
.support-widget-button:hover {
    background: var(--widget-button-hover); 
}
.support-widget-button img {
    width: 32px; 
    height: 32px; 
    transition: transform 0.2s ease;
    object-fit: contain; 
}
.support-widget-button.open img {
    transform: rotate(90deg);
}

/* --- 2. Модальное окно --- */
.support-widget-modal {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 350px;
    height: 500px;
    background: var(--widget-bg);
    border: 1px solid var(--widget-border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
}
.support-widget-modal.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* --- 3. Шапка окна --- */
.widget-header {
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--widget-border);
    text-align: center;
    position: relative;
    flex-shrink: 0; 
}
.widget-header h3 {
    margin: 0;
    color: var(--widget-text);
    font-size: 1.1rem;
}
.widget-header p {
    margin: 4px 0 0 0;
    color: var(--widget-text-muted);
    font-size: 0.85rem;
}
.widget-close-btn {
    position: absolute;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: var(--widget-text);
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 16px;
    line-height: 28px;
}
.widget-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- 4. Контент --- */
.widget-body {
    flex: 1;
    overflow: hidden;
    position: relative;
}
.widget-view {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--widget-bg);
}

/* --- 5. Экран чата (теперь по умолчанию) --- */
.widget-chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.widget-message {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    max-width: 80%;
    line-height: 1.5;
    font-size: 0.9rem;
    white-space: pre-wrap;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); 
}
.widget-message.user {
    background: var(--user-msg-bg);
    color: var(--user-msg-text);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.widget-message.admin {
    background: var(--admin-msg-bg);
    color: var(--admin-msg-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.widget-message.system {
    align-self: center;
    text-align: center;
    font-size: 0.8rem;
    color: var(--widget-text-muted);
    background: none;
    padding: 0.5rem;
    box-shadow: none; 
}
.widget-chat-reply {
    padding: 1rem;
    border-top: 1px solid var(--widget-border);
    background: rgba(0, 0, 0, 0.2);
}
.widget-chat-reply textarea {
    width: 100%;
    height: 60px;
    padding: 0.75rem;
    border: 1px solid var(--widget-border);
    border-radius: 8px;
    background: var(--widget-bg);
    color: var(--widget-text);
    resize: none;
    font-family: inherit;
    font-size: 0.9rem;
    box-sizing: border-box; 
    transition: background-color 0.3s ease, opacity 0.3s ease;
}
.widget-chat-reply button:not(.button) {
    width: 100%;
    padding: 0.75rem;
    margin-top: 0.5rem;
    border: none;
    border-radius: 8px;
    background: var(--widget-color-gradient);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.2s ease;
}
.widget-chat-reply button:not(.button):hover {
    filter: brightness(1.1); 
}
.widget-chat-reply button:not(.button):disabled {
    background: #555;
    cursor: not-allowed;
    filter: none;
}

/* --- 6. Экран "Войдите" --- */
.widget-login-prompt {
    padding: 2rem;
    text-align: center;
    color: var(--widget-text-muted);
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
}
.widget-login-prompt a {
    color: var(--widget-color);
    font-weight: 600;
}


/* --- 7. Стили для новой анимированной кнопки --- */
.button {
  --primary: var(--widget-color); 
  --neutral-1: #2a2d3a; 
  --neutral-2: #3a3d4e; 
  --radius: 10px; 
  color: var(--widget-text); 
  cursor: pointer;
  border-radius: var(--radius);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
  border: none;
  box-shadow: 0 0.5px 0.5px 1px rgba(255, 255, 255, 0.1),
    0 5px 10px rgba(0, 0, 0, 0.2), 0 2px 3px 0px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.3s ease;
  width: 100%; 
  margin-top: 0.5rem; 
  padding: 12px;
  height: 54px; 
  font-family: "Galano Grotesque", Poppins, Montserrat, sans-serif;
  font-style: normal;
  font-size: 16px; 
  font-weight: 600;
  box-sizing: border-box; 
}
.button:hover {
  transform: scale(1.02);
  box-shadow: 0 0 1px 2px rgba(255, 255, 255, 0.2),
    0 10px 20px rgba(0, 0, 0, 0.3), 0 8px 3px -3px rgba(0, 0, 0, 0.04);
}
.button:active {
  transform: scale(1);
  box-shadow: 0 0 1px 2px rgba(255, 255, 255, 0.2),
    0 8px 3px -3px rgba(0, 0, 0, 0.2);
}
.button:after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  border: 2px solid transparent; 
  background: linear-gradient(var(--neutral-1), var(--neutral-2)) padding-box,
    linear-gradient(to bottom, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.45))
      border-box;
  z-index: 0;
  transition: all 0.4s ease;
}
.button:hover::after {
  transform: scale(1.03, 1.05); 
  box-shadow: inset 0 -1px 3px 0 rgba(255, 255, 255, 0.3); 
}
.button::before {
  content: "";
  inset: 5px 6px 6px 6px; 
  position: absolute;
  background: linear-gradient(to top, var(--neutral-1), var(--neutral-2));
  border-radius: 30px;
  filter: blur(0.5px);
  z-index: 2;
}

.state p {
  display: flex;
  align-items: center;
  justify-content: center;
  
  /* ★★★ ВОТ ЭТОТ ФИКС ★★★ */
  white-space: nowrap; 
}

.state .icon {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  margin: auto;
  transform: scale(1.1); 
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.state .icon svg {
  overflow: visible;
}
.outline {
  position: absolute;
  border-radius: inherit;
  overflow: hidden;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.4s ease;
  inset: -2px -3.5px;
}
.outline::before {
  content: "";
  position: absolute;
  inset: -100%;
  background: conic-gradient(
    from 180deg,
    transparent 60%,
    white 80%,
    transparent 100%
  );
  animation: spin 2s linear infinite;
  animation-play-state: paused;
}
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
.button:hover .outline {
  opacity: 1;
}
.button:hover .outline::before {
  animation-play-state: running;
}
.state p span {
  display: block;
  opacity: 0;
  animation: slideDown 0.8s ease forwards calc(var(--i) * 0.03s);
}
.button:hover p span {
  opacity: 1;
  animation: wave 0.5s ease forwards calc(var(--i) * 0.02s);
}
.button:focus p span {
  opacity: 1;
  animation: disapear 0.6s ease forwards calc(var(--i) * 0.03s);
}
@keyframes wave {
  30% {
    opacity: 1;
    transform: translateY(4px) translateX(0) rotate(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-3px) translateX(0) rotate(0);
    color: var(--primary);
  }
  100% {
    opacity: 1;
    transform: translateY(0) translateX(0) rotate(0);
  }
}
@keyframes slideDown {
  0% {
    opacity: 0;
    transform: translateY(-20px) translateX(5px) rotate(-90deg);
    color: var(--primary);
    filter: blur(5px);
  }
  30% {
    opacity: 1;
    transform: translateY(4px) translateX(0) rotate(0);
    filter: blur(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-3px) translateX(0) rotate(0);
  }
  100% {
    opacity: 1;
    transform: translateY(0) translateX(0) rotate(0);
  }
}
@keyframes disapear {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: translateX(5px) translateY(20px);
    color: var(--primary);
    filter: blur(5px);
  }
}
.state--default .icon svg {
  animation: land 0.6s ease forwards;
}
.button:hover .state--default .icon {
  transform: rotate(45deg) scale(1.1); 
}
.button:focus .state--default svg {
  animation: takeOff 0.8s linear forwards;
}
.button:focus .state--default .icon {
  transform: rotate(0) scale(1.1); 
}
@keyframes takeOff {
  0% {
    opacity: 1;
  }
  60% {
    opacity: 1;
    transform: translateX(70px) rotate(45deg) scale(2);
  }
  100% {
    opacity: 0;
    transform: translateX(160px) rotate(45deg) scale(0);
  }
}
@keyframes land {
  0% {
    transform: translateX(-60px) translateY(30px) rotate(-50deg) scale(2);
    opacity: 0;
    filter: blur(3px);
  }
  100% {
    transform: translateX(0) translateY(0) rotate(0);
    opacity: 1;
    filter: blur(0);
  }
}
.state--default .icon:before {
  content: "";
  position: absolute;
  top: 50%;
  height: 2px;
  width: 0;
  left: -5px;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.3)); 
}
.button:focus .state--default .icon:before {
  animation: contrail 0.8s linear forwards;
}
@keyframes contrail {
  0% {
    width: 0;
    opacity: 1;
  }
  8% {
    width: 15px;
  }
  60% {
    opacity: 0.7;
    width: 80px;
  }
  100% {
    opacity: 0;
    width: 160px;
  }
}
.state {
  padding-left: 29px;
  z-index: 2;
  display: flex;
  position: relative;
}
.state--default span:nth-child(4) {
  margin-right: 5px;
}
.state--sent {
  display: none;
}
.state--sent svg {
  transform: scale(1.1); 
  margin-right: 8px;
}
.button:focus .state--default {
  position: absolute;
}
.button:focus .state--sent {
  display: flex;
}
.button:focus .state--sent span {
  opacity: 0;
  animation: slideDown 0.8s ease forwards calc(var(--i) * 0.2s);
}
.button:focus .state--sent .icon svg {
  opacity: 0;
  animation: appear 1.2s ease forwards 0.8s;
}
@keyframes appear {
  0% {
    opacity: 0;
    transform: scale(4) rotate(-40deg);
    color: var(--primary);
    filter: blur(4px);
  }
  30% {
    opacity: 1;
    transform: scale(0.6);
    filter: blur(1px);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
    filter: blur(0);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* --- 8. Состояние "Форма отправлена" --- */
.widget-chat-reply.form-sent textarea {
    background-color: var(--admin-msg-bg);
    opacity: 0.7;
    cursor: not-allowed;
}
.widget-chat-reply.form-sent .button {
    cursor: not-allowed;
    opacity: 0.85;
}
.widget-chat-reply.form-sent .state--default {
    display: none;
}
.widget-chat-reply.form-sent .state--sent {
    display: flex;
}
.widget-chat-reply.form-sent .state--sent .icon svg,
.widget-chat-reply.form-sent .state--sent p span {
    animation: none;
    opacity: 1;
    transform: none;
    filter: none;
}