/* ═══════════════════════════════════════════════════════════════════
   PRODUCT CARD (FULL SCREEN VIEW) STYLING
   ═══════════════════════════════════════════════════════════════════ */
#view-product-card {
  background: var(--bg-root);
  animation: fadeIn 0.25s ease-out;
}

.product-toolbar {
  border-bottom: 1px solid var(--border);
}

.product-card-grid {
  margin-top: 10px;
}

.product-fields-col label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.product-fields-col input,
.product-fields-col select,
.product-fields-col datalist {
  outline: none;
  transition: border-color var(--fast);
}

.product-fields-col input:focus,
.product-fields-col select:focus {
  border-color: var(--border-focus) !important;
  box-shadow: 0 0 0 2px var(--brand-glow);
}

.history-list-wrap::-webkit-scrollbar {
  width: 4px;
}

.history-item {
  border: 1px solid var(--border);
  transition: transform 0.15s ease;
}

.history-item:hover {
  transform: translateY(-2px);
  border-color: rgba(79, 142, 247, 0.2);
}

.product-link {
  color: var(--brand);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 600;
}

.product-link:hover {
  color: var(--brand-dark);
}

.wysiwyg-toolbar button {
  border-radius: var(--r-sm);
  color: var(--text-secondary);
}

.wysiwyg-toolbar button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Products Catalog Custom CSS ── */
.products-tabs .btn {
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--t-fast);
}

.products-tabs .btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.category-header-row:hover {
  background: var(--bg-hover) !important;
  opacity: 0.95;
}

.category-tree-row {
  background: rgba(79, 142, 247, 0.07);
  cursor: grab;
  user-select: none;
}

.category-tree-row.dragging {
  opacity: 0.4;
  background: var(--bg-hover) !important;
}

.category-tree-row.drag-over-top td {
  border-top: 2px solid var(--brand) !important;
}

.category-tree-row.drag-over-bottom td {
  border-bottom: 2px solid var(--brand) !important;
}

.category-tree-row td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
}

.tree-row-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.tree-category-inner {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.tree-toggle {
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}

.tree-toggle:hover {
  color: var(--brand);
}

.tree-folder-icon,
.tree-file-icon {
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
}

.tree-category-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-category-count {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 12px;
  flex-shrink: 0;
}

.cat-commission-cell {
  text-align: right;
  padding: 4px 6px !important;
  vertical-align: middle;
}

.cat-commission-input {
  width: 100%;
  max-width: 58px;
  padding: 3px 5px;
  font-size: 12px;
  text-align: right;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: text;
}

.cat-commission-input:focus {
  border-color: var(--brand);
  outline: none;
}

.tree-product-inner {
  min-width: 0;
}

.tree-connector {
  color: var(--text-muted);
  font-family: monospace;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
  width: 12px;
}

.tree-muted {
  color: var(--text-muted);
}

.product-tree-row td {
  background: var(--bg-root);
}

.product-tree-row:hover td {
  background: rgba(79, 142, 247, 0.04);
}

.product-catalog-row:hover {
  background: rgba(79, 142, 247, 0.04) !important;
}

.product-catalog-row td {
  padding: 8px 10px;
}

#btnActiveProductsFilter.active,
#btnDeletedProductsFilter.active {
  font-weight: 600;
}

.products-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.products-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.products-toolbar-right {
  flex-shrink: 0;
}

.products-catalog-table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.products-catalog-table-wrap .orders-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-card);
}

/* Custom header select filter dropdowns */
.th-content.flex-column {
  flex-direction: column !important;
  align-items: stretch !important;
}

/* Настройки шапки каталога товаров: 2 строки и узкие колонки цен */
.products-catalog-table-wrap .orders-table thead th {
  white-space: normal !important;
  vertical-align: bottom !important;
  font-size: 10px !important;
  line-height: 1.2 !important;
  padding: 6px 4px !important;
  text-transform: none !important;
}

.products-catalog-table-wrap .product-tree-row td {
  padding: 4px 6px !important;
  vertical-align: middle;
}

.products-catalog-table-wrap .orders-table td {
  padding: 6px 4px !important;
  font-size: 11px !important;
}

.tree-product-inner .catalog-product-cell {
  flex: 1;
  min-width: 0;
}


/* HTML Визуальный редактор (WYSIWYG) описаний товаров */
.rich-editor-container {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-input);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin-top: 8px;
}

.rich-editor-toolbar {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding: 6px 10px;
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.rich-editor-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-size: 11px;
  cursor: pointer;
  padding: 4px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  font-weight: 500;
  transition: all var(--t-fast);
  gap: 4px;
}

.rich-editor-btn:hover {
  background: var(--bg-hover);
  color: var(--brand);
  border-color: var(--border);
}

.rich-editor-btn.active {
  background: var(--brand-glow);
  color: var(--brand);
  border-color: rgba(79, 142, 247, 0.2);
  font-weight: 600;
}

.rich-editor-content {
  min-height: 220px;
  padding: 12px;
  color: var(--text-primary);
  outline: none;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  background: transparent;
}

.rich-editor-content p {
  margin-bottom: 10px;
}

.rich-editor-container textarea {
  display: none;
  border: none !important;
  background: var(--bg-input) !important;
  color: var(--text-primary) !important;
  resize: vertical;
  min-height: 220px;
  padding: 12px !important;
  margin: 0 !important;
  outline: none !important;
  font-family: monospace !important;
  font-size: 12px !important;
  line-height: 1.4 !important;
  overflow-y: hidden;
}

/* ── Custom Multi-Select Dropdown (Labels / Ярлыки) ────────────────── */
.custom-multiselect-container {
  position: relative;
  width: 100%;
}

