/* /opt/skynet-portal/app/static/css/layout.css */
/* v0.1.0 — раскладка SKYNET PORTAL: shell, sidebar, topbar, адаптив */
/* 30.05.2026: премиум layout поверх tokens.css + components.css */

/* =====================================================================
   1. SHELL — общая раскладка (sidebar + контент)
   ===================================================================== */
.app-body {
  min-height: 100vh;
  min-height: 100dvh;
}

/* Контейнер контентной части (справа от сайдбара) */
.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-base);
}

/* На десктопе контент сдвинут вправо на ширину сайдбара */
@media (min-width: 1024px) {
  .app-shell {
    margin-left: var(--sidebar-width);
  }
}

/* Основная рабочая область */
.app-main {
  flex: 1;
  padding: var(--sp-6);
  position: relative;
  z-index: var(--z-base);
}

@media (min-width: 1536px) {
  .app-main {
    padding: var(--sp-8) var(--sp-10);
  }
}

/* =====================================================================
   2. SIDEBAR
   ===================================================================== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--bg-canvas);
  border-right: var(--border-thin) solid var(--border-default);
  z-index: var(--z-sidebar);
  transition: transform var(--transition-base);
}

/* На мобильном сайдбар спрятан слева за экраном */
@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }
  .sidebar.is-open {
    transform: translateX(0);
  }
}

/* --- Шапка сайдбара --- */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-height);
  padding: 0 var(--sp-5);
  border-bottom: var(--border-thin) solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--gradient-accent);
  box-shadow: 0 4px 14px var(--accent-glow);
  flex-shrink: 0;
}
.sidebar-logo svg {
  width: 20px;
  height: 20px;
  color: #fff;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.sidebar-brand-name {
  font-size: var(--fs-md);
  font-weight: var(--fw-extrabold);
  letter-spacing: 0.06em;
  color: var(--text-primary);
}
.sidebar-brand-sub {
  font-size: 0.65rem;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.22em;
  color: var(--text-tertiary);
}

.sidebar-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  transition: all var(--transition-fast);
}
.sidebar-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
@media (max-width: 1023px) {
  .sidebar-close { display: flex; }
}

/* --- Навигация --- */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-group-label {
  font-size: 0.68rem;
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-1);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  transition: all var(--transition-fast);
  position: relative;
}
.sidebar-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Активный пункт — акцентный фон + цветная полоса слева */
.sidebar-link.is-active {
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: var(--fw-semibold);
}
.sidebar-link.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--gradient-accent);
  border-radius: var(--radius-full);
}
.sidebar-link.is-active .sidebar-icon {
  color: var(--accent);
}

/* Отключённый пункт (модуль ещё не готов) */
.sidebar-link.is-disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.sidebar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text-tertiary);
  transition: color var(--transition-fast);
}
.sidebar-icon svg {
  width: 19px;
  height: 19px;
}
.sidebar-link:hover .sidebar-icon {
  color: var(--text-secondary);
}

.sidebar-text {
  flex: 1;
}

/* Бейдж "soon" на неготовых пунктах */
.sidebar-badge-soon {
  font-size: 0.6rem;
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-3);
  color: var(--text-muted);
}

/* --- Подвал сайдбара --- */
.sidebar-footer {
  padding: var(--sp-4) var(--sp-5);
  border-top: var(--border-thin) solid var(--border-subtle);
  flex-shrink: 0;
}
.sidebar-version {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* --- Затемнение под сайдбаром (мобильный) --- */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-sidebar) - 1);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}
.sidebar-backdrop.is-visible {
  opacity: 1;
  visibility: visible;
}
@media (min-width: 1024px) {
  .sidebar-backdrop { display: none; }
}

/* =====================================================================
   3. TOPBAR
   ===================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: 0 var(--sp-6);
  background: color-mix(in srgb, var(--bg-canvas) 80%, transparent);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: var(--border-thin) solid var(--border-default);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex: 1;
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
}

/* Бургер */
.topbar-burger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}
.topbar-burger:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
@media (max-width: 1023px) {
  .topbar-burger { display: flex; }
}

