/*
 * Floo Corp — фирменный стиль
 * Цветовая схема: floo.coffee
 */

:root {
  --floo-yellow:       #FFCC00;
  --floo-yellow-soft:  #FFDE69;
  --floo-yellow-bg:    rgba(238, 207, 99, 0.15);
  --floo-orange:       #EC6722;
  --floo-dark:         #1C1C1C;
  --floo-text:         #1C1C1C;
  --floo-text-muted:   rgba(28, 28, 28, 0.6);
  --floo-text-light:   rgba(28, 28, 28, 0.3);
  --floo-border:       rgba(28, 28, 28, 0.1);
  --floo-bg:           #FFFFFF;
  --floo-bg-soft:      #F7F7F5;

  /* Bootstrap overrides */
  --bs-primary:        var(--floo-yellow);
  --bs-primary-rgb:    255, 204, 0;
  --bs-body-color:     var(--floo-text);
  --bs-body-bg:        var(--floo-bg);
  --bs-border-color:   var(--floo-border);
  --bs-link-color:     var(--floo-dark);
  --bs-link-hover-color: var(--floo-orange);
  --bs-border-radius:  12px;
  --bs-border-radius-sm: 8px;
  --bs-border-radius-lg: 16px;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
  background: var(--floo-bg);
  color: var(--floo-text);
  font-size: 15px;
}

/* ----- Оболочка приложения ----- */
.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--floo-bg-soft);
}
.app-main {
  flex: 1 1 auto;
  min-width: 0;
  padding-bottom: 3rem;
  background: var(--floo-bg);
}

/* ----- Sidebar (десктоп) ----- */
.sidebar {
  flex: 0 0 256px;
  width: 256px;
  background: #fff;
  border-right: 1px solid var(--floo-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 0;
  box-shadow: 1px 0 0 rgba(0, 0, 0, .02);
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .1); border-radius: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: 1.1rem 1.25rem .9rem;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--floo-dark);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.sidebar-brand:hover { color: var(--floo-dark); }
.sidebar-brand .brand-dot {
  width: 14px; height: 14px;
  background: var(--floo-yellow);
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(255, 204, 0, .2);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .7rem 1.25rem .85rem;
  border-bottom: 1px solid var(--floo-border);
  margin-bottom: .5rem;
}
.sidebar-user .avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--floo-yellow-bg);
}
.sidebar-user .user-info { min-width: 0; }
.sidebar-user .user-name {
  font-weight: 600;
  font-size: .93rem;
  line-height: 1.25;
  color: var(--floo-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user .user-role {
  font-size: .76rem;
  color: var(--floo-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: .05rem;
  padding: .25rem .55rem 1rem;
  overflow-y: auto;
}
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .55rem .8rem;
  color: var(--floo-text);
  text-decoration: none;
  border-radius: 10px;
  font-size: .92rem;
  font-weight: 500;
  position: relative;
  transition: background .12s, color .12s, transform .08s;
  line-height: 1.2;
}
.sidebar-nav-item:hover {
  background: var(--floo-yellow-bg);
  color: var(--floo-dark);
}
.sidebar-nav-item:active { transform: scale(.985); }
.sidebar-nav-item.active {
  color: var(--floo-dark);
  font-weight: 600;
  background: var(--floo-yellow);
}
.sidebar-nav-item.active::before {
  content: '';
  position: absolute;
  left: -.55rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  background: var(--floo-dark);
  border-radius: 0 3px 3px 0;
}
.sidebar-nav-item i {
  font-size: 1.08rem;
  width: 20px;
  text-align: center;
  color: var(--floo-text-muted);
  flex-shrink: 0;
  transition: color .12s;
}
.sidebar-nav-item:hover i,
.sidebar-nav-item.active i { color: var(--floo-dark); }

.sidebar-nav-item .nav-badge {
  margin-left: auto;
  font-size: .7rem;
  background: var(--floo-yellow-bg);
  color: var(--floo-dark);
  padding: .1rem .45rem;
  border-radius: 10px;
  font-weight: 600;
}

/* Группы — сворачиваемые */
.sidebar-group { margin-top: .9rem; }
.sidebar-group:first-of-type { margin-top: .35rem; }
.sidebar-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: .25rem .8rem .25rem;
  margin: 0 0 .2rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--floo-text-light);
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  user-select: none;
  transition: color .12s;
}
/* Под-разделы внутри группы (используется в Администрировании) */
.sidebar-subgroup { display: block; }
.sidebar-subgroup + .sidebar-subgroup { border-top: 1px solid rgba(0,0,0,.05); }

