/* =========================================
   1. RESET & BASE (нормализация и базовые стили)
   ========================================= */
body {
  margin: 0;
  color: var(--text-primary);
  text-align: left;
  font-family: "Mulish", sans-serif;
  font-style: normal;
  font-weight: 400;
  line-height: 1.5;
  background: url(/imgbb/background_auth.png);
}

main {
  min-height: 99vh;
  background-color: var(--bg-primary);
  box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.25);
  border-radius: 6px;
}

*,
::after,
::before {
  box-sizing: border-box;
}

/* =========================================
   2. CSS VARIABLES (глобальные переменные)
   ========================================= */
:root {
  /* Цвета (семантика) */
  --primary-color: #007bff; /* Основной синий (кнопки, акценты) */
  --secondary-color: #6c757d; /* Серый второстепенный */
  --danger-color: #dc3545; /* Красный (ошибки) */

  --text-primary: #212529; /* Основной текст */
  --text-secondary: #58595b; /* Второстепенный текст */
  --text-tertiary: #495057; /* Третичный текст */
  --bg-primary: #ffffff; /* Основной фон */
  --bg-secondary: #f1f3f5; /* Второстепенный фон */
  --bg-tertiary: #e9ecef; /* Третичный фон */
  --bg-quaternary: #f8f9fa; /* Четвертичный фон */
  --bg-hover: #f9f9f9; /* Hover-фон */
  --border-color: #dee2e6; /* Границы */
  --border-secondary: #ccc; /* Границы */
  --border-tertiary: #3c688f; /* Третичная граница */
  --border-accent: #333; /* Акцентные границы */
  --hover-primary: #c2d9ee; /* Основная подсветка */

  /* Отступы (scale: 4px * n) */
  --spacing-xs: 0.25rem; /* 4px */
  --spacing-sm: 0.5rem; /* 8px */
  --spacing-md: 1rem; /* 16px */
  --spacing-lg: 1.25rem; /* 20px */
  --spacing-xl: 1.5rem; /* 24px */
  --spacing-2xl: 2rem; /* 32px */
}

/* =========================================
   3. BASE STYLES (контейнеры, заголовки, формы)
   ========================================= */
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 20px 25px;
}

.main {
  transition: margin-left 0.3s ease;
  margin: 10px 10px 0 0;
  margin-left: 220px;
}

.main-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 0;
}

/* form-head */
.head_c {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 4px solid var(--border-accent);
  margin-bottom: 34px;
  padding-bottom: 10px;
}

.head_c h2 {
  margin: 0;
}

.head_c form {
  margin: 0;
}

.head_d {
  width: 100%;
  display: flex;
  margin: 20px 0;
  padding-top: 20px;
  border-top: 2px solid var(--border-accent);
}

.head_title {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* =========================================
   4. Form Group
   ========================================= */
.form-group {
  position: relative;
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  justify-content: center;
}

.form-group label {
  text-align: right;
  font-weight: 600;
  color: var(--border-accent);
}

.form-group input,
.form-group select {
  padding: 8px 12px;
  border: 1px solid var(--border-secondary);
  border-radius: 5px;
  font-size: 14px;
  transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary-color);
  outline: none;
}

form input[type="date"] {
  font-family: "Mulish", sans-serif;
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid var(--border-secondary);
  border-radius: 6px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input[type="date"]:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 4px rgba(0, 123, 255, 0.3);
  outline: none;
}

/* form-table */
.form-table {
  width: 100%;
  margin: 20px 0;
  padding-top: 20px;
  border-top: 2px solid var(--border-accent);
}

/* =========================================
   5. Form Filter 
   ========================================= */
#formFilter {
  width: 100%;
  display: flex;
  flex-direction: column;
  margin: 0;
}

.filter-block {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  justify-content: start;
  gap: 16px;
  margin-bottom: 20px;
}

.filter-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* =========================================
   6. Form Add 
   ========================================= */
