/* app.css — базовые стили каркаса (вне Tailwind-сборки).
   Использует CSS-токены из style.css (:root / .dark). Подключается после style.css. */

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html {
  scroll-behavior: smooth;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection { background: #000; color: #fff; }
.dark ::selection { background: #fff; color: #000; }

/* Мгновенная смена темы: на время переключения глушим все переходы/анимации,
   чтобы тяжёлые blur/градиентные слои не кроссфейдили и не подтормаживали. */
html.theme-anim-off,
html.theme-anim-off *,
html.theme-anim-off *::before,
html.theme-anim-off *::after {
  transition: none !important;
  animation-duration: 0s !important;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* fadeInUp для карточек */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card-appear { opacity: 0; animation: fadeInUp 0.45s ease forwards; }

/* Прогресс-бар трафика */
.traffic-bar-green  { background: linear-gradient(to right, #10b981, #059669); }
.traffic-bar-yellow { background: linear-gradient(to right, #f59e0b, #d97706); }
.traffic-bar-red    { background: linear-gradient(to right, #ef4444, #dc2626); }

/* Skeleton shimmer для Telegram-виджета (auth) */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
.tg-skeleton {
  width: 220px; height: 44px; border-radius: 12px;
  background: linear-gradient(90deg, rgba(0,0,0,.06) 25%, rgba(0,0,0,.11) 50%, rgba(0,0,0,.06) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
}
.dark .tg-skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,.06) 25%, rgba(255,255,255,.11) 50%, rgba(255,255,255,.06) 75%);
  background-size: 800px 100%;
}

/* Yandex SmartCaptcha (auth) */
.yandex-captcha-wrap { color-scheme: light; min-height: 100px; }
.dark .yandex-captcha-wrap { color-scheme: dark; }
.dark .yandex-captcha-wrap iframe {
  filter: invert(0.93) hue-rotate(180deg) brightness(0.96);
  border-radius: 8px;
}

/* Кнопка переключения темы */
.theme-btn {
  position: relative;
  width: 2.25rem; height: 2.25rem;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  color: var(--text-2);
  transition: background .2s ease, border-color .2s ease, color .2s ease, transform .15s ease;
  cursor: pointer;
}
.theme-btn:hover { background: var(--surface-3); color: var(--text); }
.theme-btn:active { transform: scale(0.9); }
.theme-btn svg { transition: transform 0.35s ease, opacity 0.25s ease; }
.theme-btn:active svg { transform: rotate(25deg); }

/* Toast notifications */
#toast-container {
  position: fixed;
  z-index: 9999;
  left: max(0.75rem, env(safe-area-inset-left));
  right: max(0.75rem, env(safe-area-inset-right));
  bottom: calc(1rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  pointer-events: none;
  max-width: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: #111;
  color: #fff;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 1rem;
  padding: 0.65rem 0.9rem;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.45;
  box-shadow: 0 8px 28px rgba(0,0,0,.22);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 240ms ease, transform 240ms ease;
  pointer-events: auto;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.toast-icon {
  flex: 0 0 auto;
  line-height: 1.45;
  margin-top: 0.05em;
}
.toast-text {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
}
.toast.show { opacity: 1; transform: translateY(0); }
html:not(.dark) .toast {
  background: #111;
  color: #fff;
  border-color: rgba(0,0,0,.08);
  box-shadow: 0 10px 32px rgba(0,0,0,.16);
}
.dark .toast {
  background: #1c1c1e;
  border-color: rgba(255,255,255,.1);
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
}
@media (min-width: 640px) {
  #toast-container {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(26rem, calc(100vw - 2rem));
    align-items: center;
  }
  .toast {
    width: auto;
    max-width: 100%;
    border-radius: 999px;
    padding: 0.55rem 1rem;
  }
}

/* htmx page transition */
#main-content { opacity: 1; transition: opacity 180ms ease; }
#main-content.htmx-swapping { opacity: 0; }
#main-content.htmx-settling { opacity: 1; }

/* Прогресс-бар htmx вверху */
#htmx-bar {
  position: fixed; top: 0; left: 0; width: 0; height: 2px;
  background: var(--text); z-index: 9999;
  transition: width .3s ease, opacity .3s ease; opacity: 0;
}
#htmx-bar.htmx-request { opacity: 1; }

/* Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.18); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.32); }
.dark ::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); }
.dark ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.28); }

/* Плавающая шапка: прячется при скролле вниз, возвращается при скролле вверх.
   --app-header-offset используют залипающие элементы (моб. таб-бар кабинета). */
:root { --app-header-offset: calc(3.5rem + env(safe-area-inset-top)); }
#app-nav { transition: transform .35s ease, opacity .3s ease; will-change: transform; }
#app-nav.app-nav-hidden { transform: translateY(-200%); opacity: 0; pointer-events: none; }
