/* css/components/modals.css — Всплывающие окна: общая основа (затемнение, окно, шапка, тело), окно «About this tool», окно статистики.
   Порядок подключения всех стилей задан в layout/head.php — он важен. */
/* ===== КНОПКА ===== */
.puter-stats-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid rgba(124, 92, 255, 0.25);
  background: rgba(124, 92, 255, 0.08);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin: 8px 0;
  letter-spacing: 0.02em;
}

.puter-stats-btn:hover {
  border-color: rgba(124, 92, 255, 0.5);
  color: #ffffff;
  background: rgba(124, 92, 255, 0.15);
  box-shadow: 0 0 14px rgba(124, 92, 255, 0.15);
}

/* Обёртка вокруг Sign in / Sign Out / Refresh / Stats —
   заменяет инлайновый style="display:flex; flex-wrap:wrap" в разметке.
   3 колонки, а не 2 — после удаления Model Comparison видимый набор кнопок
   после входа (Sign Out/Refresh/Stats) стал ровно 3, 2 колонки оставляли
   пустую ячейку в неполной второй строке. */
.puter-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 4px;
}

.puter-actions .puter-stats-btn {
  justify-content: center;
  margin: 0;
  width: 100%;
}

/* ===== ОВЕРЛЕЙ ===== */
.pstats-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: pstats-fade-in 0.2s ease;
}

@keyframes pstats-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ===== МОДАЛЬНОЕ ОКНО ===== */
.pstats-modal {
  width: 100%;
  max-width: 540px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  border: 1px solid rgba(124, 92, 255, 0.2);
  background: linear-gradient(180deg, rgba(20, 28, 45, 0.99), rgba(10, 16, 28, 0.99));
  box-shadow:
    0 0 60px rgba(124, 92, 255, 0.15),
    0 0 120px rgba(0, 229, 255, 0.06);
  animation: pstats-slide-up 0.25s ease;
  overflow: hidden;
}

/* Модификатор для confirm-модалки (common/ui/confirm-modal.js) — короткий
   текст + пара кнопок, полноразмерный .pstats-modal (540px) для этого
   слишком широкий. */
.pstats-modal-sm {
  max-width: 420px;
}

/* Кнопки Cancel/Confirm confirm-модалки — переиспользует .puter-stats-btn/
   .puter-stats-btn-danger (те же классы, что Delete-кнопки в Custom
   Platforms/CSV Presets и т.п.), только выравнивание вправо и отступ от
   текста над ними. */
.confirm-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* pre-line — многострочные подтверждения (например HISTORY_ENABLE_CONFIRM в
   credit-panel.js) разделяют абзацы через \n\n в JS-строке; обычный
   white-space схлопнул бы все переносы в один пробел, как в единственной
   строке. */
.confirm-modal-message {
  white-space: pre-line;
}

/* Модификатор для "больших" модалок (Custom Platforms, Categories
   (Universal), Custom CSV Presets, Buy More Credits) —
   80vh даёт ~10vh пустого пространства сверху/снизу за счёт центрирования
   .pstats-overlay (align-items:center); 90vh сокращает этот зазор вдвое,
   не трогая маленькие модалки (подтверждения, токен) с базовым .pstats-modal.
   height (не только max-height) — иначе модалки с коротким контентом
   (например, Categories (Universal)) сжимаются по контенту и визуально
   ниже соседних больших модалок; .pstats-body (flex:1, см. ниже) сам
   заполняет освободившееся место и скроллится, если контента больше. */
.pstats-modal-lg {
  height: 90vh;
  max-height: 90vh;
}

@keyframes pstats-slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ===== ШАПКА ===== */
.pstats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid rgba(124, 92, 255, 0.12);
  flex-shrink: 0;
}

.pstats-title {
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.01em;
}

.pstats-subtitle {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pstats-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(124, 92, 255, 0.15);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.pstats-close:hover {
  background: rgba(255, 92, 122, 0.1);
  border-color: rgba(255, 92, 122, 0.3);
  color: #ff5c7a;
}

/* ===== ТЕЛО ===== */
.pstats-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0; /* без этого flex-item по умолчанию не сжимается меньше контента — на .pstats-modal-lg (фикс. height) распирало бы модалку вместо внутреннего скролла */
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.pstats-loading {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  padding: 20px 0;
}

/* ===== "About this tool" — pages/modal/modal-about-tool.php =====
   Переиспользует .pstats-overlay/.pstats-modal/.pstats-header/.pstats-body
   (тот же паттерн, что Usage Statistics) + .badge из
   template.css для списков форматов/платформ. Каждая из 4 карточек-секций
   красится своим акцентом — тот же приём "цветная рамка + подсвеченный
   фон", что у .export-btn--folder/--zip/--csv. */
.about-tool-intro {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  text-align: left;
}

.about-tool-card {
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 14px 16px;
}

.about-tool-card-heading {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 10px;
}

.about-tool-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  text-align: left;
}

.about-tool-notes {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  text-align: left;
}

.about-tool-card--cyan {
  border-color: rgba(0, 229, 255, 0.25);
  background: rgba(0, 229, 255, 0.05);
}
.about-tool-card--cyan .about-tool-card-heading { color: var(--cyan); }

.about-tool-card--purple {
  border-color: rgba(124, 92, 255, 0.25);
  background: rgba(124, 92, 255, 0.05);
}
.about-tool-card--purple .about-tool-card-heading { color: #a090ff; }

.about-tool-card--success {
  border-color: rgba(0, 229, 160, 0.25);
  background: rgba(0, 229, 160, 0.05);
}
.about-tool-card--success .about-tool-card-heading { color: var(--success); }

.about-tool-card--amber {
  border-color: rgba(255, 176, 32, 0.3);
  background: rgba(255, 176, 32, 0.06);
}
.about-tool-card--amber .about-tool-card-heading { color: #ffb020; }

/* ===== СЕКЦИИ ===== */
.pstats-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pstats-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ===== ОБЗОР ===== */
.pstats-overview {
  display: flex;
  align-items: center;
  gap: 24px;
}

.pstats-big-num {
  font-size: 42px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  min-width: 90px;
}

.pstats-big-label {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 4px;
}

.pstats-overview-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pstats-overview-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

.pstats-overview-row span:last-child {
  font-weight: 500;
  color: #ffffff;
}

/* Главный прогресс-бар */
.pstats-main-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

.pstats-main-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
  box-shadow: 0 0 10px currentColor;
}

/* ===== МОДЕЛИ ===== */
.pstats-models {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pstats-model-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pstats-model-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pstats-model-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #e0e6f0;
  font-family: monospace;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pstats-provider-icon {
  color: var(--purple);
  font-size: 14px;
  flex-shrink: 0;
}

.pstats-model-meta {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.pstats-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(124, 92, 255, 0.15);
  color: #a090ff;
  border: 1px solid rgba(124, 92, 255, 0.2);
  white-space: nowrap;
}

.pstats-model-stats {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 2px;
}

.pstats-model-stats span:last-child {
  color: #00e5a0;
  font-weight: 500;
}

.pstats-footer{font-size: 12px;}


#backToTopBtn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(0, 229, 160, 0.35);
  background: rgba(20, 20, 24, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #00e5a0;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  z-index: 999;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease, background 0.2s ease, border-color 0.2s ease;
}

#backToTopBtn.visible {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

#backToTopBtn:hover {
  background: rgba(0, 229, 160, 0.12);
  border-color: #00e5a0;
}

#backToTopBtn svg {
  width: 20px;
  height: 20px;
  display: block;
}