.form-add {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.form-add input,
.form-add select {
  width: 100%;
}

.block-add {
  width: 100%;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 20px 40px;
}

.block-combo {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 20px;
}

.block-combo.block-combo-vertically {
  flex-direction: column;
}

/* =========================================
   7. Form Edit 
   ========================================= */
.form-edit {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.block-edit {
  width: 100%;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 40px;
}

/* =========================================
   8. Company Combo
   ========================================= */
.company-input {
  position: relative;
}

.company-input .form-control {
  width: 100%;
  padding-right: 40px;
  box-sizing: border-box;
}

.company-input .company-input-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  border-radius: 20px;
  padding: 6px 6px;
  cursor: pointer;
  font-size: 14px;
  background-color: var(--bg-tertiary);
  transition: background-color 0.2s ease-in-out;
}

.company-input .company-input-btn:hover {
  background-color: var(--hover-primary);
}

/* =========================================
   9. BUTTONS & INTERACTIVE (Кнопки)
   ========================================= */
.crud-button {
  min-width: 48px;
  min-height: 42px;
  padding: 2px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 0.5px solid var(--border-tertiary);
  cursor: pointer;
  font-size: 16px;
  transition: background 0.2s ease;
}

.crud-button:hover {
  background-color: var(--primary-color);
  color: white;
}

.btn-filter {
  padding: 8px 16px;
  font-size: 14px;
  display: flex;
  align-items: center;
  min-width: 48px;
  justify-content: center;
  border-radius: 6px;
  min-height: 42px;
  border: 0.5px solid var(--border-tertiary);
  cursor: pointer;
}

.btn-filter:hover {
  background: var(--hover-primary);
}

.page-btn {
  width: 50px;
  height: 100%;
  margin: 1px 2px;
  padding: 1px 0;
  border: 0.5px solid var(--border-tertiary);
  border-radius: 6px;
  font-size: 13px;
  color: #222;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.page-btn:hover {
  background: var(--hover-primary);
}

.page-btn.active {
  color: white;
  background: var(--primary-color);
}

.btn-select {
  padding: 5px;
  margin: 5px;
  border: 0.5px solid var(--border-tertiary);
  border-radius: 6px;
  font-size: 14px;
  text-align: center;
  cursor: pointer;
}

.btn-select:hover {
  background: var(--hover-primary);
}

.btn-unload {
  padding: 4px 6px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  max-height: 32px;
  border: 0.5px solid var(--border-tertiary);
  cursor: pointer;
}

.btn-unload:hover {
  background: var(--hover-primary);
}

.btn-view-agreements {
  display: inline-block;
  padding: 4px 8px;
  color: white;
  text-decoration: none;
  border-radius: 3px;
  font-size: 14px;
  transition: background 0.3s ease;
}

.btn-view-agreements:hover {
  background: var(--hover-primary);
}

/* Кнопка "назад" (компонент) */
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg-quaternary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--secondary-color);
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.btn-back:hover,
.btn-back:focus {
  background: var(--hover-primary);
  color: var(--text-primary);
  transform: translateX(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  outline: none;
}

.btn-back i {
  transition: transform 0.3s ease;
}

/* Responsive: На мобиле — только иконка, меньше padding */
@media (max-width: 768px) {
  .btn-back {
    padding: 8px;
  }
}

/* =========================================
   10. Table (Таблица)
   ========================================= */
.table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  background-color: #fff;
  font-size: 14px;
  box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.05);
  border-radius: 6px;
  overflow: hidden;
}

.table thead {
  background-color: var(--bg-secondary);
}

.table th,
.table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.table th {
  font-weight: 600;
  color: var(--text-tertiary);
}

.table tbody tr:hover {
  background-color: var(--bg-hover);
}

@media screen and (max-width: 1020px) {
  .table th,
  .table td {
    padding: 3px 4px;
  }
}

tr.active-row {
  /* background-color: var(--bg-quaternary); */
}

tr.inactive-row {
  color: var(--secondary-color);
  background-color: var(--bg-tertiary);
  opacity: 0.7;
}

.clickable-td {
  cursor: pointer;
}

.clickable-td:hover {
  background-color: var(--hover-primary);
}

.pagination {
  display: flex;
  gap: 5px;
  justify-content: center;
  align-items: center;
}

/* =========================================
   11. Modal (Модельное окно)
   ========================================= */
/* Модельное окно */
#loadingOverlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  color: white;
  font-size: 20px;
  text-align: center;
  padding-top: 20%;
}

#modalCompaniesContainer,
#modalCompaniesMultipleContainer,
#modalRolesAccessContainer,
#modalRolesContainer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  /* align-items: center; */
  align-items: flex-start;
  z-index: 1000;
}

