/* Корневой контейнер виджета - гарантированное отображение */
#tg-lead-widget-root {
  position: fixed !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  z-index: 99999 !important;
}

.tg-lead-widget {
  position: fixed;
  right: 24px;
  top: 24px;
  z-index: 9999;
  font-family: Arial, Helvetica, sans-serif;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.tg-lead-widget__button {
  border: none;
  background: #25c26e;
  color: #ffffff;
  font-weight: 600;
  padding: 8px 18px;
  height: 50px;
  min-height: 50px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(23, 32, 80, 0.25);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tg-lead-widget__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.tg-lead-widget__button-label {
  font-size: 13px;
  line-height: 1.2;
}

.tg-lead-widget__button:hover {
  background: #1e9b58;
}

.tg-lead-widget__button:disabled {
  background: #9bd9b8;
  cursor: not-allowed;
}

/* Form styles */
.tg-lead-widget__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
  background: #ffffff;
  border-radius: 12px 12px 0 0;
}

.tg-lead-widget__title {
  font-size: 16px;
  font-weight: 600;
  color: #1f2328;
}

.tg-lead-widget__close {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: #6b7280;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.tg-lead-widget__close:hover {
  background: #f3f4f6;
  color: #1f2328;
}

.tg-lead-widget__body {
  padding: 20px;
  background: #ffffff;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 12px 30px rgba(23, 32, 80, 0.25);
  min-width: 320px;
  max-width: 400px;
  box-sizing: border-box;
}

.tg-lead-widget__label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 8px;
}

.tg-lead-widget__input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 16px;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.tg-lead-widget__input:focus {
  outline: none;
  border-color: #25c26e;
  box-shadow: 0 0 0 3px rgba(37, 194, 110, 0.1);
}

.tg-lead-widget__input::placeholder {
  color: #9ca3af;
}

.tg-lead-widget__checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.5;
  color: #374151;
}

.tg-lead-widget__checkbox {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: #25c26e;
}

.tg-lead-widget__checkbox-text {
  user-select: none;
}

.tg-lead-widget__submit {
  width: 100%;
  border: none;
  background: #25c26e;
  color: #ffffff;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
  margin-top: 8px;
}

.tg-lead-widget__submit:hover {
  background: #1e9b58;
}

.tg-lead-widget__submit:disabled {
  background: #9bd9b8;
  cursor: not-allowed;
}

.tg-lead-widget__bot-button {
  width: 100%;
  border: 1px solid #25c26e;
  background: transparent;
  color: #25c26e;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  margin-top: 8px;
  pointer-events: auto;
}

.tg-lead-widget__bot-button:hover {
  background: #25c26e;
  color: #ffffff;
}

.tg-lead-widget__bot-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.tg-lead-widget__status {
  margin-top: 12px;
  font-size: 13px;
  text-align: center;
  min-height: 20px;
  padding: 8px;
  border-radius: 6px;
}

.tg-lead-widget__status--success {
  color: #059669;
  background: #d1fae5;
}

.tg-lead-widget__status--error {
  color: #dc2626;
  background: #fee2e2;
}

/* Планшеты (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
  .tg-lead-widget {
    right: 20px;
    top: 20px;
  }

  .tg-lead-widget__button {
    padding: 7px 16px;
    height: 48px;
    min-height: 48px;
  }

  .tg-lead-widget__avatar {
    width: 32px;
    height: 32px;
  }

  .tg-lead-widget__button-label {
    font-size: 12px;
  }

  .tg-lead-widget__body {
    min-width: 300px;
    max-width: 380px;
    padding: 18px;
  }
}

/* Мобильные устройства (до 768px) - круглая кнопка */
@media (max-width: 768px) {
  #tg-lead-widget-root {
    position: fixed !important;
    top: 16px !important;
    right: 16px !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 99999 !important;
    pointer-events: auto !important;
  }

  .tg-lead-widget {
    right: 16px;
    top: 16px;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
  }

  .tg-lead-widget__button {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .tg-lead-widget__button {
    padding: 0;
    width: 58px;
    height: 58px;
    min-height: 58px;
    min-width: 58px;
    border-radius: 50%;
    gap: 0;
    justify-content: center;
  }

  .tg-lead-widget__avatar {
    width: 58px;
    height: 58px;
    border: none;
  }

  .tg-lead-widget__button-label {
    display: none;
  }

  .tg-lead-widget__body {
    min-width: 280px;
    max-width: calc(100vw - 32px);
    padding: 16px;
  }

  .tg-lead-widget__header {
    padding: 14px;
  }

  .tg-lead-widget__title {
    font-size: 15px;
  }

  .tg-lead-widget__label {
    font-size: 13px;
    margin-bottom: 6px;
  }

  .tg-lead-widget__input {
    padding: 9px 11px;
    font-size: 13px;
    margin-bottom: 14px;
  }

  .tg-lead-widget__checkbox-label {
    font-size: 12px;
    gap: 8px;
    margin-bottom: 14px;
  }

  .tg-lead-widget__checkbox {
    width: 16px;
    height: 16px;
  }

  .tg-lead-widget__submit,
  .tg-lead-widget__bot-button {
    padding: 11px 14px;
    font-size: 13px;
  }
}