/* Поиск */
.topbar-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 420px;
}
.topbar-search-icon {
  position: absolute;
  left: var(--sp-3);
  display: flex;
  align-items: center;
  color: var(--text-muted);
  pointer-events: none;
}
.topbar-search-input {
  width: 100%;
  height: 40px;
  padding: 0 var(--sp-10) 0 calc(var(--sp-3) + 26px);
  font-size: var(--fs-sm);
  color: var(--text-primary);
  background: var(--bg-input);
  border: var(--border-thin) solid var(--border-default);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
}
.topbar-search-input::placeholder { color: var(--text-muted); }
.topbar-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.topbar-search-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.topbar-search-kbd {
  position: absolute;
  right: var(--sp-3);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-surface-3);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: var(--border-thin) solid var(--border-subtle);
}
@media (max-width: 639px) {
  .topbar-search-kbd { display: none; }
}

/* Статус + часы */
.topbar-status {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-surface-2);
  border: var(--border-thin) solid var(--border-default);
  border-radius: var(--radius-md);
}
.topbar-status-text {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--success-text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.topbar-clock {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}
@media (max-width: 767px) {
  .topbar-status { display: none; }
}

/* Разделитель */
.topbar-divider {
  width: var(--border-thin);
  height: 24px;
  background: var(--border-default);
  margin: 0 var(--sp-1);
}
@media (max-width: 767px) {
  .topbar-divider { display: none; }
}

/* Кнопки-действия (тема, язык) */
.topbar-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 40px;
  min-width: 40px;
  padding: 0 var(--sp-2);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}
.topbar-action:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.topbar-action.is-active {
  background: var(--accent-soft);
  color: var(--accent-hover);
}
.topbar-lang {
  padding: 0 var(--sp-3);
}
.topbar-lang-code {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.03em;
}

/* Дропдаун-контейнер */
.topbar-dropdown {
  position: relative;
}

/* Меню дропдауна */
.topbar-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--bg-elevated);
  border: var(--border-thin) solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: var(--sp-2);
  z-index: var(--z-dropdown);
}

.topbar-menu-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  text-align: left;
  transition: all var(--transition-fast);
}
.topbar-menu-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.topbar-menu-item.is-selected {
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: var(--fw-semibold);
}
.topbar-menu-item.is-danger:hover {
  background: var(--danger-soft);
  color: var(--danger-text);
}
.topbar-menu-item.is-disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}
.topbar-menu-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 20px;
  font-size: 0.6rem;
  font-weight: var(--fw-bold);
  background: var(--bg-surface-3);
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
}
.topbar-menu-check {
  margin-left: auto;
  color: var(--accent);
}

/* Пользователь */
.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: 44px;
  padding: 0 var(--sp-2) 0 var(--sp-2);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}
.topbar-user:hover {
  background: var(--bg-hover);
}
.topbar-user.is-active {
  background: var(--bg-surface-2);
}
.topbar-user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}
.topbar-user-name {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  white-space: nowrap;
}
.topbar-user-role {
  font-size: 0.68rem;
  color: var(--text-tertiary);
  text-transform: capitalize;
}
.topbar-user-caret {
  color: var(--text-tertiary);
  transition: transform var(--transition-base);
}
@media (max-width: 639px) {
  .topbar-user-info { display: none; }
  .topbar-user-caret { display: none; }
}

/* Меню пользователя — шире */
.topbar-menu-user {
  min-width: 260px;
}
.topbar-user-header {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3);
}
.topbar-user-header-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar-user-header-name {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
}
.topbar-user-header-email {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.topbar-menu-divider {
  height: var(--border-thin);
  background: var(--border-subtle);
  margin: var(--sp-2) 0;
}

/* =====================================================================
   4. ЗАГОЛОВОК СТРАНИЦЫ (page header — для всех разделов)
   ===================================================================== */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}
.page-header-content {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.page-title {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.page-subtitle {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
}
.page-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

/* =====================================================================
   5. СЕТКИ (для виджетов дашборда)
   ===================================================================== */
.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.grid-widgets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--sp-5);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--sp-5);
}
