/* Виджет "Написать администратору" — плавающая кнопка и окно чата */

.lh-support-widget {
  font-family: var(--font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  font-size: 14px;
  box-sizing: border-box;
}

.lh-support-widget *,
.lh-support-widget *::before,
.lh-support-widget *::after {
  box-sizing: border-box;
}

/* Кнопка-кругляшок */
.lh-support-btn {
  position: fixed;
  right: 20px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color, #1e3a8a), var(--secondary-color, #0f766e));
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(30, 58, 138, 0.4);
  z-index: 99998;
  transition: transform 0.2s, box-shadow 0.2s;
}

.lh-support-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(30, 58, 138, 0.5);
}

.lh-support-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5);
}

.lh-support-btn svg {
  width: 24px;
  height: 24px;
}

/* Мобильные: кнопка с учётом safe-area и удобного нажатия */
@media (max-width: 768px) {
  .lh-support-btn {
    right: max(16px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
    width: 54px;
    height: 54px;
    min-width: 44px;
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  .lh-support-btn {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    width: 52px;
    height: 52px;
  }
}

/* Оверлей */
.lh-support-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 99999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}


.lh-support-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

/* Окно чата */
.lh-support-window {
  position: fixed;
  right: 20px;
  bottom: 90px;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: min(520px, 90vh);
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(30, 58, 138, 0.12);
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.08),
    0 10px 25px -5px rgba(0, 0, 0, 0.12),
    0 20px 50px -12px rgba(0, 0, 0, 0.15);
  z-index: 100000;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.98);
  transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
  overflow: hidden;
}

.lh-support-overlay.is-open .lh-support-window {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Мобильные: окно на весь экран с safe-area (лист снизу) */
@media (max-width: 768px) {
  .lh-support-window {
    right: 0;
    left: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-width: 100%;
    max-height: min(92vh, calc(100dvh - env(safe-area-inset-bottom, 0px)));
    height: min(92vh, calc(100dvh - env(safe-area-inset-bottom, 0px)));
    border-radius: 16px 16px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.2);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

@media (max-width: 480px) {
  .lh-support-window {
    max-height: min(95vh, calc(100dvh - env(safe-area-inset-bottom, 0px)));
    height: min(95vh, calc(100dvh - env(safe-area-inset-bottom, 0px)));
    border-radius: 14px 14px 0 0;
  }
}

/* Заголовок окна */
.lh-support-header {
  padding: 16px 18px;
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #0f766e 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.lh-support-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.01em;
}

.lh-support-close {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  cursor: pointer;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}

.lh-support-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.lh-support-close:active {
  transform: scale(0.98);
}

@media (max-width: 768px) {
  .lh-support-header {
    padding: 14px 16px;
    padding-top: max(14px, env(safe-area-inset-top));
  }
  .lh-support-header h3 {
    font-size: 1rem;
  }
  .lh-support-close {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
}

/* Онлайн / офлайн */
.lh-support-online-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 500;
  color: #166534;
  background: linear-gradient(90deg, rgba(22, 101, 52, 0.08) 0%, rgba(34, 197, 94, 0.06) 100%);
  border-bottom: 1px solid #e5e7eb;
}

.lh-support-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3);
  animation: lh-support-pulse 2s ease-in-out infinite;
}

@keyframes lh-support-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.1); }
}

.lh-support-offline-msg {
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.45;
  color: #64748b;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid #e2e8f0;
}

.lh-support-offline-text {
  display: block;
}

/* Контейнер сообщений */
.lh-support-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-height: 140px;
  max-height: 280px;
  background: #fafbfc;
}

.lh-support-messages::-webkit-scrollbar {
  width: 6px;
}

.lh-support-messages::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}

.lh-support-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.lh-support-messages::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

@media (max-width: 768px) {
  .lh-support-messages {
    flex: 1;
    min-height: 120px;
    max-height: none;
    padding: 12px 14px;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 480px) {
  .lh-support-messages {
    padding: 10px 12px;
  }
  .lh-support-msg {
    padding: 12px 14px;
    margin-bottom: 10px;
  }
}

.lh-support-msg {
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  max-width: 88%;
  word-wrap: break-word;
  line-height: 1.45;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.lh-support-msg.user,
.lh-support-msg.guest {
  margin-left: auto;
  margin-right: 0;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.lh-support-msg.admin {
  margin-right: auto;
  margin-left: 0;
  background: #fff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}

.lh-support-msg-name {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.9;
  margin-bottom: 4px;
}

.lh-support-msg.admin .lh-support-msg-name {
  color: #475569;
}

.lh-support-msg-time {
  font-size: 11px;
  opacity: 0.85;
  margin-top: 6px;
}

/* Форма ввода */
.lh-support-form {
  padding: 16px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.lh-support-form .lh-support-field {
  margin-bottom: 12px;
}

.lh-support-form .lh-support-field:last-of-type {
  margin-bottom: 0;
}

.lh-support-form .lh-support-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: #475569;
}

.lh-support-form input[type="text"],
.lh-support-form input[type="email"],
.lh-support-form input[type="tel"],
.lh-support-form textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

/* Мобильные: 16px в полях ввода — предотвращает авто-зум iOS при фокусе */
@media (max-width: 768px) {
  .lh-support-form input[type="text"],
  .lh-support-form input[type="email"],
  .lh-support-form input[type="tel"],
  .lh-support-form textarea {
    padding: 12px 14px;
    font-size: 16px;
    min-height: 48px;
  }
  .lh-support-form textarea {
    min-height: 80px;
  }
  .lh-support-form .lh-support-submit {
    padding: 14px 18px;
    min-height: 48px;
    margin-top: 14px;
  }
  .lh-support-form {
    padding: 14px 16px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
}

.lh-support-form input:focus,
.lh-support-form textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.lh-support-form textarea {
  min-height: 76px;
  resize: vertical;
  max-height: 120px;
}

.lh-support-form .lh-support-submit {
  width: 100%;
  padding: 12px 18px;
  margin-top: 12px;
  background: linear-gradient(135deg, #1e3a8a 0%, #0f766e 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(30, 58, 138, 0.3);
}

.lh-support-form .lh-support-submit:hover:not(:disabled) {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(30, 58, 138, 0.35);
}

.lh-support-form .lh-support-submit:active:not(:disabled) {
  transform: translateY(0);
}

.lh-support-form .lh-support-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

/* Состояния */
.lh-support-status {
  padding: 12px 16px;
  text-align: center;
  font-size: 13px;
  line-height: 1.4;
  color: #64748b;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

.lh-support-status.success {
  color: #166534;
  background: rgba(22, 101, 52, 0.08);
}

.lh-support-status.error {
  color: #b91c1c;
  background: rgba(185, 28, 28, 0.08);
}

.lh-support-honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