.sidebar-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--floo-text-light);
  opacity: .55;
  padding: .55rem .8rem .15rem;
  margin: .15rem 0 0;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  user-select: none;
  transition: opacity .12s, color .12s;
}
.sidebar-subhead:hover { opacity: .9; color: var(--floo-orange); }
.sidebar-subhead .chevron {
  font-size: .65rem;
  transition: transform .2s;
  opacity: .7;
}
.sidebar-subhead[aria-expanded="false"] .chevron { transform: rotate(-90deg); }

.sidebar-subgroup-items {
  display: flex;
  flex-direction: column;
  gap: .05rem;
  overflow: hidden;
  max-height: 1000px;
  transition: max-height .25s ease, opacity .2s ease;
}
.sidebar-subgroup-items[data-collapsed="true"] {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}
.sidebar-group-title:hover { color: var(--floo-orange); }
.sidebar-group-title .chevron {
  font-size: .7rem;
  transition: transform .2s;
  opacity: .6;
}
.sidebar-group-title[aria-expanded="false"] .chevron { transform: rotate(-90deg); }
.sidebar-group-items {
  display: flex;
  flex-direction: column;
  gap: .05rem;
  overflow: hidden;
  max-height: 3000px;
  transition: max-height .35s ease, opacity .2s ease;
}
.sidebar-group-items[data-collapsed="true"] {
  max-height: 0 !important;
  opacity: 0;
  pointer-events: none;
}

.sidebar-footer {
  padding: .65rem .55rem .85rem;
  border-top: 1px solid var(--floo-border);
  margin-top: .5rem;
  display: flex;
  flex-direction: column;
  gap: .05rem;
  background: #fff;
  position: sticky;
  bottom: 0;
}

/* ----- Мобильный top-bar + off-canvas sidebar ----- */
.mobile-topbar {
  display: none;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  background: var(--floo-bg);
  border-bottom: 1px solid var(--floo-border);
  position: sticky;
  top: 0;
  z-index: 1020;
}
.mobile-topbar .brand-dot {
  width: 10px; height: 10px;
  background: var(--floo-yellow);
  border-radius: 50%;
  display: inline-block;
}
.sidebar-toggle {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--floo-dark);
  padding: .25rem .5rem;
  border-radius: 8px;
}
.sidebar-toggle:hover { background: var(--floo-bg-soft); }
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  z-index: 1040;
}
.sidebar-backdrop.open { display: block; }

@media (max-width: 991.98px) {
  .app-shell { flex-direction: column; }
  .mobile-topbar { display: flex; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 1050;
    box-shadow: 0 0 30px rgba(0, 0, 0, .08);
  }
  .sidebar.open { transform: translateX(0); }
}

/* ----- Кнопки ----- */
.btn {
  font-weight: 500;
  border-radius: 10px;
  padding: .5rem 1.1rem;
  transition: all .12s;
}
.btn-primary,
.btn-floo {
  background: var(--floo-yellow);
  border-color: var(--floo-yellow);
  color: var(--floo-dark);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.btn-primary:hover,
.btn-floo:hover {
  background: var(--floo-yellow-soft);
  border-color: var(--floo-yellow-soft);
  color: var(--floo-dark);
  box-shadow: 0 2px 8px rgba(255, 204, 0, .35);
  transform: translateY(-1px);
}
.btn-primary:focus,
.btn-floo:focus {
  box-shadow: 0 0 0 .25rem rgba(255, 204, 0, .4);
}
.btn-outline-dark {
  border-color: var(--floo-border);
  color: var(--floo-text);
  background: #fff;
}
.btn-outline-dark:hover {
  background: var(--floo-dark);
  border-color: var(--floo-dark);
  color: #fff;
}

/* ----- Карточки ----- */
.card {
  border: 1px solid var(--floo-border);
  border-radius: var(--bs-border-radius-lg);
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .02);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--floo-border);
  font-weight: 600;
  padding: .9rem 1.25rem;
}

/* ----- Таблицы ----- */
.table { --bs-table-border-color: var(--floo-border); }
.table > :not(caption) > * > * { padding: .75rem 1rem; }
.table > thead {
  background: var(--floo-bg-soft);
  color: var(--floo-text-muted);
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
}