.custom-multiselect-trigger {
  width: 100%;
  min-height: 38px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  cursor: pointer;
  box-sizing: border-box;
}

/* ── Страница каталога ── */
.products-page {
  padding: 20px;
  width: 100%;
}

.products-top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 15px;
  flex-wrap: wrap;
  background: var(--bg-panel);
  padding: 12px 15px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}

.products-page-title {
  font-size: 20px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0;
  flex-shrink: 0;
  white-space: nowrap;
}

.products-filter-search {
  flex: 1;
  min-width: 200px;
}

.products-filter-category {
  width: 180px;
  flex-shrink: 0;
}

.catalog-search-hint {
  text-align: center;
  padding: 10px;
  color: var(--text-secondary);
  font-size: 12px;
}

.products-catalog-table-wrap.products-catalog--search .orders-table th:nth-child(12),
.products-catalog-table-wrap.products-catalog--search .orders-table td:nth-child(12) {
  display: none;
}


.products-page-header {
  display: none;
}

.form-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

.form-input--sm {
  width: auto;
  padding: 6px 12px;
  font-size: 12px;
}

.btn-add-product {
  background: #5cb85c;
  color: white;
  padding: 5px 14px;
  border-radius: var(--r-sm);
  font-weight: 500;
  font-size: 12px;
}

.active-products-btn.active {
  background: var(--brand-glow);
  border: 1px solid rgba(79, 142, 247, 0.2);
  color: var(--brand);
}

/* ── Строки каталога ── */
.col-check { text-align: center; }
.col-check input { cursor: pointer; }
.col-num { text-align: right; }
.col-muted { color: var(--text-secondary); font-family: monospace; }
.col-price { font-weight: bold; color: var(--brand); font-family: monospace; }
.col-id { font-family: monospace; font-weight: 500; }
.catalog-id { font-size: 11px; font-weight: 600; }
.col-actions { text-align: center; }
.stock-low { color: var(--status-new); font-weight: bold; }
.catalog-stock-min { font-size: 9px; color: var(--text-muted); font-weight: normal; }
.catalog-label-badge {
  background: var(--brand-glow);
  color: var(--brand);
  border: 1px solid rgba(79, 142, 247, 0.1);
  font-size: 10px;
  padding: 2px 6px;
}
.catalog-product-cell {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.catalog-product-name-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  flex: 1;
}
.products-catalog-table-wrap .catalog-product-thumb {
  width: 28px;
  height: 28px;
  max-width: 28px;
  max-height: 28px;
  min-width: 28px;
  min-height: 28px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  flex-shrink: 0;
  display: block;
}
.catalog-product-thumb--empty {
  width: 28px;
  height: 28px;
  max-width: 28px;
  max-height: 28px;
  min-width: 28px;
  min-height: 28px;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-muted);
}
.catalog-actions {
  display: flex;
  gap: 4px;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.catalog-actions .btn { padding: 4px 8px; font-size: 11px; }

.catalog-category {
  font-size: 11px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  max-width: 110px;
}
.btn-product-delete { color: var(--status-new); font-weight: bold; }
.btn-product-restore { color: #5cb85c; font-weight: bold; }

/* ── Страница карточки товара ── */
.product-card-page {
  padding: 20px;
  overflow-y: auto;
  height: 100vh;
  width: 100%;
}

.product-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 15px;
}

.product-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.product-toolbar-right {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.product-breadcrumb {
  font-size: 13px;
  color: var(--text-secondary);
}

.product-breadcrumb a {
  color: var(--brand);
}

.product-card-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.product-card-grid {
  display: grid;
  grid-template-columns: 280px 1fr 1.2fr;
  gap: 20px;
  align-items: start;
}

.product-photos-col,
.product-fields-col,
.product-side-tabs-col {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.product-fields-col,
.product-side-tabs-col,
.product-description-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px;
}

.main-photo-box {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  width: 100%;
  position: relative;
}

#productMainPhoto {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#productNoPhotoPlaceholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  gap: 8px;
}

.thumbs-box {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.product-photos-empty {
  color: var(--text-secondary);
  font-size: 12px;
  padding: 10px;
  text-align: center;
  grid-column: span 4;
}

.thumb-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-card);
  cursor: pointer;
  border: 1px solid var(--border);
}

.thumb-item--main {
  border: 2px solid var(--brand);
}

.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn-photo-delete {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
}

.product-card-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}

.side-tabs-header {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 15px;
  padding-bottom: 10px;
  margin-bottom: 5px;
}

.side-tab-btn {
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 0;
  border-bottom: 2px solid transparent;
  outline: none;
}

.side-tab-btn.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.side-tab-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

#productCharsContainer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 480px;
  overflow-y: auto;
}

.char-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.char-row input {
  padding: 6px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  min-width: 0;
}

.char-row .char-name { flex: 1; }
.char-row .char-value { flex: 2; }

.product-history-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-secondary);
}

.hist-head,
.hist-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hist-type { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.hist-date { font-size: 10px; color: var(--text-muted); }
.hist-qty { font-size: 13px; font-weight: 700; }
.hist-qty--plus { color: #4ade80; }
.hist-qty--minus { color: #ef4444; }
.hist-balance { font-size: 11px; color: var(--text-secondary); }
.hist-price { font-size: 11px; color: var(--text-secondary); margin-top: 3px; }
.hist-comment {
  font-style: italic;
  font-size: 11px;
  margin-top: 4px;
  color: var(--text-secondary);
  border-left: 2px solid var(--border);
  padding-left: 6px;
}

.order-link { color: var(--brand); font-weight: 500; }

@media (max-width: 1200px) {
  .product-card-grid {
    grid-template-columns: 1fr;
  }
  .product-card-bottom {
    grid-template-columns: 1fr;
  }
}
