/* Scoped stylesheet for Quản lý danh mục table to match Documents table styles exactly and enforce 2-level indent formatting */

@media (min-width: 761px) {
  /* Fix: .table-wrap default has border-radius:12px which causes overflow:hidden
     and clips/hides the first tbody row when thead is sticky. Reset it here. */
  body[data-page="categories"] .categories-table-wrap {
    border-radius: 0 !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    border: 0 !important;
    box-shadow: none !important;
  }

  /* Fix: sticky thead must stick below the admin header so the first
     data row is never hidden behind the header bar. */
  body[data-page="categories"] table.cat-mgmt-table thead th {
    position: sticky !important;
    top: 0 !important;
    z-index: 4 !important;
  }

  body[data-page="categories"] table.cat-mgmt-table {
    table-layout: fixed !important;
    width: 100% !important;
    border-collapse: collapse !important;
    margin: 0 !important;
    background: #fff !important;
  }

   body[data-page="categories"] table.cat-mgmt-table th,
   body[data-page="categories"] table.cat-mgmt-table td {
     display: table-cell !important;
     vertical-align: middle !important;
     padding: 14px 16px !important;
     overflow: hidden !important;
     box-sizing: border-box !important;
     white-space: normal !important;
     text-overflow: ellipsis !important;
     border-bottom: 1px solid #edf2f7 !important;
     border-left: none !important;
     border-right: none !important;
     text-align: left !important;
   }

  body[data-page="categories"] table.cat-mgmt-table th {
    background: #f8fafc !important;
    color: #334155 !important;
    font-size: 13px !important;
    font-weight: 800 !important;
    border-bottom: 2px solid #e2e8f0 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
  }

  /* Column widths — 6 columns: 32% Tên, 16% Slug, 22% Mô tả, 12% Thứ tự, 10% Trạng thái, 8% Thao tác */
  body[data-page="categories"] table.cat-mgmt-table th:nth-child(1), body[data-page="categories"] table.cat-mgmt-table td:nth-child(1) { width: 32% !important; }
  body[data-page="categories"] table.cat-mgmt-table th:nth-child(2), body[data-page="categories"] table.cat-mgmt-table td:nth-child(2) { width: 16% !important; }
  body[data-page="categories"] table.cat-mgmt-table th:nth-child(3), body[data-page="categories"] table.cat-mgmt-table td:nth-child(3) { width: 22% !important; }
  body[data-page="categories"] table.cat-mgmt-table th:nth-child(4), body[data-page="categories"] table.cat-mgmt-table td:nth-child(4) { width: 12% !important; }
  body[data-page="categories"] table.cat-mgmt-table th:nth-child(5), body[data-page="categories"] table.cat-mgmt-table td:nth-child(5) { width: 10% !important; }
  body[data-page="categories"] table.cat-mgmt-table th:nth-child(6), body[data-page="categories"] table.cat-mgmt-table td:nth-child(6) { width: 8% !important; }

  /* Tree elements styling */
  body[data-page="categories"] .cat-tree-name {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    min-width: 0 !important;
  }

  body[data-page="categories"] .cat-tree-name.is-root {
    font-weight: 700 !important;
    color: #1e293b !important;
  }

  body[data-page="categories"] .cat-tree-name.is-child {
    font-weight: 500 !important;
    color: #475569 !important;
  }

  body[data-page="categories"] .cat-tree-toggle {
    flex-shrink: 0 !important;
    display: inline-grid !important;
    place-items: center !important;
    width: 22px !important;
    height: 22px !important;
    border: 1px solid #bfdbfe !important;
    border-radius: 6px !important;
    background: #eff6ff !important;
    color: #2563eb !important;
    font-size: 9px !important;
    line-height: 1 !important;
    cursor: pointer !important;
    padding: 0 !important;
  }

  body[data-page="categories"] .cat-tree-toggle:hover {
    background: #dbeafe !important;
    border-color: #93c5fd !important;
  }

  body[data-page="categories"] .cat-tree-spacer {
    flex-shrink: 0 !important;
    display: inline-block !important;
    width: 22px !important;
    height: 22px !important;
  }

  body[data-page="categories"] .cat-child-badge {
    flex-shrink: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 18px !important;
    padding: 0 6px !important;
    border-radius: 999px !important;
    background: #eff6ff !important;
    border: 1px solid #bfdbfe !important;
    color: #1d4ed8 !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
  }

  /* Description styling */
  body[data-page="categories"] .cat-desc-cell {
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: normal !important;
    color: #64748b !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
  }

  /* Order actions */
  body[data-page="categories"] .cat-order-actions {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
  }

  body[data-page="categories"] .cat-icon-btn {
    width: 32px !important;
    min-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  body[data-page="categories"] .cat-icon-btn:disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
  }

  /* Actions button layout matching documents exactly */
  body[data-page="categories"] .cat-actions-wrapper {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
  }

  body[data-page="categories"] .cat-actions-wrapper .btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 32px !important;
    min-height: 32px !important;
    padding: 0 12px !important;
    font-size: 12.5px !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
    white-space: nowrap !important;
  }
}

/* Mobile responsive styles - preserving card list formatting */
@media (max-width: 760px) {
  body[data-page="categories"] table.cat-mgmt-table {
    display: block !important;
    width: 100% !important;
    border: none !important;
    background: transparent !important;
  }

  body[data-page="categories"] table.cat-mgmt-table thead {
    display: none !important;
  }

  body[data-page="categories"] table.cat-mgmt-table tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
    width: 100% !important;
  }

  body[data-page="categories"] table.cat-mgmt-table tr {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 14px !important;
    padding: 16px !important;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05) !important;
    box-sizing: border-box !important;
  }

  body[data-page="categories"] table.cat-mgmt-table td {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
    border: none !important;
    text-align: left !important;
    overflow: visible !important;
  }

  body[data-page="categories"] table.cat-mgmt-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 4px;
  }

  body[data-page="categories"] .cat-tree-name {
    display: inline-flex !important;
    padding-left: 0 !important;
  }

  body[data-page="categories"] .cat-actions-wrapper,
  body[data-page="categories"] .cat-order-actions {
    display: flex !important;
    gap: 8px !important;
    margin-top: 6px;
  }

  body[data-page="categories"] .cat-actions-wrapper .btn {
    flex: 1 1 auto !important;
    justify-content: center !important;
    height: 36px !important;
  }
}
