/* ============================================
   Базы данных: Excel-подобная таблица с фильтрами
   ============================================ */

/* --- Бейдж БД --- */
.form-card__type-badge--db {
  color: #0d9488;
  background-color: #ccfbf1;
}

/* --- Стиль навигации БД --- */
.sidebar__nav-item--db {
  color: #0d9488;
}

/* --- Обёртка таблицы --- */
.db-view {
  overflow: hidden;
}

.db-table-wrapper {
  margin-top: var(--spacing-md);
}

.db-stats {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-sm);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid var(--color-border-light);
}

.db-table-scroll {
  overflow-x: auto;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
}

/* --- Таблица --- */
.db-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
  table-layout: auto;
}

.db-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

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

/* --- Заголовок столбца --- */
.db-th {
  background: var(--color-surface);
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
  user-select: none;
  border-bottom: 2px solid var(--color-border) !important;
}

.db-th--filtered {
  background: #e0f2fe;
  color: var(--color-primary);
}

.db-th--action {
  text-align: center;
  width: 70px;
}

.db-th__content {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* --- Кнопка фильтра (стрелка ▼) --- */
.db-filter-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 10px;
  padding: 1px 4px;
  line-height: 1;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.db-filter-btn:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.db-th--filtered .db-filter-btn {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* --- Строки таблицы --- */
.db-table tbody tr {
  transition: background-color var(--transition-fast);
}

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

.db-table tbody tr:nth-child(even) {
  background-color: var(--color-surface);
}

.db-table tbody tr:nth-child(even):hover {
  background-color: var(--color-surface-hover);
}

/* --- Ячейка описания --- */
.db-td--description {
  max-width: 350px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Кнопка удаления заявки --- */
.db-td--action {
  text-align: center;
}

.btn-db-delete {
  background: none;
  border: 1.5px solid var(--color-error);
  color: var(--color-error);
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: bold;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-db-delete:hover {
  background: var(--color-error);
  color: #fff;
  transform: scale(1.1);
}

/* --- Выбор статуса в таблице --- */
.db-status-select {
  font-size: 0.82rem;
  padding: 3px 6px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  max-width: 140px;
}

.db-status-select:disabled {
  opacity: 0.5;
  cursor: default;
}

/* --- Пустое состояние --- */
.db-empty {
  text-align: center !important;
  color: var(--color-text-muted);
  padding: 2rem !important;
  font-style: italic;
}

/* ========================================
   Фильтр-дропдаун (Excel-стиль)
   ======================================== */
.db-filter-dropdown {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  max-width: 300px;
  animation: filterAppear 150ms ease;
}

@keyframes filterAppear {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.db-filter-dropdown__header {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border-light);
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.db-filter-dropdown__list {
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 0;
}

.db-filter-dropdown__option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--color-text);
  transition: background var(--transition-fast);
}

.db-filter-dropdown__option:hover {
  background: var(--color-surface-hover);
}

.db-filter-dropdown__option span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.db-filter-checkbox {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.db-filter-dropdown__actions {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--color-border-light);
  background: var(--color-surface);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.btn-sm {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
}

.db-filter-clear {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  cursor: pointer;
}

.db-filter-clear:hover {
  background: var(--color-surface-hover);
}
