/* ============================================================
   DANZFLO — Category Management (Merch)
   ============================================================ */

.cat-page {
  position: relative;
  background:
    radial-gradient(ellipse 80% 50% at 0% 0%, rgba(37, 99, 235, 0.06), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(236, 72, 153, 0.05), transparent 50%),
    var(--bg, #f8fafc);
}

.cat-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  mask-image: linear-gradient(180deg, #000 0%, transparent 70%);
}

.cat-page > * {
  position: relative;
  z-index: 1;
}

/* ---- Page header ---- */
.cat-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.cat-page-badge {
  display: inline-flex;
  padding: 0.25rem 0.625rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #db2777;
  background: rgba(236, 72, 153, 0.1);
  border: 1px solid rgba(236, 72, 153, 0.18);
  border-radius: 9999px;
}

.cat-page-title {
  margin-top: 0.625rem;
  font-size: clamp(1.375rem, 2.5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.cat-page-subtitle {
  margin-top: 0.375rem;
  font-size: 0.875rem;
  color: var(--muted, #64748b);
}

.cat-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6875rem 1.125rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  border: none;
  border-radius: 0.75rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cat-add-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.28);
}

/* ---- Stats ---- */
.cat-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.875rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 767px) {
  .cat-stats-grid {
    grid-template-columns: 1fr;
  }
}

.cat-stat-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 1rem 1.125rem;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 0.875rem;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}

.cat-stat-card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  flex-shrink: 0;
}

.cat-stat-card__icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

.cat-stat-card--blue .cat-stat-card__icon {
  color: #2563eb;
  background: rgba(37, 99, 235, 0.12);
}

.cat-stat-card--purple .cat-stat-card__icon {
  color: #7c3aed;
  background: rgba(124, 58, 237, 0.12);
}

.cat-stat-card--green .cat-stat-card__icon {
  color: #16a34a;
  background: rgba(22, 163, 74, 0.12);
}

.cat-stat-card__label {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: #64748b;
}

.cat-stat-card__value {
  margin: 0.125rem 0 0;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #0f172a;
}

/* ---- Panel ---- */
.cat-panel {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-lg, 1rem);
  box-shadow:
    0 4px 24px rgba(15, 23, 42, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  overflow: hidden;
}

.cat-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.875rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(226, 232, 240, 0.85);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.9));
}

.cat-search {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.cat-search-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: #94a3b8;
  pointer-events: none;
}

.cat-search-input {
  width: 100%;
  height: 2.5rem;
  padding: 0 0.875rem 0 2.5rem;
  font-size: 0.875rem;
  color: var(--text, #0f172a);
  background: #fff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 0.75rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cat-search-input:focus {
  border-color: var(--primary, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.cat-count {
  font-size: 0.8125rem;
  color: var(--muted, #64748b);
}

/* ---- Table ---- */
.cat-table-wrap {
  padding: 1rem;
}

.cat-table-inner {
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 0.875rem;
}

.cat-table {
  width: 100%;
  min-width: 640px;
  border-collapse: separate;
  border-spacing: 0;
}

.cat-table th {
  padding: 1rem 1.125rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-align: left;
  color: var(--muted, #64748b);
  background: rgba(241, 245, 249, 0.95);
  border-bottom: 1px solid var(--border, #e2e8f0);
  white-space: nowrap;
}

.cat-table thead tr:first-child th:first-child {
  border-top-left-radius: calc(0.875rem - 1px);
}

.cat-table thead tr:first-child th:last-child {
  border-top-right-radius: calc(0.875rem - 1px);
}

.cat-table th.cat-th-sort {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease;
}

.cat-table th.cat-th-sort:hover {
  color: #334155;
}

.cat-th-sort-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.cat-sort-icon {
  width: 0.875rem;
  height: 0.875rem;
  color: #94a3b8;
}

.cat-table th.text-right,
.cat-table td.text-right {
  text-align: right;
}

.cat-table td {
  padding: 0.9375rem 1.125rem;
  font-size: 0.875rem;
  color: #334155;
  vertical-align: middle;
  border-bottom: 1px solid rgba(226, 232, 240, 0.85);
}

.cat-table tbody tr:last-child td {
  border-bottom: none;
}

.cat-table tbody tr:hover {
  background: rgba(37, 99, 235, 0.025);
}

.cat-row.hidden-by-search {
  display: none;
}

.cat-row.is-expanded > td {
  background: rgba(37, 99, 235, 0.02);
}

.cat-name-cell {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
}

.cat-tree-indent {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.cat-tree-line {
  width: 1rem;
  height: 1px;
  background: #cbd5e1;
  margin-right: 0.25rem;
}

.cat-expand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.625rem;
  height: 1.625rem;
  padding: 0;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1;
  color: #64748b;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.4375rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.cat-expand:hover {
  color: #2563eb;
  border-color: rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.06);
}

.cat-row.is-expanded > td .cat-expand {
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

.cat-expand.is-empty {
  visibility: hidden;
  pointer-events: none;
}

.cat-name-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.cat-name {
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
}

.cat-slug {
  font-size: 0.75rem;
  color: #94a3b8;
}

.cat-depth-badge {
  display: inline-flex;
  padding: 0.125rem 0.4375rem;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  flex-shrink: 0;
}

.cat-table th.cat-th-image,
.cat-table th:nth-child(2),
.cat-table td.cat-td-image {
  width: 5.5rem;
  text-align: center;
  vertical-align: middle;
}

.cat-thumb-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  background: linear-gradient(135deg, #2563eb, #ec4899);
  border-radius: 0.5rem;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
  line-height: 0;
  vertical-align: middle;
}

.cat-thumb-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: #fff;
  border-radius: calc(0.5rem - 2px);
  overflow: hidden;
}

.cat-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  padding: 0.3125rem;
  background: #fff;
}

.cat-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.cat-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.125rem;
  height: 2.125rem;
  padding: 0;
  background: #fff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cat-action-btn svg {
  width: 1rem;
  height: 1rem;
}

.cat-action-btn--delete {
  color: #fff;
  background: #ef4444;
  border-color: #ef4444;
}

.cat-action-btn--delete:hover {
  background: #dc2626;
  border-color: #dc2626;
}

.cat-action-btn--edit {
  color: #2563eb;
}

.cat-action-btn--edit:hover {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.35);
}

/* ---- Pagination ---- */
.cat-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid rgba(241, 245, 249, 0.9);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.5), rgba(255, 255, 255, 0.8));
}

