/* ==========================================================
   VDTM Components – единый файл стилей
   ========================================================== */

/* ---------- CSS-переменные ---------- */
:root {
  --nav-height: 42px;
  --nav-bg-start: #1e1e2c;
  --nav-bg-end: #2d2d44;
  --nav-shadow: 0 4px 12px rgba(0,0,0,.25);
  --nav-hover-bg: rgba(255,255,255,.12);
  --nav-active-line: #00d2ff;
}

/* ---------- Общие ---------- */
body {
  background-color: #f8f9fa;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  margin: 0;
  padding: 0;
}

/* ---------- Шапка ---------- */
.navbar > .container { align-items: center; }

@media (min-width: 1200px) {
  .navbar > .container { max-width: 1440px; }
}

.navbar .btn,
.navbar .nav-link,
.navbar .dropdown-toggle {
  height: var(--nav-height);
  display: inline-flex;
  align-items: center;
  padding: 0 .75rem;
  font-size: .90rem;
  white-space: nowrap;
  transition: background .2s;
}

.navbar .dropdown-toggle::after { margin-left: .35rem; }

.navbar .btn:hover,
.navbar .nav-link:hover {
  background: var(--nav-hover-bg);
  box-shadow: 0 0 0 1px rgba(255,255,255,.25);
}

.navbar .btn.active,
.navbar .nav-link.active {
  background: rgba(0,0,0,.15);
  box-shadow: inset 0 -3px 0 var(--nav-active-line);
}

.navbar-brand { margin: 0; padding: 0; display: flex; align-items: center; gap: .5rem; }
.navbar-collapse { transition: height .35s ease; }

.dropdown-toggle .text-end {
  max-width: 220px;
  overflow: hidden;
  text-align: right;
}
.dropdown-toggle .text-end .fw-bold,
.dropdown-toggle .text-end .small {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 992px) {
  .dropdown-toggle .text-end { text-align: left; max-width: 150px; }
}

.navbar {
  background: linear-gradient(135deg, var(--nav-bg-start) 0%, var(--nav-bg-end) 100%);
  box-shadow: var(--nav-shadow);
  z-index: 1050;
  position: relative;
  margin: 0;
  padding: .5rem 1rem;
}

@media (min-width: 992px) and (max-width: 1199px) {
  .navbar-nav.mx-auto { flex-wrap: nowrap; }
  .navbar-nav .nav-item { margin: 0 .15rem; }
  .navbar-nav .btn { font-size: .825rem; padding: 0 .60rem; }
}

@media (max-width: 576px) {
  .navbar .btn { width: 100%; justify-content: flex-start; margin-bottom: .25rem; }
}

.navbar-toggler { border: none; padding: 0; }
.navbar-toggler:focus { box-shadow: none; }

.navbar-nav { margin: 0; }
.navbar .dropdown-toggle .text-end { margin: 0; padding: 0; }

.navbar-brand { margin-right: 0 !important; padding: 0.5rem 0 !important; }
.navbar .container {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  width: 100% !important;
}
.navbar-collapse { flex-grow: 0 !important; }
.navbar-nav.ms-auto {
  margin-left: auto !important;
  margin-right: 0 !important;
}

@media (max-width: 992px) {
  .navbar-brand { flex-shrink: 0 !important; }
  .navbar-toggler { order: 2 !important; }
  .navbar-collapse { order: 3 !important; width: 100% !important; }
  .navbar-nav { margin-top: 1rem; }
  .navbar-nav .nav-item { margin-bottom: 0.5rem; margin-right: 0; }
  .navbar .btn { width: 100%; text-align: left; padding: 0.5rem 1rem; }
  .dropdown-menu { width: 100%; }
}

.navbar .btn {
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  transition: all 0.2s;
  white-space: nowrap;
}
.navbar .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.navbar .btn-outline-light:hover { background-color: rgba(255,255,255,0.1); }
.navbar .btn-outline-light.active { background-color: rgba(255,255,255,0.2); }

.navbar .dropdown-toggle .text-end {
  max-width: 190px;
  min-width: 0;
  overflow: hidden;
}
.navbar .dropdown-toggle .text-end .small,
.navbar .dropdown-toggle .text-end .fw-bold {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 190px;
  text-align: right;
}

@media (max-width: 992px) {
  .navbar .dropdown-toggle .text-end,
  .navbar .dropdown-toggle .text-end .small,
  .navbar .dropdown-toggle .text-end .fw-bold {
    max-width: 120px;
    text-align: left;
  }
}

/* ---------- Выпадающие меню ---------- */
.dropdown-menu {
  border: none;
  border-radius: .5rem;
  box-shadow: 0 .5rem 1rem rgba(0,0,0,.15);
  margin-top: .5rem;
  z-index: 1060 !important;
}
.dropdown-item {
  border-radius: .25rem;
  padding: 0.5rem 1rem;
  transition: all 0.2s;
}
.dropdown-item:hover { background-color: rgba(0,0,0,0.05); }

