/* ═══════════════════════════════════════════════════════════════════════
   LAYOUT — скелет приложения
   Сайдбар + шапка + контентная зона. Используется на всех страницах кроме
   логина/регистрации/лендинга.
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── ОБЁРТКА ВСЕГО ПРИЛОЖЕНИЯ ────────────────────────────────────────── */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--header-height) 1fr;
  grid-template-areas:
    "sidebar header"
    "sidebar main";
  min-height: 100vh;
}


/* ─── САЙДБАР ─────────────────────────────────────────────────────────── */

.sidebar {
  grid-area: sidebar;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: var(--space-4) var(--space-3);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

/* лого блок */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-6);
}

.sidebar-brand-logo {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--weight-bold);
  font-size: var(--font-lg);
  flex-shrink: 0;
}

.sidebar-brand-name {
  font-size: var(--font-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.sidebar-brand-tag {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  margin-top: 1px;
}

/* секции навигации */
.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: var(--space-5);
}

.sidebar-section-title {
  font-size: var(--font-xs);
  font-weight: var(--weight-medium);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-1);
}

/* пункт навигации */
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  height: 36px;
  font-size: var(--font-md);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  cursor: pointer;
  user-select: none;
  position: relative;
}

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

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-item-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-item-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

.nav-item-label {
  flex: 1;
}

/* счётчик справа */
.nav-item-badge {
  font-size: var(--font-xs);
  font-weight: var(--weight-semibold);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  min-width: 20px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-item.active .nav-item-badge {
  background: var(--accent);
  color: var(--accent-text);
}

/* блок пользователя внизу сайдбара */
.sidebar-footer {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.sidebar-user:hover {
  background: var(--bg-elevated);
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: var(--font-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ─── ШАПКА ───────────────────────────────────────────────────────────── */

.header {
  grid-area: header;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-8);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.header-title {
  font-size: var(--font-xl);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}


/* ─── КОНТЕНТНАЯ ЗОНА ─────────────────────────────────────────────────── */

.main {
  grid-area: main;
  padding: var(--space-8);
  overflow-y: auto;
}

.main-inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

/* секция страницы */
.section {
  margin-bottom: var(--space-8);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.section-title {
  font-size: var(--font-xl);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.section-subtitle {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}


/* ─── СЕТКА МЕТРИК (4-5 карточек в ряд) ───────────────────────────────── */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}


/* ─── PAGE: страницы аутентификации (центрированные) ──────────────────── */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: var(--bg-base);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.auth-brand-logo {
  width: 48px;
  height: 48px;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--weight-bold);
  font-size: var(--font-xl);
}

.auth-title {
  font-size: var(--font-2xl);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  text-align: center;
  margin-bottom: var(--space-1);
}

.auth-subtitle {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: var(--space-6);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.auth-footer {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-size: var(--font-sm);
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--accent);
  font-weight: var(--weight-medium);
}

.auth-footer a:hover {
  text-decoration: underline;
}


/* ─── СОСТОЯНИЕ "ПУСТО" / "ЗАГРУЗКА" ──────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  text-align: center;
  gap: var(--space-3);
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
}

.empty-state-title {
  font-size: var(--font-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.empty-state-text {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  max-width: 360px;
}

/* спиннер для загрузки */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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


/* ─── АДАПТИВ (мобильные — на потом, для лендинга/MVP не требуется) ───── */

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main";
  }
  .sidebar { display: none; }
  .header { padding: 0 var(--space-4); }
  .main { padding: var(--space-4); }
}
