/* static/css/chat-widget.css */

/*
  ALFAPOL Chat Widget styles.
  Префикс .apc- (ALFAPOL Chat) чтобы не пересекаться с существующими классами.
*/

/* ============================================
   ПЛАВАЮЩИЕ КНОПКИ: чат + звонок
   Обе оранжевые, одинаковый размер, вертикальный стек справа
   ============================================ */

/* Общий стиль-миксин для формы кнопок */
.apc-fab,
.apc-fab-phone {
  width: 3.5rem;
  height: 3.5rem;
  background: #ea580c;
  border: none;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  box-shadow: 0 6px 16px rgba(234, 88, 12, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.apc-fab:hover,
.apc-fab-phone:hover {
  transform: scale(1.08);
  background: #c2410c;
  box-shadow: 0 8px 22px rgba(234, 88, 12, 0.5);
}

/* Кнопка чата — сверху */
.apc-fab {
  position: fixed;
  right: 1rem;
  bottom: 5.75rem; /* над кнопкой звонка с зазором 12px */
  z-index: 45;
}

.apc-fab--hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

.apc-fab__icon {
  width: 1.5rem;
  height: 1.5rem;
}

/*
  Бейдж AI: компактная зелёная метка в правом верхнем углу.
  Меньше чем в v1, без белой обводки — выглядит аккуратно.
*/
.apc-fab__badge {
  position: absolute;
  top: -0.125rem;
  right: -0.125rem;
  background: #22c55e;
  color: white;
  font-size: 0.5625rem;
  font-weight: 800;
  padding: 0.125rem 0.3125rem;
  border-radius: 9999px;
  line-height: 1;
  letter-spacing: 0.03em;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Кнопка телефона — снизу */
.apc-fab-phone {
  right: 1rem;
  bottom: 1rem;
  text-decoration: none;
}

.apc-fab-phone svg {
  width: 1.5rem;
  height: 1.5rem;
}

/* Десктоп: увеличиваем отступы от края */
@media (min-width: 768px) {
  .apc-fab {
    right: 1.5rem;
    bottom: 6.25rem;
  }
  .apc-fab-phone {
    right: 1.5rem;
    bottom: 1.5rem;
  }
}

/* ============================================
   PANEL — окно чата
   ============================================ */
.apc-panel {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: calc(100vw - 2rem);
  max-width: 400px;
  height: calc(100vh - 6rem);
  max-height: 640px;
  background: white;
  border-radius: 1.25rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 46;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.98);
  transition: opacity 0.25s ease, transform 0.25s ease;
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.apc-panel--open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

@media (min-width: 768px) {
  .apc-panel {
    right: 1.5rem;
    bottom: 1.5rem;
  }
}

/* ============================================
   HEADER — шапка чата
   ============================================ */
.apc-header {
  background: #0f172a;
  color: white;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
}

.apc-header__info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.apc-header__avatar {
  width: 2.5rem;
  height: 2.5rem;
  background: #ea580c;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.apc-header__avatar svg {
  color: white;
}

.apc-header__title {
  min-width: 0;
}

.apc-header__name {
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Статус "Онлайн" с зелёной точкой */
.apc-header__status {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 0.125rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.apc-header__dot {
  width: 0.5rem;
  height: 0.5rem;
  background: #22c55e;
  border-radius: 9999px;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
}

.apc-header__close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.apc-header__close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ============================================
   MESSAGES — область сообщений
   ============================================ */
.apc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-behavior: smooth;
}

.apc-messages::-webkit-scrollbar {
  width: 6px;
}
.apc-messages::-webkit-scrollbar-track {
  background: transparent;
}
.apc-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.apc-msg {
  display: flex;
  max-width: 85%;
  animation: apcFadeIn 0.25s ease-out;
}

.apc-msg--user {
  align-self: flex-end;
  justify-content: flex-end;
}

.apc-msg--assistant {
  align-self: flex-start;
  justify-content: flex-start;
}

.apc-bubble {
  padding: 0.625rem 0.9375rem;
  border-radius: 1rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.apc-msg--user .apc-bubble {
  background: #ea580c;
  color: white;
  border-bottom-right-radius: 0.25rem;
}

.apc-msg--assistant .apc-bubble {
  background: white;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 0.25rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

@keyframes apcFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   TYPING INDICATOR — "печатает..."
   Удаляется сразу после получения ответа (см. chat-widget.js)
   ============================================ */
.apc-typing {
  display: flex;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  align-items: center;
}

.apc-typing span {
  width: 0.5rem;
  height: 0.5rem;
  background: #94a3b8;
  border-radius: 9999px;
  animation: apcTyping 1.4s infinite ease-in-out;
}

.apc-typing span:nth-child(1) { animation-delay: 0s; }
.apc-typing span:nth-child(2) { animation-delay: 0.2s; }
.apc-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes apcTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ============================================
   INPUT AREA — поле ввода
   ============================================ */
.apc-input-area {
  border-top: 1px solid #e2e8f0;
  background: white;
  padding: 0.75rem;
  flex-shrink: 0;
}

.apc-input-wrap {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.apc-input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 0.75rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  font-family: inherit;
  line-height: 1.4;
  resize: none;
  min-height: 2.5rem;
  max-height: 7.5rem;
  outline: none;
  transition: border-color 0.15s;
  background: #f8fafc;
  color: #0f172a;
}

.apc-input:focus {
  border-color: #ea580c;
  background: white;
}

.apc-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Кнопка отправки — квадратная, оранжевая, самолётик внутри */
.apc-send {
  background: #ea580c;
  color: white;
  border: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
  padding: 0;
}

.apc-send:hover:not(:disabled) {
  background: #c2410c;
}

.apc-send:active:not(:disabled) {
  transform: scale(0.95);
}

.apc-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.apc-send svg {
  display: block;
}

.apc-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0 0.25rem;
  font-size: 0.6875rem;
  color: #94a3b8;
}

.apc-counter--warn {
  color: #ea580c;
  font-weight: 600;
}

.apc-privacy {
  color: #94a3b8;
  text-align: right;
}

.apc-privacy a {
  color: #64748b;
  text-decoration: underline;
}