/* ----- Формы ----- */
.form-control, .form-select {
  border-color: var(--floo-border);
  border-radius: 10px;
  padding: .55rem .85rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--floo-yellow);
  box-shadow: 0 0 0 .2rem rgba(255, 204, 0, .25);
}
.form-label { font-weight: 500; font-size: .9rem; }

/* ----- Бейджи ----- */
.badge-floo {
  background: var(--floo-yellow);
  color: var(--floo-dark);
  font-weight: 500;
}
.badge-soft {
  background: var(--floo-yellow-bg);
  color: var(--floo-dark);
  font-weight: 500;
}
.badge-muted {
  background: rgba(28, 28, 28, .06);
  color: var(--floo-text-muted);
}

/* ----- Страница логина ----- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--floo-bg) 0%, var(--floo-yellow-bg) 100%);
  padding: 2rem 1rem;
}
.login-card {
  background: #fff;
  border: 1px solid var(--floo-border);
  border-radius: 20px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .04);
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo .brand-dot {
  display: inline-block;
  width: 14px; height: 14px;
  background: var(--floo-yellow);
  border-radius: 50%;
  margin-right: .5rem;
  vertical-align: middle;
}
.login-logo h1 {
  display: inline-block;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  vertical-align: middle;
}
.login-logo .subtitle {
  display: block;
  font-size: .85rem;
  color: var(--floo-text-muted);
  margin-top: .5rem;
}

/* ----- Dashboard ----- */
.module-card {
  display: block;
  padding: 1.75rem;
  border-radius: var(--bs-border-radius-lg);
  border: 1px solid var(--floo-border);
  background: #fff;
  text-decoration: none;
  color: var(--floo-text);
  transition: all .2s;
  height: 100%;
}
.module-card:hover {
  border-color: var(--floo-yellow);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .05);
  color: var(--floo-text);
}
.module-card .icon {
  width: 44px; height: 44px;
  background: var(--floo-yellow-bg);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  font-size: 1.3rem;
}
.module-card h5 { font-weight: 600; margin-bottom: .25rem; }
.module-card p  { color: var(--floo-text-muted); font-size: .9rem; margin: 0; }

/* ----- Аватар ----- */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--floo-yellow-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--floo-dark);
  font-size: .82rem;
  object-fit: cover;
  overflow: hidden;
}
.avatar-lg { width: 80px; height: 80px; font-size: 1.5rem; }

/* ----- Оргструктура (дерево) ----- */
.org-tree, .org-tree ul {
  list-style: none;
  padding-left: 1.5rem;
  border-left: 1px dashed var(--floo-border);
}
.org-tree > li {
  padding: .35rem 0;
  position: relative;
}

/* ----- Пустые состояния ----- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--floo-text-muted);
}

/* ----- Утилиты ----- */
.text-muted-floo { color: var(--floo-text-muted) !important; }
.page-title {
  font-weight: 700;
  font-size: 1.6rem;
  line-height: 1.2;
  margin: 0 0 .35rem;
  letter-spacing: -0.01em;
}
/* Если у .page-title нет подзаголовка — увеличиваем отступ до следующего блока */
.page-title:last-child { margin-bottom: 1.5rem; }

.section-sub {
  color: var(--floo-text-muted);
  font-size: .92rem;
  line-height: 1.4;
  margin: 0 0 1.5rem;
}

/* ----- Дерево папок (FolderTree / preview-modal) ----- */
.folder-header { border-radius: 8px; }
.folder-header:hover { background: var(--floo-yellow-bg); }
.folder-header[aria-expanded="true"] .folder-chevron { transform: rotate(90deg); }
.folder-chevron { transition: transform .2s; font-size: .8em; }
.doc-row { border-radius: 8px; }
.doc-row:hover { background: var(--floo-bg-soft); }

/* ----- Контент страниц content_pages (about/marketing/fire_safety) ----- */
.content-page-body { line-height: 1.65; font-size: 1rem; }
.content-page-body h1, .content-page-body h2, .content-page-body h3 { margin-top: 1.5em; margin-bottom: .6em; }
.content-page-body h2 { font-size: 1.4rem; }
.content-page-body h3 { font-size: 1.15rem; }
.content-page-body p { margin-bottom: 1em; }
.content-page-body ul, .content-page-body ol { padding-left: 1.5em; margin-bottom: 1em; }
.content-page-body img { max-width: 100%; height: auto; border-radius: 12px; margin: .5em 0; }
.content-page-body a { color: var(--floo-orange); }

