/* === Кастомные стили поверх Tailwind === */

/* --- Скроллбары (Telegram-стиль) --- */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #2b5278;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #3a6a9a;
}
/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: #2b5278 transparent;
}

/* --- Плавные переходы --- */
.transition-fast {
  transition: all 0.15s ease;
}

/* --- Анимация: появление (fadeIn) --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-fade-in {
  animation: fadeIn 0.2s ease forwards;
}

/* --- Анимация: вращение (spin) --- */
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Анимация: тряска при ошибке (shake) --- */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}
.animate-shake {
  animation: shake 0.3s ease;
}

/* --- Анимация: typing-dots (три точки «печатает») --- */
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-4px); }
}
.typing-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #8b9ba6;
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}
.typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

/* --- Анимация: toast (slide-up + fade) --- */
@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(16px); }
}
.animate-toast-in {
  animation: toastIn 0.2s ease-out forwards;
}
.animate-toast-out {
  animation: toastOut 0.15s ease-in forwards;
}

/* --- Анимация: модалка (overlay fade + content scale) --- */
@keyframes modalOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modalOverlayOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}
@keyframes modalContentIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes modalContentOut {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.95); }
}
.animate-modal-overlay-in {
  animation: modalOverlayIn 0.2s ease-out forwards;
}
.animate-modal-overlay-out {
  animation: modalOverlayOut 0.15s ease-in forwards;
}
.animate-modal-content-in {
  animation: modalContentIn 0.2s ease-out forwards;
}
.animate-modal-content-out {
  animation: modalContentOut 0.15s ease-in forwards;
}

/* --- Анимация: slide-in правой панели --- */
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
@keyframes slideOutRight {
  from { transform: translateX(0); }
  to   { transform: translateX(100%); }
}
.animate-slide-in-right {
  animation: slideInRight 0.25s ease-out forwards;
}
.animate-slide-out-right {
  animation: slideOutRight 0.2s ease-in forwards;
}

/* --- Анимация: новое сообщение (снизу) --- */
@keyframes messageIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-message-in {
  animation: messageIn 0.2s ease forwards;
}

/* --- Spinner загрузки --- */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid #2b5278;
  border-top-color: #4ea4f6;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

/* --- Код верификации — крупные цифры --- */
.code-input {
  letter-spacing: 0.5em;
  font-size: 1.75rem;
  text-align: center;
  font-family: ui-monospace, monospace;
}

/* --- Скрытие скроллбара при необходимости --- */
.hide-scrollbar::-webkit-scrollbar {
  display: none;
}
.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* === Floating Label Input (Telegram-стиль) === */

/* Обёртка инпута */
.input-group {
  position: relative;
  width: 100%;
}