/* Маленькие мобильные (до 520px) */
@media (max-width: 520px) {
  #tg-lead-widget-root {
    position: fixed !important;
    top: 12px !important;
    right: 12px !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 99999 !important;
  }

  .tg-lead-widget {
    right: 12px;
    top: 12px;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .tg-lead-widget__button {
    padding: 0;
    width: 56px;
    height: 56px;
    min-height: 56px;
    min-width: 56px;
    border-radius: 50%;
    gap: 0;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(23, 32, 80, 0.2);
  }

  .tg-lead-widget__avatar {
    width: 56px;
    height: 56px;
    border: none;
  }

  .tg-lead-widget__button-label {
    display: none;
  }

  .tg-lead-widget__body {
    min-width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    padding: 14px;
    border-radius: 0 0 10px 10px;
  }

  .tg-lead-widget__header {
    padding: 12px;
    border-radius: 10px 10px 0 0;
  }

  .tg-lead-widget__title {
    font-size: 14px;
  }

  .tg-lead-widget__close {
    width: 22px;
    height: 22px;
    font-size: 22px;
  }

  .tg-lead-widget__label {
    font-size: 12px;
    margin-bottom: 5px;
  }

  .tg-lead-widget__input {
    padding: 8px 10px;
    font-size: 12px;
    margin-bottom: 12px;
  }

  .tg-lead-widget__checkbox-label {
    font-size: 11px;
    gap: 6px;
    margin-bottom: 12px;
  }

  .tg-lead-widget__checkbox {
    width: 15px;
    height: 15px;
    margin-top: 1px;
  }

  .tg-lead-widget__submit,
  .tg-lead-widget__bot-button {
    padding: 10px 12px;
    font-size: 12px;
    margin-top: 6px;
  }

  .tg-lead-widget__status {
    font-size: 12px;
    padding: 6px;
    margin-top: 10px;
  }
}

/* Очень маленькие экраны (до 375px) */
@media (max-width: 375px) {
  #tg-lead-widget-root {
    position: fixed !important;
    top: 8px !important;
    right: 8px !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 99999 !important;
  }

  .tg-lead-widget {
    right: 8px;
    top: 8px;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .tg-lead-widget__button {
    padding: 0;
    width: 54px;
    height: 54px;
    min-height: 54px;
    min-width: 54px;
    border-radius: 50%;
    gap: 0;
    justify-content: center;
  }

  .tg-lead-widget__avatar {
    width: 54px;
    height: 54px;
    border: none;
  }

  .tg-lead-widget__button-label {
    display: none;
  }

  .tg-lead-widget__body {
    min-width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    padding: 12px;
  }

  .tg-lead-widget__header {
    padding: 10px;
  }

  .tg-lead-widget__title {
    font-size: 13px;
  }
}

/* Ландшафтная ориентация на мобильных */
@media (max-width: 768px) and (orientation: landscape) {
  #tg-lead-widget-root {
    position: fixed !important;
    top: 8px !important;
    right: 12px !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 99999 !important;
  }

  .tg-lead-widget {
    top: 8px;
    right: 12px;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .tg-lead-widget__button {
    padding: 0;
    width: 52px;
    height: 52px;
    min-height: 52px;
    min-width: 52px;
    border-radius: 50%;
    gap: 0;
    justify-content: center;
  }

  .tg-lead-widget__avatar {
    width: 52px;
    height: 52px;
    border: none;
  }

  .tg-lead-widget__button-label {
    display: none;
  }

  .tg-lead-widget__body {
    max-height: calc(100vh - 20px);
    overflow-y: auto;
  }
}

/* Большие экраны (от 1440px) */
@media (min-width: 1440px) {
  .tg-lead-widget {
    right: 32px;
    top: 32px;
  }

  .tg-lead-widget__button {
    padding: 9px 20px;
    height: 52px;
    min-height: 52px;
  }

  .tg-lead-widget__avatar {
    width: 36px;
    height: 36px;
  }

  .tg-lead-widget__button-label {
    font-size: 14px;
  }

  .tg-lead-widget__body {
    min-width: 340px;
    max-width: 420px;
    padding: 22px;
  }
}

/* Очень большие экраны (от 1920px) */
@media (min-width: 1920px) {
  .tg-lead-widget {
    right: 40px;
    top: 40px;
  }

  .tg-lead-widget__body {
    min-width: 360px;
    max-width: 440px;
    padding: 24px;
  }
}