/* ----- Quill WYSIWYG редактор (общие стили для всех admin-страниц) ----- */
#editor { border-radius: 0 0 10px 10px; }
.ql-toolbar.ql-snow {
  border-radius: 10px 10px 0 0;
  border-color: var(--floo-border);
  background: var(--floo-bg-soft);
}
.ql-container.ql-snow {
  border-radius: 0 0 10px 10px;
  border-color: var(--floo-border);
  font-family: inherit;
  font-size: 15px;
}
.ql-editor { min-height: 380px; }
.ql-editor h2 { font-weight: 700; font-size: 1.5rem; margin: 1em 0 .5em; }
.ql-editor h3 { font-weight: 600; font-size: 1.2rem; margin: 1em 0 .5em; }
.ql-editor p  { line-height: 1.6; }
.ql-snow .ql-stroke { stroke: var(--floo-dark); }
.ql-snow .ql-fill   { fill:   var(--floo-dark); }
.ql-snow .ql-picker-label:hover,
.ql-snow .ql-picker-item:hover,
.ql-snow .ql-active { color: var(--floo-orange) !important; }
.ql-snow .ql-active .ql-stroke { stroke: var(--floo-orange) !important; }
.ql-snow .ql-active .ql-fill   { fill:   var(--floo-orange) !important; }

/* ============== Карточки корневых папок (Sprint 16) ============== */
.folder-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.folder-card {
  display: block;
  padding: 1.25rem 1.1rem;
  border-radius: 12px;
  background: var(--floo-bg-soft);
  border: 1px solid var(--floo-border);
  transition: transform .15s, box-shadow .15s;
  color: inherit;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}
.folder-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .08);
}
.folder-card-icon {
  font-size: 1.8rem;
  margin-bottom: .4rem;
  display: inline-block;
}
.folder-card-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: .2rem;
}
.folder-card-meta {
  color: var(--floo-text-muted);
  font-size: .85rem;
}
.folder-card-accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--floo-orange);
}

/* ----- Мобильная адаптация (≤ 575px) ----- */
@media (max-width: 575.98px) {
  /* На узких экранах сбрасываем все inline min-width на формах
     чтобы поля не выпирали за вьюпорт и нормально стэкались. */
  form [style*="min-width:"] { min-width: 0 !important; max-width: 100% !important; }
  form .form-control,
  form .form-select { max-width: 100% !important; }

  /* В таблицах (внутри .table-responsive) запрещаем перенос заголовков,
     чтобы горизонтальный скролл показывал полные подписи, а не обрезанные. */
  .table-responsive .table th { white-space: nowrap; }

  /* KPI-карточки — крупный шрифт делаем чуть меньше, чтобы число не переносилось. */
  .card .fs-3 { font-size: 1.4rem !important; }
  .card .fs-4 { font-size: 1.15rem !important; }

  /* Заголовок страницы — оставляем читаемым, но без agressive line-height. */
  .page-title { font-size: 1.35rem; line-height: 1.25; }
}

/* ----- Узкие планшеты / горизонтальный смартфон (576-767px) ----- */
@media (min-width: 576px) and (max-width: 767.98px) {
  .table-responsive .table th { white-space: nowrap; }
}

/* =====================================================
   Page FAQ — кнопка «?» рядом с заголовком + модалка
   ===================================================== */
.page-faq-btn {
  width: 28px; height: 28px; padding: 0; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.page-faq-btn i { font-size: 14px; }

.page-faq-section { margin-bottom: 18px; }
.page-faq-section:last-child { margin-bottom: 0; }
.page-faq-section h6 { font-weight: 600; margin-bottom: 6px; color: var(--floo-text); }
.page-faq-section p,
.page-faq-section li { font-size: .92rem; color: var(--floo-text-muted); margin-bottom: 4px; }
.page-faq-section ul,
.page-faq-section ol { padding-left: 1.2rem; margin-bottom: .5rem; }
.page-faq-section code {
  background: #f5f5f4; padding: 1px 5px; border-radius: 3px;
  font-size: .85em; color: #1c1c1c;
}
.page-faq-section a { color: var(--floo-primary); }
