/* ============================================================
   VAIMAN EMBER LIGHT — Layout
   Header, sidebar, content, bottom tabs, responsive
   Depends on: ember-light.css + components.css
   ============================================================ */


/* ── Site Header (fixed top) ───────────────────────────────── */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(140%) blur(16px);
  backdrop-filter: saturate(140%) blur(16px);
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 8px;
  z-index: var(--z-sticky);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.site-logo-text {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.25rem;
  background: linear-gradient(135deg, var(--accent-ember) 0%, var(--accent-ember-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.site-logo-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-balance {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--accent-ember);
  padding: 6px 12px;
  background: rgba(199, 102, 25, 0.08);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.header-balance-icon {
  font-size: 1rem;
  line-height: 1;
}

.header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--bg-tertiary);
  cursor: pointer;
  transition: box-shadow var(--duration) var(--ease);
}

.header-avatar:hover {
  box-shadow: 0 0 0 2px var(--accent-ember);
}

.header-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}

.header-theme-toggle:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.header-notifications {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease);
}

.header-notifications:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.header-notifications svg {
  width: 20px;
  height: 20px;
}

.header-notifications-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--danger);
  color: var(--bg-tertiary);
  font-size: 0.625rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}

.header-menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease);
}

.header-menu-toggle:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.header-menu-toggle svg {
  width: 22px;
  height: 22px;
}

.header-menu-toggle:active {
  transform: scale(0.92);
}

/* Тоггл панели виден на ВСЕХ размерах: десктоп — сворачивает «рельс»,
   планшет/телефон — открывает выезжающую панель. */


/* ── Sidebar — выезжающая/сворачиваемая панель (модель KIE) ──── */

.site-sidebar {
  position: fixed;
  left: 0;
  top: var(--header-h);
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar-grad);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--sidebar-border);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  z-index: var(--z-modal);
  transition: width 0.26s var(--ease), transform 0.28s var(--ease);
}

/* ===== Десктоп (≥1024): закреплён слева, сворачивается в «рельс» ===== */
@media (min-width: 1024px) {
  .site-sidebar {
    z-index: var(--z-sticky);
    transform: none;
  }
  body.nav-collapsed .site-sidebar {
    width: var(--sidebar-w-rail);
  }
}

/* ===== Планшет/телефон (<1024): выезжает слева поверх контента ===== */
@media (max-width: 1023px) {
  .site-sidebar {
    width: var(--sidebar-w-drawer);
    transform: translateX(-100%);
    box-shadow: var(--shadow-3);
  }
  body.nav-open .site-sidebar {
    transform: translateX(0);
  }
}

/* Затемнение под выезжающей панелью.
   Начинается ПОД шапкой (top: header-h), чтобы тоггл и кнопки шапки оставались
   доступны при открытой панели, и чтобы не воевать по z-index с модалками. */
.nav-overlay {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 18, 28, 0.52);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  z-index: calc(var(--z-modal) - 1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.26s var(--ease);
}

@media (max-width: 1023px) {
  body.nav-open .nav-overlay {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (min-width: 1024px) {
  .nav-overlay { display: none; }
}

/* ── Свёрнутый «рельс» на десктопе: только иконки + подсказка при наведении ── */
@media (min-width: 1024px) {
  body.nav-collapsed .sidebar-nav {
    padding: 8px 10px;
    align-items: center;
  }
  body.nav-collapsed .sidebar-item {
    justify-content: center;
    padding: 10px;
    position: relative;
  }
  /* подпись прячем визуально, но как всплывающую подсказку справа */
  body.nav-collapsed .sidebar-item > span {
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
    padding: 7px 11px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-2);
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.16s var(--ease), transform 0.16s var(--ease);
    z-index: var(--z-tooltip);
  }
  body.nav-collapsed .sidebar-item:hover > span {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
  }
  body.nav-collapsed .sidebar-divider {
    margin: 10px 8px;
  }
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 8px;
  flex: 1;
}

.sidebar-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

.sidebar-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.sidebar-section-label {
  padding: 4px 16px 8px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease);
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-item:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.sidebar-item.active {
  background: rgba(199, 102, 25, 0.08);
  color: var(--text-primary);
  font-weight: 700;
}

.sidebar-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color var(--duration) var(--ease);
}

.sidebar-item.active .sidebar-icon {
  color: var(--accent-ember);
}

.sidebar-item:hover .sidebar-icon {
  color: var(--text-secondary);
}

.sidebar-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: rgba(199, 102, 25, 0.12);
  color: var(--accent-ember);
  font-size: 0.6875rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  margin-top: auto;
}

/* ============================================================
   EMBER LIGHT PREMIUM — Dashboard + Sidebar (8pt grid, gradients, cards)
   ============================================================ */