.cat-pagination[hidden] {
  display: none;
}

.cat-page-nav,
.cat-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.125rem;
  height: 2.125rem;
  padding: 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #64748b;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cat-page-nav svg {
  width: 1rem;
  height: 1rem;
}

.cat-page-nav:hover:not(:disabled),
.cat-page-btn:hover {
  color: #2563eb;
  border-color: #93c5fd;
  background: rgba(37, 99, 235, 0.04);
}

.cat-page-nav:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.cat-page-nums {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.cat-page-btn.active {
  color: #2563eb;
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.06);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.12);
}

/* ---- Modals ---- */
.cat-modal .modal-body {
  padding: 1.25rem 1.35rem;
}

.cat-form-input,
.cat-form-select {
  width: 100%;
  height: 2.75rem;
  padding: 0 0.875rem;
  font-size: 0.875rem;
  color: var(--text, #0f172a);
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.625rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.cat-form-input:hover,
.cat-form-select:hover {
  background: #fff;
  border-color: #cbd5e1;
}

.cat-form-input:focus,
.cat-form-select:focus {
  background: #fff;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.cat-form-select {
  appearance: none;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  cursor: pointer;
}

.cat-file-field {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-height: 2.75rem;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.02);
}

.cat-file-name {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 2.75rem;
  margin: 0;
  padding: 0 1rem;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1;
  color: #94a3b8;
  background: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-file-browse {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  margin: 0;
  padding: 0 1.25rem;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.01em;
  color: #0f172a;
  background: #e8edf3;
  border: none;
  border-left: 1px solid #e2e8f0;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.cat-file-browse:hover {
  background: #dde4ec;
  color: #0f172a;
}

.cat-file-field:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.cat-file-field.has-file .cat-file-name {
  color: #334155;
  font-weight: 500;
}

.cat-image-preview-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  margin-top: 0.75rem;
  background: linear-gradient(135deg, #2563eb, #ec4899);
  border-radius: 0.625rem;
  line-height: 0;
}

.cat-image-preview-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4.5rem;
  height: 4.5rem;
  background: #fff;
  border-radius: calc(0.625rem - 3px);
  overflow: hidden;
}

.cat-image-preview {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  padding: 0.375rem;
  background: #fff;
}

.cat-image-preview[hidden],
.cat-image-preview-wrap[hidden] {
  display: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  width: 100%;
  max-width: 520px;
  max-height: min(90vh, 720px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.25);
  overflow: hidden;
  animation: cat-modal-in 0.25s ease;
}

@keyframes cat-modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.125rem 1.35rem;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.modal-title {
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  font-size: 1.5rem;
  line-height: 1;
  color: #94a3b8;
  background: transparent;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
}

.modal-close:hover {
  color: #0f172a;
  background: #f1f5f9;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.35rem;
  border-top: 1px solid var(--border, #e2e8f0);
  background: #f8fafc;
}

.modal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.125rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 0.625rem;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-btn--text {
  color: #0f172a;
  background: transparent;
}

.modal-btn--text:hover {
  background: #e2e8f0;
}

.modal-btn--dark {
  color: #fff;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
}

.modal-btn--dark:hover {
  background: linear-gradient(135deg, #1e293b, #334155);
}

.form-group {
  margin-bottom: 1.125rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text, #0f172a);
}

/* ---- Delete popover ---- */
.cat-delete-popover {
  position: fixed;
  z-index: 70;
  width: 14rem;
  padding: 1rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.2);
}

.cat-delete-popover[hidden] {
  display: none;
}

.cat-delete-popover::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -0.4375rem;
  width: 0.875rem;
  height: 0.875rem;
  background: #fff;
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  transform: translateX(-50%) rotate(45deg);
}

.cat-delete-popover-body {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  margin-bottom: 0.875rem;
}

.cat-delete-popover-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  color: #fff;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.35);
}

.cat-delete-popover-icon svg {
  display: block;
  width: 0.875rem;
  height: 0.875rem;
  flex-shrink: 0;
}

.cat-delete-popover-text {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.4;
}

.cat-delete-popover-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.cat-pop-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.25rem;
  padding: 0.4375rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 0.4375rem;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cat-pop-btn--cancel {
  color: #334155;
  background: #fff;
}

.cat-pop-btn--cancel:hover {
  background: #f8fafc;
}

.cat-pop-btn--ok {
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.cat-pop-btn--ok:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
}