/* Сам инпут */
.input-group .form-control {
  width: 100%;
  height: 3.375rem; /* 54px */
  padding: 1.125rem 1.1875rem 0.375rem;
  border: 1.5px solid var(--tg-border, #1c2936);
  border-radius: 0.75rem; /* 12px */
  font-size: 1rem;
  line-height: 1.25rem;
  color: var(--tg-text, #f5f5f5);
  background-color: transparent;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  caret-color: var(--tg-link, #4ea4f6);
  -webkit-appearance: none;
}

.input-group .form-control::placeholder {
  color: transparent;
}

.input-group .form-control:hover {
  border-color: var(--tg-link, #4ea4f6);
}

.input-group .form-control:focus {
  border-color: var(--tg-link, #4ea4f6);
  box-shadow: inset 0 0 0 0.5px var(--tg-link, #4ea4f6);
}

/* Плавающая метка */
.input-group label {
  pointer-events: none;
  cursor: text;
  position: absolute;
  top: 1rem;
  left: 1.125rem;
  transform-origin: left center;
  font-size: 1rem;
  font-weight: 400;
  color: var(--tg-muted, #8b9ba6);
  white-space: nowrap;
  background-color: var(--label-bg, transparent);
  padding: 0 0.25rem;
  transition: transform 0.15s ease-out, color 0.15s ease-out, font-size 0.15s ease-out;
}

/* Метка поднимается при фокусе или наличии текста (.has-value) */
.input-group .form-control:focus + label,
.input-group.has-value label {
  transform: translateY(-1.6rem) scale(0.75);
  color: var(--tg-link, #4ea4f6);
  background-color: var(--label-bg, var(--tg-bg, #17212b));
  padding: 0 0.3125rem;
}

/* Когда есть значение, но нет фокуса — метка наверху, но серая */
.input-group.has-value .form-control:not(:focus) + label {
  color: var(--tg-muted, #8b9ba6);
}

/* Ошибка */
.input-group.has-error .form-control {
  border-color: var(--tg-danger, #e53935);
  box-shadow: inset 0 0 0 0.5px var(--tg-danger, #e53935);
}
.input-group.has-error label,
.input-group.has-error .form-control:focus + label {
  color: var(--tg-danger, #e53935);
}

/* Текст ошибки под инпутом */
.input-group .error-text {
  font-size: 0.75rem;
  color: var(--tg-danger, #e53935);
  margin-top: 0.25rem;
  padding-left: 1.125rem;
}

/* Специальный вариант для кода верификации */
.input-group.code-variant .form-control {
  letter-spacing: 0.5em;
  font-size: 1.75rem;
  text-align: center;
  font-family: ui-monospace, monospace;
  padding: 1rem 1.1875rem 0.375rem;
  height: 3.75rem;
}

/* Специальный вариант для пароля */
.input-group .form-control[type="password"] {
  letter-spacing: 0.05em;
}

/* === Кнопки (Telegram-стиль) === */

.tg-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 3.375rem; /* 54px */
  border: none;
  border-radius: 0.75rem; /* 12px */
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, opacity 0.2s;
  -webkit-appearance: none;
  user-select: none;
}

.tg-btn-primary {
  color: #fff;
  background-color: var(--tg-link, #4ea4f6);
}
.tg-btn-primary:hover {
  filter: brightness(1.1);
}
.tg-btn-primary:active {
  filter: brightness(0.95);
}
.tg-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

.tg-btn-text {
  color: var(--tg-link, #4ea4f6);
  background: transparent;
  font-weight: 500;
}
.tg-btn-text:hover {
  background-color: var(--tg-hover, #202b36);
}

/* === Auth-специфичные стили === */

.auth-container {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--tg-sidebar, #0e1621);
  padding: 2rem 1rem;
}

.auth-form {
  width: 100%;
  max-width: 26rem; /* 416px */
  margin: 0 auto;
  text-align: center;
}

.auth-logo {
  width: 8rem; /* 128px */
  height: 8rem;
  margin: 0 auto 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--tg-link, #4ea4f6);
  position: relative;
  overflow: hidden;
}

@media (min-width: 600px) {
  .auth-logo {
    width: 10rem; /* 160px */
    height: 10rem;
    margin-bottom: 2.5rem;
  }
  .auth-form h1 {
    font-size: 2rem !important;
  }
  .auth-form .auth-note {
    font-size: 1rem !important;
    margin-bottom: 3rem !important;
  }
}

.auth-form h1 {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--tg-text, #f5f5f5);
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.auth-form .auth-note {
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--tg-muted, #8b9ba6);
  margin-bottom: 2.5rem;
}

.auth-form form,
.auth-form .auth-fields {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.auth-form .tg-btn {
  margin-top: 0.5rem;
}

/* Иллюстрация для экрана кода (SVG вместо стикера) */
.auth-illustration {
  width: 8rem;
  height: 8rem;
  margin: 0 auto 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 600px) {
  .auth-illustration {
    width: 10rem;
    height: 10rem;
    margin-bottom: 2.5rem;
  }
}

/* Номер/контакт с кнопкой редактирования */
.auth-contact-display {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--tg-text, #f5f5f5);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.auth-contact-edit {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  color: var(--tg-muted, #8b9ba6);
  transition: background-color 0.15s, color 0.15s;
}
.auth-contact-edit:hover {
  background-color: var(--tg-hover, #202b36);
  color: var(--tg-text, #f5f5f5);
}

/* Таймер повторной отправки */
.auth-resend {
  font-size: 0.875rem;
  margin-top: 1.25rem;
  text-align: center;
  color: var(--tg-muted, #8b9ba6);
  transition: color 0.15s;
}
.auth-resend.clickable {
  color: var(--tg-link, #4ea4f6);
  cursor: pointer;
}
.auth-resend.clickable:hover {
  text-decoration: underline;
}

/* --- Мобильная адаптация --- */
@media (max-width: 768px) {
  #sidebar {
    width: 100% !important;
    position: absolute;
    z-index: 10;
  }
  #sidebar.chat-open {
    display: none !important;
  }
  #message-area {
    width: 100% !important;
  }
  .mobile-back-btn {
    display: block !important;
  }
}
@media (min-width: 769px) {
  .mobile-back-btn {
    display: none !important;
  }
}