/* ---------- Основной контент ---------- */
.main-container {
  padding: 0.5rem;
  max-width: 100%;
  margin: 0 auto;
}

.container-fluid {
  padding-right: 0;
  padding-left: 0;
}

@media (min-width: 1200px) {
  .container-fluid {
    max-width: 100%;
  }
}

/* ---------- Карточки ---------- */
.card {
  border: none;
  border-radius: 0.5rem;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  margin-bottom: 1.5rem;
}
.card-header {
  background-color: #f8f9fa;
  border-bottom: 1px solid rgba(0,0,0,.125);
  font-weight: 600;
  padding: 1rem 1.25rem;
}
.card.rounded-0 {
  border-radius: 0 !important;
  border-left: none;
  border-right: none;
}
.card .card-body {
  padding: 0.75rem;
}

/* ---------- Таблицы ---------- */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0;
  padding: 0;
}
.table {
  margin-bottom: 0;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.table th {
  white-space: nowrap;
  background-color: #f8f9fa;
  padding: 0.5rem;
  vertical-align: middle;
}
.table td {
  padding: 0.5rem;
  vertical-align: middle;
  border-top: 1px solid #dee2e6;
}
.table.m-0 { margin: 0 !important; }
.table-striped tbody tr:nth-of-type(odd) { background-color: rgba(0, 0, 0, 0.02); }
.table-hover tbody tr:hover { background-color: rgba(0, 0, 0, 0.04); }
.table td:empty::before { content: "—"; color: #6c757d; }

/* ---------- Компактная таблица пользователей ---------- */
.users-table {
  font-size: 0.85rem;
  white-space: nowrap;
}
.users-table th,
.users-table td {
  padding: 0.4rem 0.5rem;
  vertical-align: middle;
}
.users-table .btn-sm {
  padding: 0.2rem 0.4rem;
  font-size: 0.75rem;
}
.users-table td {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.users-table td:last-child {
  max-width: none;
  overflow: visible;
}

/* ---------- Формы ---------- */
.form-control, .form-select {
  margin-bottom: 1rem;
  border-radius: 0.375rem;
  border: 1px solid #ced4da;
}
.form-label {
  font-weight: 500;
  margin-bottom: 0.5rem;
}
.form-label.required::after { content: " *"; color: #dc3545; }

.form-control:focus, 
.form-select:focus {
  border-color: #86b7fe;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
  outline: none;
  transform: translateY(-1px);
}

.form-control, .form-select, .form-check-input {
  transition: all 0.15s ease-in-out;
}

.form-check-input:checked {
  background-color: #0d6efd;
  border-color: #0d6efd;
}
.form-check-input:focus {
  border-color: #86b7fe;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.form-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}
.form-section {
  background: white;
  border-radius: 0.5rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  border: 1px solid rgba(0,0,0,.125);
}
.form-section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid #0d6efd;
  color: #0d6efd;
}
.form-group-required .form-label::after { content: " *"; color: #dc3545; }
.form-text { font-size: 0.875rem; margin-top: 0.25rem; }

/* ---------- Кнопки ---------- */
.btn {
  border-radius: 0.375rem;
  font-weight: 500;
  transition: all 0.2s;
}
.btn-group { flex-wrap: nowrap; }
.btn-group .btn { padding: 0.375rem 0.75rem; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.875rem; }
.btn-action-group {
  background: #f8f9fa;
  padding: 1.5rem;
  border-radius: 0.5rem;
  border-top: 2px solid #0d6efd;
  margin-top: 2rem;
}

/* ---------- Бейджи ---------- */
.badge {
  font-weight: 500;
  padding: 0.35em 0.65em;
  border-radius: 0.25rem;
  font-size: 0.875em;
}

/* ---------- Иконки ---------- */
.bi { vertical-align: middle; font-size: 1.1em; }

/* ---------- Select2 ---------- */
.select2-container--default .select2-selection--multiple {
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  min-height: 38px;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
  background-color: #0d6efd;
  border-color: #006fe6;
  color: white;
  margin: 3px;
  padding: 2px 5px;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
  color: white;
  margin-right: 5px;
}
.select2-container--default .select2-search--inline .select2-search__field {
  margin-top: 0;
  height: auto;
}
.select2-container--default.select2-container--focus .select2-selection--multiple {
  border-color: #86b7fe;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}
.select2-container--open .select2-dropdown { z-index: 9999 !important; }

/* ---------- Статусы ---------- */
.bg-in_stock { background-color: #0d6efd !important; }
.bg-awaiting_inspection { background-color: #ffc107 !important; color: #212529 !important; }
.bg-awaiting_ati { background-color: #fd7e14 !important; }
.bg-in_progress { background-color: #dc3545 !important; }
.bg-processing { background-color: #6f42c1 !important; }
.bg-completed { background-color: #198754 !important; }
.bg-scrap { background-color: #601812 !important; }
.bg-ccl { background-color: #c5cc25 !important; }

/* ---------- Карточки задач ---------- */
.list-group-item {
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border: 1px solid rgba(0, 0, 0, 0.125);
  margin-bottom: -1px;
}
.completed-task {
  background-color: rgba(40, 167, 69, 0.08);
  border-left: 3px solid #28a745;
}
.completed-task .task-text { text-decoration: line-through; color: #6c757d; }
.task-content { display: flex; align-items: center; flex-grow: 1; }
.task-text { transition: all 0.3s ease; word-break: break-word; margin-left: 0.5rem; }
.task-date { min-width: 120px; text-align: right; font-size: 0.85rem; color: #6c757d; }

/* ---------- Журнал изменений ---------- */
.changelog-preview, .changelog-full { max-height: 300px; overflow-y: auto; }
.timeline-item { padding: 0.75rem 1.25rem; border-bottom: 1px solid #eee; }
.timeline-item:last-child { border-bottom: none; }
.timeline-item-header { display: flex; justify-content: space-between; margin-bottom: 0.25rem; font-size: 0.9rem; }
.timeline-item-body { font-size: 0.85rem; color: #555; }
.toggle-changelog { padding: 0.25rem 0.5rem; font-size: 0.85rem; }

/* ---------- Модальные окна ---------- */
.modal-content { border: none; border-radius: 0.5rem; }
.modal-header { border-bottom: 1px solid #dee2e6; }
.modal-footer { border-top: 1px solid #dee2e6; }
.modal-dialog { margin: 1.75rem auto; }

/* ---------- Валидация ---------- */
.is-invalid { border-color: #dc3545; animation: shake 0.5s ease-in-out; }
.invalid-feedback { color: #dc3545; font-size: 0.875em; margin-top: 0.25rem; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

.was-validated .form-control:valid,
.was-validated .form-select:valid {
  border-color: #198754;
}
.was-validated .form-control:invalid,
.was-validated .form-select:invalid {
  border-color: #dc3545;
}

/* ---------- Упаковка ---------- */
.packaging-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.packaging-option {
  flex: 1;
  min-width: 120px;
  text-align: center;
  padding: 0.75rem;
  border: 2px solid #dee2e6;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.2s;
}
.packaging-option:hover { border-color: #86b7fe; background-color: #f8f9fa; }
.packaging-option.active { border-color: #0d6efd; background-color: #e8f4ff; font-weight: 600; }

/* ---------- Статистика ---------- */
.card-counter {
  box-shadow: 2px 2px 10px rgba(0,0,0,0.2);
  padding: 20px 10px;
  border-radius: 5px;
  transition: .3s linear all;
}
.card-counter:hover { box-shadow: 4px 4px 20px rgba(0,0,0,0.3); transition: .3s linear all; }
.card-counter.primary { background-color: #0d6efd; color: #FFF; }
.card-counter.warning { background-color: #ffc107; color: #000; }
.card-counter.danger { background-color: #dc3545; color: #FFF; }
.card-counter.success { background-color: #198754; color: #FFF; }
.card-counter.info { background-color: #0dcaf0; color: #000; }
.card-counter i { font-size: 3em; opacity: 0.3; }
.card-counter .count-numbers { font-size: 2em; display: block; }
.card-counter .count-name { font-style: italic; opacity: 0.8; display: block; }

/* ---------- Адаптация для мобильных ---------- */
@media (max-width: 768px) {
  .table-responsive { border: 0; }
  .table thead { display: none; }
  .table tr { display: block; margin-bottom: 1rem; border: 1px solid #dee2e6; border-radius: 0.25rem; }
  .table td { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #dee2e6; }
  .table td::before { content: attr(data-label); font-weight: bold; margin-right: 1rem; flex: 1; }
  .table td:last-child { border-bottom: 0; }
  .btn-group .btn { padding: 0.25rem; }
  .btn-group .btn .bi { font-size: 1rem; }
  .changelog-preview, .changelog-full { max-height: 200px; }
  .timeline-item { padding: 0.5rem; }
  .list-group-item { flex-direction: column; align-items: flex-start; }
  .task-date { margin-top: 0.5rem; align-self: flex-end; }
  .form-container { padding: 0.5rem; }
  .form-section { padding: 1rem; margin-bottom: 1rem; }
  .form-section-title { font-size: 1.1rem; }
  .btn-action-group { padding: 1rem; }
}

@media (max-width: 576px) {
  .d-md-flex { flex-direction: column; }
  .btn { width: 100%; margin-bottom: 0.5rem; }
  textarea.form-control { min-height: 100px; }
}