.sidebar-item {
  transition: background 0.15s var(--ease), color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.sidebar-item:hover {
  background: rgba(199, 102, 25, 0.07);
  color: var(--text-primary);
  box-shadow: inset 3px 0 0 rgba(199, 102, 25, 0.22);
}

.sidebar-item.active {
  background: rgba(199, 102, 25, 0.12);
  color: var(--text-primary);
  font-weight: 800;
  box-shadow: inset 4px 0 0 var(--accent-ember);
}

.sidebar-item.active .sidebar-icon {
  color: var(--accent-ember);
}

/* Тёмная тема: активный пункт получает тёплое ember-свечение (как active-таб в TG) */
[data-theme="dark"] .sidebar-item.active {
  background: linear-gradient(90deg, rgba(232, 151, 101, 0.16), rgba(232, 151, 101, 0.03));
}

#page-content .section {
  margin-bottom: 24px;
}

#page-content .section-header {
  margin-bottom: 16px;
}

#page-content .section-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

#recent-generations .dash-recent-grid {
  gap: 12px;
}

#recent-generations .dash-recent-item {
  border: 1px solid rgba(199, 102, 25, 0.20);
  box-shadow: var(--shadow-1);
  background: var(--bg-tertiary);
}

#recent-generations .dash-recent-item:hover {
  border-color: rgba(199, 102, 25, 0.32);
  box-shadow: 0 12px 28px -10px rgba(26, 18, 16, 0.16);
  transform: translateY(-2px);
}

#recent-generations .dash-recent-skeleton {
  background: var(--bg-secondary);
  border: 1px solid rgba(199, 102, 25, 0.12);
}

#recent-generations .dash-empty {
  border: 1px solid rgba(199, 102, 25, 0.18);
  box-shadow: 0 4px 14px -6px rgba(26, 18, 16, 0.10);
}


/* ── Mobile Bottom Tabs (< 1024px) ─────────────────────────── */

/* Легаси нижняя панель: навигация переехала в левую выезжающую панель (как KIE).
   Скрыта на всех экранах; элемент остаётся в DOM — иммерсивные страницы-генераторы
   ссылаются на #mobile-tabs, когда прячут оболочку. */
.mobile-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-light);
  display: none;
  z-index: var(--z-sticky);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 0;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: color var(--duration) var(--ease);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.mobile-tab:hover {
  color: var(--text-secondary);
}

.mobile-tab.active {
  color: var(--accent-ember);
}

.mobile-tab-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.mobile-tab-icon svg,
.mobile-tab-icon img {
  width: 24px;
  height: 24px;
}

.mobile-tab-label {
  font-family: 'Manrope', sans-serif;
  /* 7 табов: на узких экранах подпись «Инфографика» шире своей доли —
     плавно ужимаем шрифт вместо переноса/обрезания */
  font-size: clamp(0.5rem, 2.4vw, 0.625rem);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}


/* ── Content Area ──────────────────────────────────────────── */

.site-content {
  margin-top: var(--header-h);
  padding: 14px;
  min-height: calc(100dvh - var(--header-h));
  padding-bottom: 24px;
  /* контент по центру при любой ширине сайдбара/рельса */
  transition: margin-left 0.26s var(--ease);
}

@media (min-width: 1024px) {
  .site-content {
    margin-left: var(--sidebar-w);
    padding: 24px;
  }
  body.nav-collapsed .site-content {
    margin-left: var(--sidebar-w-rail);
  }
}

.page-container {
  max-width: 1200px;
  margin: 0 auto;
}

/* Большие экраны: контейнер растёт, контент занимает ширину (не островок). Шрифты — корневой rem-clamp. */
@media (min-width: 1600px) {
  .page-container {
    max-width: 1400px;
  }
}

@media (min-width: 2200px) {
  .page-container {
    max-width: 1640px;
  }
}


/* ── Responsive Breakpoints ────────────────────────────────── */

/* Compact mobile (< 600px) */
@media (max-width: 599px) {
  .hide-mobile {
    display: none;
  }

  .site-content {
    padding: 12px;
    padding-bottom: 24px;
  }
}

/* Tablet (600 - 1023px) */
@media (min-width: 600px) and (max-width: 1023px) {
  .hide-tablet {
    display: none;
  }

  .site-content {
    padding: 18px;
    padding-bottom: 24px;
  }
}

/* Desktop (>= 1024px) */
@media (min-width: 1024px) {
  .hide-desktop {
    display: none;
  }
}

/* Show only on specific breakpoints */
.show-mobile {
  display: none;
}

@media (max-width: 599px) {
  .show-mobile {
    display: block;
  }
}

.show-tablet {
  display: none;
}

@media (min-width: 600px) and (max-width: 1023px) {
  .show-tablet {
    display: block;
  }
}

.show-desktop {
  display: none;
}

@media (min-width: 1024px) {
  .show-desktop {
    display: block;
  }
}


