/* ============================================================================
   Trust Infinity — общая дизайн-система
   Канонические токены взяты из самой свежей и цельной части продукта —
   Dashboard (1.Страница логин/app/home-style.css) и модуля «Соцсети».
   Подключать ДО собственного css модуля: модуль по-прежнему может
   переопределять точечные правила, но общие переменные, шрифт, toast
   и навигационная панель становятся едиными для всей системы.
   ============================================================================ */

:root {
  /* ---- Поверхности (тёмная стеклянная тема) ---- */
  --ti-bg-base:        #0c0d11;
  --ti-bg-surface:     #13141a;
  --ti-bg-raised:      #1a1c24;
  --ti-bg-hover:       #1f2130;

  /* ---- Окантовки / разделители ---- */
  --ti-rim:            rgba(255,255,255,0.10);
  --ti-rim-mid:        rgba(255,255,255,0.16);
  --ti-rim-bright:     rgba(255,255,255,0.24);

  /* ---- Текст ---- */
  --ti-text-1:         #f0f1f8;
  --ti-text-2:         #9ba3be;
  --ti-text-3:         #6b7390;
  --ti-text-inverse:   #14151a;

  --ti-silver:         #8a90a8;
  --ti-silver-bright:  #b0b8cc;

  /* ---- Акцент (единый для всей системы, в тон существующим info/pill-цветам) ---- */
  --ti-accent:         #5c8fd6;
  --ti-accent-hover:   #6f9fe0;
  --ti-accent-soft:    rgba(92,143,214,0.16);
  --ti-accent-strong:  #3f6fb8;

  /* ---- Статусы ---- */
  --ti-success:        #3a7c52;
  --ti-success-bright: #4caf7d;
  --ti-danger:         #e0554f;
  --ti-danger-bright:  #e57050;
  --ti-warning:        #d9a441;
  --ti-info:           #5c8fd6;

  /* ---- Радиусы ---- */
  --ti-r-sm:   6px;
  --ti-r-btn:  8px;
  --ti-r-icon: 10px;
  --ti-r-md:   12px;
  --ti-r-card: 14px;
  --ti-r-lg:   18px;

  /* ---- Тени ---- */
  --ti-shadow-sm: 0 1px 3px rgba(0,0,0,.24), 0 1px 2px rgba(0,0,0,.16);
  --ti-shadow-md: 0 12px 32px rgba(0,0,0,.32), 0 2px 6px rgba(0,0,0,.18);
  --ti-shadow-lg: 0 20px 50px rgba(0,0,0,.45);

  /* ---- Типографика ---- */
  --ti-font-display: 'Syne', system-ui, sans-serif;
  --ti-font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;

  /* ---- Анимации ---- */
  --ti-ease:     cubic-bezier(.4,0,.2,1);
  --ti-ease-out: cubic-bezier(.16,1,.3,1);

  /* ---- Служебное ---- */
  --ti-navbar-h: 44px;
  --ti-z-navbar: 9000;
  --ti-z-toast:  9500;
}

/* Фокус-стиль — единый для всей системы (доступность) */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--ti-accent);
  outline-offset: 2px;
}

/* ============================================================================
   Верхняя панель навигации (внедряется скриптом /_shared/nav.js)
   ============================================================================ */
#ti-navbar {
  position: sticky;
  top: 0;
  z-index: var(--ti-z-navbar);
  height: var(--ti-navbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  /* backdrop-filter прибрано: цей бар (position:sticky) присутній АБСОЛЮТНО
     на кожній сторінці системи (внедряється nav.js) — браузер мусив
     безперервно перераховувати розмиття фону під час будь-якого скролу на
     будь-якій сторінці, весь час. Фон і так майже непрозорий (92%), тож
     суцільний колір виглядає практично ідентично, без цієї ціни. */
  background: rgb(15,16,20);
  border-bottom: 1px solid var(--ti-rim);
  font-family: var(--ti-font-body);
  box-sizing: border-box;
}

#ti-navbar * { box-sizing: border-box; }

/* Bar wstrzykiwany przez nav.js jest PIERWSZYM elementem <body> na każdej
   stronie modułu — łącznie z tymi, które ktoś drukuje (protokoły, umowy).
   Żaden z lokalnych arkuszy modułów o nim nie wie i nie może go ukryć (nie ich
   element), więc bez tej reguły zajmuje całą wysokość pierwszej strony
   wydruku, spychając właściwy dokument na drugą. */
@media print {
  #ti-navbar { display: none !important; }
}

.ti-nav__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ti-text-1);
  text-decoration: none;
  font-family: var(--ti-font-display);
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: .2px;
  flex-shrink: 0;
}
.ti-nav__brand:hover { color: var(--ti-accent-hover); }
.ti-nav__brand-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ti-accent);
  box-shadow: 0 0 8px var(--ti-accent);
  flex-shrink: 0;
}
.ti-nav__current {
  color: var(--ti-text-3);
  font-size: 12.5px;
  padding-left: 10px;
  margin-left: 2px;
  border-left: 1px solid var(--ti-rim-mid);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ti-nav__spacer { flex: 1 1 auto; min-width: 8px; }

.ti-nav__menu-wrap { position: relative; }

.ti-nav__toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--ti-rim);
  color: var(--ti-text-2);
  border-radius: var(--ti-r-btn);
  padding: 6px 10px;
  font-size: 12.5px;
  font-family: var(--ti-font-body);
  cursor: pointer;
  transition: background .15s var(--ti-ease), border-color .15s var(--ti-ease), color .15s var(--ti-ease);
}
.ti-nav__toggle:hover { background: rgba(255,255,255,0.09); color: var(--ti-text-1); border-color: var(--ti-rim-bright); }
.ti-nav__toggle svg { width: 13px; height: 13px; flex-shrink: 0; }

