/* ===========================
   ERP LAYOUT
   Шапка · Сайдбар · Контент
   =========================== */

/* Базовый фон */
body {
  min-height: 100vh;
  background: var(--erp-bg, #f5f7fb);
}

/* ---------- ШАПКА (фиксированная) ---------- */

.erp-navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--erp-navbar-h, 56px);

  background-color: #ffffff;
  border-bottom: 1px solid var(--erp-border, #e5e7eb);

  z-index: 1030;
  display: flex;
  align-items: center;
}

.erp-navbar .container-fluid {
  padding-inline: 0.75rem;
}

/* Точка бренда в шапке */
.erp-brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #4f46e5, #22c55e);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .18);
}

/* Глобальный поиск в шапке */
.erp-global-search .input-group-text {
  border-radius: 999px 0 0 999px !important;
}

.erp-global-search .form-control {
  border-radius: 0 999px 999px 0 !important;
  box-shadow: none !important;
}

/* Кнопки-иконки уведомлений */
.erp-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
}

.erp-icon-btn i {
  font-size: 1.05rem;
}

/* Бейдж поверх иконки */
.erp-icon-badge {
  position: absolute;
  top: -4px;
  right: -2px;
  font-size: .65rem;
  line-height: 1;
  padding: .15rem .35rem;
}

/* Контейнер иконок уведомлений */
.erp-header-notifs {
  padding-right: .25rem;
}

/* ---------- ОБОЛОЧКА / КОНТЕНТ ---------- */

/* Вся страница под шапкой */
.erp-shell {
  display: flex;
  min-height: 100vh;
  margin-top: var(--erp-navbar-h, 56px); /* чтобы контент не лез под шапку */
}

/* ---------- САЙДБАР (левое меню, фиксированное) ---------- */

.erp-sidebar {
  width: 260px; /* фактическая ширина, синхронизирована с --erp-sidebar-w */

  position: fixed;
  top: var(--erp-navbar-h, 56px);
  bottom: 0;
  left: 0;

  background: #0f172a;
  color: #e5e7eb;

  border-right: 1px solid rgba(148, 163, 184, 0.25);
  display: flex;
  flex-direction: column;
  z-index: 1020;
}

/* Заголовки в сайдбаре */
.erp-sidebar-heading {
  padding: .75rem 1.25rem .25rem;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: #64748b;
}

/* Плашка сверху с кнопкой свернуть */
.erp-sidebar-toggle-label {
  font-size: .75rem;
}

/* Пункты меню */
.erp-sidebar .list-group-item {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #cbd5f5;

  display: flex;
  align-items: center;
  gap: .65rem;

  padding: .55rem 1.25rem;
  font-size: .9rem;

  transition: background .15s ease, color .15s ease, padding-left .15s ease;
}

.erp-sidebar .list-group-item i {
  font-size: 1.1rem;
  opacity: .9;
  flex-shrink: 0;
}