/* ── Page Transitions ──────────────────────────────────────── */

.page-enter {
  opacity: 0;
  transform: translateY(8px);
}

.page-enter-active {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 0.2s var(--ease),
    transform 0.2s var(--ease);
}

.page-exit {
  opacity: 1;
  transform: translateY(0);
}

.page-exit-active {
  opacity: 0;
  transform: translateY(-4px);
  transition:
    opacity 0.15s var(--ease),
    transform 0.15s var(--ease);
}


/* ── Empty State ───────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  color: var(--text-muted);
  margin-bottom: 16px;
  opacity: 0.6;
}

.empty-state-icon svg,
.empty-state-icon img {
  width: 64px;
  height: 64px;
}

.empty-state-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 320px;
  line-height: 1.5;
}

.empty-state-action {
  margin-top: 20px;
}


/* ── Page Header ───────────────────────────────────────────── */

.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--text-primary);
  line-height: 1.2;
}

@media (min-width: 1024px) {
  .page-title {
    font-size: 1.75rem;
  }
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

@media (min-width: 600px) {
  .page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
  }

  .page-header-actions {
    margin-top: 0;
    flex-shrink: 0;
  }
}


/* ── Section ───────────────────────────────────────────────── */

.section {
  margin-bottom: 32px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text-primary);
}

.section-link {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent-ember);
  text-decoration: none;
  transition: color var(--duration) var(--ease);
}

.section-link:hover {
  color: var(--accent-ember-dark);
}


/* ── Notifications Panel (slide from right) ───────────────── */

.notifications-overlay {
  position: fixed;
  inset: 0;
  background: rgba(42, 24, 16, 0.25);
  z-index: var(--z-modal-backdrop);
  opacity: 0;
  transition: opacity 0.25s var(--ease);
  pointer-events: none;
}

.notifications-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.notifications-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 100vw;
  background: var(--bg-tertiary);
  border-left: 1px solid var(--border-light);
  box-shadow: var(--shadow-3);
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s var(--ease);
  will-change: transform;
}

.notifications-panel.open {
  transform: translateX(0);
}

.notifications-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.notifications-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

.notif-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.notif-item {
  display: flex;
  gap: 12px;
  padding: 14px 12px;
  border-radius: var(--radius-md);
  transition: background var(--duration) var(--ease);
  cursor: pointer;
}

.notif-item:hover {
  background: var(--bg-secondary);
}

.notif-item.unread {
  background: rgba(199, 102, 25, 0.05);
}

.notif-item.unread::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-ember);
  flex-shrink: 0;
  margin-top: 6px;
}

.notif-body {
  flex: 1;
  min-width: 0;
}

.notif-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.notif-text {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.notif-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

@media (max-width: 599px) {
  .notifications-panel {
    width: 100%;
  }
}


/* ── Toast Notifications ──────────────────────────────────── */
/* ЕДИНАЯ система тостов живёт в components.css (низ, по центру).
   Здесь был ВТОРОЙ конкурирующий блок (top:72px/right:20px + mobile left:16px):
   свойства двух систем смешивались и на телефоне тост улетал за левый край
   (top из этого файла + translateX(-50%) из components). Удалён 2026-06-09. */


/* ── Loading Skeleton ─────────────────────────────────────── */

.page-loading {
  max-width: 800px;
  animation: skeleton-fade-in 0.3s var(--ease);
}

.skeleton {
  background: linear-gradient(90deg,
    var(--bg-secondary) 25%,
    rgba(199, 102, 25, 0.06) 50%,
    var(--bg-secondary) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.skeleton-hero {
  height: 180px;
  margin-bottom: 20px;
  border-radius: var(--radius-lg);
}

.skeleton-title {
  height: 32px;
  width: 45%;
  margin-bottom: 16px;
}

.skeleton-row {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.skeleton-card {
  flex: 1;
  height: 140px;
  border-radius: var(--radius-lg);
}

.skeleton-text {
  height: 16px;
  width: 80%;
  margin-bottom: 12px;
}

.skeleton-text-short {
  width: 55%;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes skeleton-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}


/* ── Avatar (used in header + elsewhere) ──────────────────── */

.avatar {
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-ember-light), var(--accent-ember));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sm {
  width: 32px;
  height: 32px;
}

.avatar-md {
  width: 40px;
  height: 40px;
}

.avatar-lg {
  width: 56px;
  height: 56px;
}

/* ── Badge Count (header notifications) ───────────────────── */

.badge-count {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--danger);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
}

/* ── Sidebar Divider ──────────────────────────────────────── */

.sidebar-divider {
  height: 1px;
  background: var(--border-light);
  margin: 10px 16px;
}

/* ── Balance Icon ─────────────────────────────────────────── */

.balance-icon {
  color: var(--accent-ember);
  font-size: 1rem;
  margin-left: 2px;
}