.ti-nav__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 260px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--ti-bg-raised);
  border: 1px solid var(--ti-rim-mid);
  border-radius: var(--ti-r-card);
  box-shadow: var(--ti-shadow-lg);
  padding: 6px;
  display: none;
  z-index: var(--ti-z-navbar);
}
.ti-nav__dropdown.is-open { display: block; animation: ti-nav-pop .15s var(--ti-ease-out); }
@keyframes ti-nav-pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* FIX (аудит 8.3): группировка модулей по категориям — та же группировка,
   что уже используется на /home (module-card eyebrow: Marketing/Księgowość/
   Serwis/Klienci/Pozostałe/Komunikacja/IT), перенесённая в постоянный
   dropdown, чтобы не нужно было возвращаться на /home ради навигации. */
.ti-nav__group-label {
  padding: 10px 10px 4px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ti-text-3, var(--ti-text-2));
  opacity: .75;
}
.ti-nav__group-label:first-of-type { padding-top: 6px; }

.ti-nav__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--ti-r-sm);
  color: var(--ti-text-2);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}
.ti-nav__item:hover { background: var(--ti-bg-hover); color: var(--ti-text-1); }
.ti-nav__item.is-current { color: var(--ti-text-1); background: rgba(255,255,255,0.05); }
.ti-nav__item-icon { width: 15px; height: 15px; flex-shrink: 0; opacity: .85; }

.ti-nav__logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--ti-rim);
  color: var(--ti-text-2);
  border-radius: var(--ti-r-btn);
  padding: 6px 10px;
  font-size: 12.5px;
  font-family: var(--ti-font-body);
  cursor: pointer;
  transition: color .15s var(--ti-ease), border-color .15s var(--ti-ease);
}
.ti-nav__logout:hover { color: var(--ti-danger-bright); border-color: var(--ti-danger); }

@media (max-width: 640px) {
  .ti-nav__current { display: none; }
  #ti-navbar { padding: 0 10px; gap: 8px; }
}

/* ============================================================================
   Toast-уведомления (единый API window.showToast(type, title, message, duration))
   ============================================================================ */
.toast-container {
  position: fixed;
  top: calc(var(--ti-navbar-h) + 14px);
  right: 18px;
  z-index: var(--ti-z-toast);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--ti-bg-raised);
  border: 1px solid var(--ti-rim-mid);
  border-radius: var(--ti-r-card);
  padding: 14px 14px;
  box-shadow: var(--ti-shadow-md);
  border-left: 3px solid var(--ti-info);
  animation: ti-toast-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
  font-family: var(--ti-font-body);
}
.toast.toast-hide { animation: ti-toast-out 0.22s ease forwards; }

@keyframes ti-toast-in {
  from { opacity: 0; transform: translateX(24px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes ti-toast-out {
  from { opacity: 1; transform: translateX(0) scale(1); max-height: 200px; margin-bottom: 0; }
  to   { opacity: 0; transform: translateX(24px) scale(0.96); max-height: 0; margin-bottom: -10px; }
}

.toast-success { border-left-color: var(--ti-success-bright); }
.toast-error   { border-left-color: var(--ti-danger-bright); }
.toast-warning { border-left-color: var(--ti-warning); }
.toast-info    { border-left-color: var(--ti-info); }

.toast-icon {
  width: 30px; height: 30px; border-radius: var(--ti-r-icon);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0; color: #fff;
}
.toast-success .toast-icon { background: linear-gradient(135deg, var(--ti-success-bright) 0%, var(--ti-success) 100%); }
.toast-error   .toast-icon { background: linear-gradient(135deg, var(--ti-danger-bright) 0%, var(--ti-danger) 100%); }
.toast-warning .toast-icon { background: linear-gradient(135deg, #e5b25a 0%, var(--ti-warning) 100%); }
.toast-info    .toast-icon { background: linear-gradient(135deg, var(--ti-accent-hover) 0%, var(--ti-accent-strong) 100%); }

.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: 13px; font-weight: 700; color: var(--ti-text-1); margin-bottom: 2px; letter-spacing: -0.1px; }
.toast-message { font-size: 12.5px; color: var(--ti-text-2); line-height: 1.45; }

.toast-close {
  background: none; border: none; color: var(--ti-text-3);
  font-size: 15px; cursor: pointer; line-height: 1; padding: 2px; flex-shrink: 0;
  transition: color 0.15s ease;
}
.toast-close:hover { color: var(--ti-text-1); }

.toast-progress {
  position: absolute; bottom: 0; left: 0; height: 2px;
  background: rgba(255,255,255,0.18);
  animation: ti-toast-progress linear forwards;
}
.toast-success .toast-progress { background: rgba(76,175,125,0.35); }
.toast-error   .toast-progress { background: rgba(229,112,80,0.35); }
.toast-warning .toast-progress { background: rgba(217,164,65,0.35); }

@keyframes ti-toast-progress { from { width: 100%; } to { width: 0%; } }

@media (prefers-reduced-motion: reduce) {
  .toast, .toast.toast-hide, .ti-nav__dropdown.is-open { animation: none; }
}