.erp-sidebar .list-group-item span {
  flex: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.erp-sidebar .list-group-item:hover {
  background: rgba(30, 64, 175, 0.35);
  color: #e5e7eb;
  padding-left: 1.45rem;
}

.erp-sidebar .list-group-item.active {
  background: linear-gradient(135deg, #4f46e5, #0ea5e9);
  color: #f9fafb;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .25);
}

.erp-sidebar .list-group-item.active i {
  opacity: 1;
}

/* ---------- Сворачивание сайдбара (desktop) ---------- */

@media (min-width: 992px) {
  body.sidebar-collapsed .erp-sidebar {
    width: 72px;
  }

  body.sidebar-collapsed .erp-sidebar-heading {
    display: none;
  }

  body.sidebar-collapsed .erp-sidebar-toggle-label {
    display: none;
  }

  body.sidebar-collapsed .erp-sidebar .list-group-item {
    justify-content: center;
    padding-left: .75rem;
    padding-right: .75rem;
  }

  body.sidebar-collapsed .erp-sidebar .list-group-item span {
    display: none;
  }
}

/* ---------- КОНТЕНТНАЯ ОБЛАСТЬ ---------- */

.erp-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--erp-bg, #f5f7fb);
}

/* На десктопе отступаемся от фиксированного сайдбара */
@media (min-width: 992px) {
  .erp-content {
    margin-left: 260px; /* та же ширина, что и .erp-sidebar */
  }

  body.sidebar-collapsed .erp-content {
    margin-left: 72px;
  }
}

/* На мобилке сайдбар скрыт (через d-none d-lg-flex в HTML),
   контент тянется на всю ширину */
@media (max-width: 991.98px) {
  .erp-content {
    margin-left: 0;
  }
}

/* ---------- SUBHEADER (прилипший внутри контента) ---------- */

.erp-subheader {
  position: sticky;
  top: 0; /* внутри .erp-content, которая уже смещена под шапку */
  z-index: 100;
  background: #ffffff;
  border-bottom: 1px solid var(--erp-border, #e5e7eb);
}

/* ---------- FOOTER ---------- */

.erp-footer {
  border-top: 1px solid var(--erp-border, #e5e7eb);
  background: #ffffff;
}

/* ---------- SHIFT WIDGET ---------- */

.shift-widget {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .15rem .6rem;
  border-radius: 999px;
  background-color: rgba(15, 23, 42, 0.03);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.shift-timer {
  font-variant-numeric: tabular-nums;
  min-width: 82px;
  text-align: right;
  font-size: .8rem;
}

/* ---------- TOAST контейнер ---------- */

.erp-toast-container {
  z-index: 2000;
}

/* ---------- ПРЕЛОАДЕР ---------- */

.erp-preloader-banner {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2100;
}

.erp-preloader-card {
  background: #0f172a;
  color: #e5e7eb;
  padding: 1rem 1.25rem;
  border-radius: .75rem;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.65);
  display: flex;
  align-items: center;
  gap: .75rem;
  min-width: 260px;
  max-width: 360px;
}

.erp-preloader-card .spinner-border {
  width: 1.8rem;
  height: 1.8rem;
}

.erp-preloader-title {
  font-weight: 600;
  font-size: .95rem;
}

.erp-preloader-text {
  font-size: .8rem;
  opacity: .85;
}

/* ===================== CONTROLLER LK ===================== */

.erp-card {
  border-radius: 0.75rem;
  border: 1px solid var(--bs-border-color);
  background-color: var(--bs-body-bg);
  box-shadow: 0 .375rem 1.25rem rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

[data-bs-theme="dark"] .erp-card {
  border-color: rgba(148, 163, 184, 0.35);
  box-shadow: 0 .5rem 1.5rem rgba(0, 0, 0, 0.7);
}

.erp-card > .card-header {
  border-bottom: 1px solid rgba(148, 163, 184, 0.35);
  background: linear-gradient(
    to bottom,
    rgba(148, 163, 184, 0.12),
    rgba(148, 163, 184, 0.02)
  );
  font-size: 0.9rem;
  font-weight: 600;
}

[data-bs-theme="dark"] .erp-card > .card-header {
  background: linear-gradient(
    to bottom,
    rgba(15, 23, 42, 0.95),
    rgba(15, 23, 42, 0.85)
  );
}

.erp-card > .card-footer {
  border-top: 1px solid rgba(148, 163, 184, 0.35);
  background-color: rgba(148, 163, 184, 0.04);
  font-size: 0.8rem;
}

.erp-card .badge.small,
.erp-card .small {
  font-size: 0.8rem;
}

/* Списки задач / анкет */

.erp-card .list-group-item {
  border: none;
  border-radius: 0;
}

.erp-card .list-group-item + .list-group-item {
  border-top: 1px solid rgba(148, 163, 184, 0.25);
}

.erp-card .list-group-item-action {
  transition: background-color 0.12s ease-out, color 0.12s ease-out, padding-left 0.12s;
}

.erp-card .list-group-item-action:hover {
  background-color: rgba(59, 130, 246, 0.04);
  padding-left: 0.85rem;
}

.erp-card .list-group-item-action.active {
  background: linear-gradient(
    to right,
    rgba(59, 130, 246, 0.16),
    rgba(59, 130, 246, 0.08)
  );
  color: var(--bs-body-color);
  border-left: 3px solid var(--bs-primary);
  padding-left: 0.95rem;
}

[data-bs-theme="dark"] .erp-card .list-group-item-action.active {
  background: linear-gradient(
    to right,
    rgba(59, 130, 246, 0.3),
    rgba(15, 23, 42, 0.9)
  );
}

.erp-card .list-group-item .fw-semibold {
  font-size: 0.9rem;
}

.erp-card .list-group-item .text-muted {
  font-size: 0.75rem;
}

/* Комментарии */

.erp-card .list-group-item .small.mt-1 {
  white-space: pre-line;
}

.erp-card textarea.form-control-sm {
  font-size: 0.85rem;
}

/* Чек-лист */

.erp-card .list-group-flush .list-group-item {
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}

.erp-card .list-group-flush .list-group-item .btn-sm {
  width: 2rem;
  height: 2rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.erp-card .list-group-flush .list-group-item .text-decoration-line-through {
  opacity: 0.7;
}

/* Адаптив */

@media (max-width: 991.98px) {
  .erp-card {
    box-shadow: 0 .25rem .75rem rgba(15, 23, 42, 0.09);
  }

  .erp-card > .card-body {
    padding: 0.75rem 0.9rem;
  }

  .erp-card > .card-header,
  .erp-card > .card-footer {
    padding: 0.6rem 0.9rem;
  }
}