#modalCompaniesContainer .modal,
#modalCompaniesMultipleContainer .modal,
#modalRolesAccessContainer .modal,
#modalRolesContainer .modal {
  background: white;
  border-radius: 5px;
  max-width: 460px;
  width: 100%;
  max-height: 90vh;
  margin-top: 50px;
  overflow-y: auto;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
  position: relative;
}

/* Модельное окно - Голова */
.modal-header {
  background: var(--bg-quaternary);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  margin: 0;
  font-size: 18px;
}

/* Модельное окно - Тело */
.modal-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Список компаний */
#modelList,
#modelListMultiple {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 68vh;
  /* Ограничение по высоте */
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 4px;
  padding: 8px;
}

#modelList li,
#modelListMultiple li {
  padding: 6px 8px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
  display: flex;
  align-items: center;
}

#modelList li:last-child,
#modelListMultiple li:last-child {
  border-bottom: none;
}

#modelList input[type="checkbox"],
#modelListMultiple input[type="checkbox"] {
  margin-right: 8px;
}

/* Модельное окно - Поле поиска */
#searchFilter,
#searchFilterMultiple {
  padding: 10px 14px;
  border: 1px solid var(--border-secondary);
  border-radius: 4px;
  width: 100%;
  font-size: 16px;
}

/* Модельное окно - Кнопки */
.btn-modal {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  background-color: var(--secondary-color);
  color: white;
}

.btn-choose:hover {
  background-color: var(--primary-color);
}

.btn-cancel:hover {
  background-color: var(--danger-color);
}

.btn-cross {
  padding: 0;
  background: none;
  border: none;
  font-size: 26px;
  cursor: pointer;
  color: var(--border-accent);
}

.btn-cross:hover {
  color: var(--danger-color);
}

/* =========================================
   12. Togle (Рычаг)
   ========================================= */
.toggle {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle input:checked + .slider {
  background-color: #4caf50;
}

.toggle input:checked + .slider:before {
  transform: translateX(24px);
}

.active-toggle {
  transform: scale(1.2);
  cursor: pointer;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-secondary);
  transition: 0.4s;
  border-radius: 26px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

/* =========================================
   13. Toast (Уведомление)
   ========================================= */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.toast {
  position: relative;
  color: white;
  padding: 12px 20px;
  border-radius: 6px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 0.5s ease, transform 0.5s ease;
  cursor: pointer;
  overflow: hidden;
  min-width: 220px;
  margin-bottom: 8px;  /* Отступ между toast'ами */
  font-size: 14px;  /* Компактный текст */
}

/* Базовые типы (цвета) */
.toast.error {  /* Красный для ошибок */
  background: rgba(244, 67, 54, 0.9);
}

.toast.success {  /* Зелёный для успеха */
  background: rgba(40, 167, 69, 0.9);
}

.toast.info {  /* Синий для инфо */
  background: rgba(23, 162, 184, 0.9);
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.7);  /* Белый прогресс для всех типов */
  width: 100%;
  transform-origin: right;
}

/* =========================================
   14. Collapsible Section (Выпадающий раздел)
   ========================================= */
.collapsible-block {
  display: flex;
  flex-direction: column;
  margin-bottom: 8px;
}

.collapsible-section {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
}

.collapsible-header {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-quaternary);
  border: none;
  text-align: left;
  font-size: 16px;
  font-weight: bold;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.3s ease;
}

.collapsible-header:hover {
  background: var(--bg-tertiary);
}

.collapsible-header i {
  transition: transform 0.3s ease;
}

.collapsible-header.active i {
  transform: rotate(180deg);
}

.collapsible-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
  background: white;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.collapsible-content.active {
  max-height: 250px;
  min-height: 250px;
}

.collapsible-content .block-combo {
  padding: 16px;
}

.collapsible-content .form-group {
  padding: 0 5px;
}

/* =========================================
   15. Other (Error и другое)
   ========================================= */
.error-message {
  display: block;
  position: absolute;
  bottom: -18px;
  margin: 0;
  padding: 0;
  color: red;
  font-size: 12px;
  line-height: 20px;
}

input::placeholder {
  color: var(--placeholder-color, #999);
  opacity: 1;
  transition: color 0.2s ease;
}

.readonly,
input[readonly] {
  background-color: var(--bg-tertiary);
  border: 1px solid #ced4da;
}
