/**
 * Tabelas do admin — confortáveis, responsivas, sem exagero.
 * Escopo: .main-panel apenas.
 */

/* Wrapper: scroll horizontal nativo quando precisar; sem gambiarra overflow:visible */
.main-panel .card.data-tables {
  overflow: hidden;
}

.main-panel .admin-table-shell,
.main-panel .card.data-tables > .table-responsive,
.main-panel .card.data-tables .dataTables_wrapper {
  width: 100%;
}

.main-panel .admin-table-shell {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.main-panel .card.data-tables .table-responsive.py-4 {
  padding: 0 !important;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.main-panel .card.data-tables .dataTables_wrapper {
  padding: 0;
}

/* Tabela base */
.main-panel .table,
.main-panel .admin-table,
.main-panel table.dataTable {
  margin: 0 !important;
  width: 100% !important;
  min-width: 640px;
  border-collapse: collapse !important;
  border-spacing: 0 !important;
  background: #fff;
  color: #1f2a37;
  font-size: 0.875rem;
  line-height: 1.4;
}

/* LBD força display:block no last-child — quebra o fundo do thead */
.main-panel .card .table thead th:last-child,
.main-panel .card .table tbody td:last-child,
.main-panel .card .admin-table thead th:last-child,
.main-panel .card .admin-table tbody td:last-child,
.main-panel .card table.dataTable thead th:last-child,
.main-panel .card table.dataTable tbody td:last-child {
  display: table-cell !important;
}

.main-panel .table thead,
.main-panel .admin-table thead,
.main-panel table.dataTable thead,
.main-panel .table thead tr,
.main-panel .admin-table thead tr,
.main-panel table.dataTable thead tr {
  background: #fafbfc;
}

.main-panel .table thead th,
.main-panel .table > thead > tr > th,
.main-panel .admin-table thead th,
.main-panel table.dataTable thead th,
.main-panel table.dataTable thead th.sorting,
.main-panel table.dataTable thead th.sorting_asc,
.main-panel table.dataTable thead th.sorting_desc,
.main-panel table.dataTable thead th.sorting_disabled {
  position: sticky;
  top: 0;
  z-index: 2;
  border: 0 !important;
  border-bottom: 1px solid #e8ecf0 !important;
  background: #fafbfc !important;
  color: #6b7280 !important;
  font-size: 0.75rem !important;
  font-weight: 600 !important;
  letter-spacing: 0;
  text-transform: none !important;
  padding: 0.75rem 1rem !important;
  vertical-align: middle !important;
  white-space: nowrap;
  box-sizing: border-box;
}

.main-panel .table > tbody > tr > td,
.main-panel .table td,
.main-panel .admin-table td,
.main-panel table.dataTable tbody td {
  padding: 0.85rem 1rem !important;
  vertical-align: middle !important;
  border: 0 !important;
  border-bottom: 1px solid #f0f2f5 !important;
  background: #fff !important;
  color: #374151;
}

.main-panel .table > tbody > tr:last-child > td,
.main-panel .admin-table > tbody > tr:last-child > td {
  border-bottom: 0 !important;
}

.main-panel .table > tbody > tr:hover > td,
.main-panel .admin-table > tbody > tr:hover > td,
.main-panel table.dataTable.hover tbody tr:hover > td,
.main-panel table.dataTable tbody tr:hover > td {
  background: #f7faf8 !important;
}

.main-panel .table.table-striped > tbody > tr:nth-of-type(odd) {
  background: transparent;
}

/* Sort DataTables — ícone colado ao texto (não absoluto / não FontAwesome) */
.main-panel table.dataTable thead .sorting,
.main-panel table.dataTable thead .sorting_asc,
.main-panel table.dataTable thead .sorting_desc,
.main-panel table.dataTable thead .sorting_asc_disabled,
.main-panel table.dataTable thead .sorting_desc_disabled {
  background-image: none !important;
  cursor: pointer;
  padding-right: 1rem !important;
}

.main-panel table.dataTable thead .sorting:before,
.main-panel table.dataTable thead .sorting_asc:before,
.main-panel table.dataTable thead .sorting_desc:before,
.main-panel table.dataTable thead .sorting_asc_disabled:before,
.main-panel table.dataTable thead .sorting_desc_disabled:before {
  display: none !important;
  content: none !important;
}

.main-panel table.dataTable thead .sorting:after,
.main-panel table.dataTable thead .sorting_asc:after,
.main-panel table.dataTable thead .sorting_desc:after,
.main-panel table.dataTable thead .sorting_asc_disabled:after,
.main-panel table.dataTable thead .sorting_desc_disabled:after {
  position: static !important;
  display: inline-block !important;
  top: auto !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  margin-left: 0.35rem;
  padding: 0;
  font-family: inherit !important;
  font-size: 0.625rem !important;
  font-weight: 600 !important;
  font-style: normal !important;
  line-height: 1 !important;
  vertical-align: 0.05em;
  opacity: 0.4;
  color: #9ca3af;
  content: "↕" !important;
  transform: none !important;
}

.main-panel table.dataTable thead .sorting_asc:after {
  content: "↑" !important;
  opacity: 0.85;
  color: #1db770;
}

.main-panel table.dataTable thead .sorting_desc:after {
  content: "↓" !important;
  opacity: 0.85;
  color: #1db770;
}

.main-panel table.dataTable thead .sorting_disabled:after,
.main-panel table.dataTable thead .disabled-sorting:after {
  display: none !important;
  content: none !important;
}

/* Ações */
.main-panel .admin-table__actions {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.375rem;
}

.main-panel .admin-table__action-form {
  display: inline-flex;
  margin: 0;
}

.main-panel .table .td-actions,
.main-panel .admin-table .td-actions,
.main-panel .admin-table__actions-col {
  white-space: nowrap;
  text-align: right;
  width: 1%;
}

.main-panel .admin-table .td-actions .btn,
.main-panel .admin-table .td-actions .btn-sm,
.main-panel .table .td-actions .btn,
.main-panel .table .td-actions .btn-sm {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 8px !important;
  border: 1px solid #e5e7eb !important;
  background: #fff !important;
  color: #4b5563 !important;
  box-shadow: none !important;
  font-size: 0;
  line-height: 1;
}

.main-panel .admin-table .td-actions .btn i,
.main-panel .table .td-actions .btn i {
  font-size: 0.875rem !important;
  margin: 0 !important;
  color: inherit !important;
}

.main-panel .admin-table .td-actions .btn:hover,
.main-panel .table .td-actions .btn:hover {
  background: #f3f4f6 !important;
  border-color: #d1d5db !important;
  color: #111827 !important;
}

.main-panel .admin-table .td-actions .btn-danger,
.main-panel .admin-table .td-actions .btn-confirm-delete,
.main-panel .table .td-actions .btn-danger {
  color: #dc2626 !important;
  border-color: #fecaca !important;
}

.main-panel .admin-table .td-actions .btn-danger:hover,
.main-panel .admin-table .td-actions .btn-confirm-delete:hover {
  background: #fef2f2 !important;
  color: #b91c1c !important;
}

.main-panel .admin-table .td-actions .btn-success,
.main-panel .admin-table .td-actions .btn-primary,
.main-panel .admin-table .td-actions .btn-info {
  color: #059669 !important;
  border-color: #bbf7d0 !important;
}

.main-panel .admin-table .dropdown-menu,
body > .dropdown-menu.admin-table-dd-menu-open {
  z-index: 3000 !important;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.1);
  padding: 0.35rem;
  max-height: min(70vh, 420px);
  overflow-y: auto;
  min-width: 12rem;
  background: #fff;
  opacity: 1 !important;
  visibility: visible !important;
  filter: none !important;
}

body > .dropdown-menu.admin-table-dd-menu-open .dropdown-item {
  display: block;
  width: 100%;
  clear: both;
  font-weight: 400;
  font-size: 0.8125rem;
  color: #374151;
  text-align: inherit;
  white-space: nowrap;
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 0.4rem 0.65rem;
}

body > .dropdown-menu.admin-table-dd-menu-open .dropdown-item:hover,
body > .dropdown-menu.admin-table-dd-menu-open .dropdown-item:focus {
  color: #111827;
  background: #f3f4f6;
  text-decoration: none;
}

body > .dropdown-menu.admin-table-dd-menu-open .dropdown-header {
  font-size: 0.6875rem;
  font-weight: 600;
  color: #9ca3af;
  padding: 0.35rem 0.65rem;
  margin: 0;
}

body > .dropdown-menu.admin-table-dd-menu-open .dropdown-divider {
  margin: 0.25rem 0;
  border-top: 1px solid #f0f2f5;
}

body > .dropdown-menu.admin-table-dd-menu-open .dropdown-item.small {
  white-space: normal;
}

/* Imagens / badges */
.main-panel .admin-table img,
.main-panel .table img {
  border-radius: 6px;
  max-height: 32px;
  width: auto;
  object-fit: cover;
}

.main-panel .admin-table__thumb {
  width: 32px;
  height: 32px;
  margin-right: 0.75rem;
}

.main-panel .admin-table__thumb img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.main-panel .admin-table__thumb-link {
  display: inline-flex;
  line-height: 0;
}

.main-panel .admin-table__product-thumb {
  width: 88px;
  height: 88px;
  border-radius: 8px;
  object-fit: cover;
  background: #f3f4f6;
  display: block;
}

.main-panel .admin-table__product-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 600;
  color: #1f2a37;
  line-height: 1.35;
  max-width: 280px;
}

.main-panel .admin-table td.td-name {
  white-space: normal;
  max-width: 280px;
}

.main-panel .admin-table td.td-price,
.main-panel .admin-table td.td-stock {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.main-panel .admin-table td.img-container {
  width: 1%;
  white-space: nowrap;
}

.main-panel .admin-table .badge,
.main-panel .table .badge {
  font-size: 0.625rem;
  font-weight: 600;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.25;
}

.main-panel .admin-plan-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  line-height: 1.3;
  min-width: 0;
}

.main-panel .admin-plan-cell__name {
  font-size: 0.8125rem;
  color: #374151;
  white-space: nowrap;
}

.main-panel .admin-plan-cell .badge {
  font-size: 0.5625rem;
  padding: 0.1rem 0.35rem;
  align-self: flex-start;
}

.main-panel .admin-date-cell,
.main-panel .admin-table td.admin-date-cell {
  white-space: nowrap !important;
  font-size: 0.8125rem;
  color: #6b7280;
  width: 1%;
}

.main-panel .admin-table td.td-plan {
  white-space: normal;
}

.main-panel .admin-table__pre {
  margin: 0;
  max-width: 24rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.75rem;
  color: #6b7280;
}

/* Toolbar DataTables */
.main-panel .dataTables_wrapper {
  font-size: 0.8125rem;
  color: #6b7280;
}

.main-panel .admin-dt-top,
.main-panel .admin-dt-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
}

.main-panel .admin-dt-top {
  border-bottom: 1px solid #f0f2f5;
}

.main-panel .admin-dt-bottom {
  border-top: 1px solid #f0f2f5;
}

.main-panel .admin-dt-length label,
.main-panel .admin-dt-filter label,
.main-panel .dataTables_wrapper .dataTables_length label,
.main-panel .dataTables_wrapper .dataTables_filter label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  color: #6b7280;
}

.main-panel .dataTables_wrapper .dataTables_filter {
  text-align: right;
}

.main-panel .admin-dt-search-group,
.main-panel .shops-search-wrap .input-group {
  width: min(100%, 16rem);
  min-width: 12rem;
}

.main-panel .admin-dt-search-group .input-group-text,
.main-panel .shops-search-wrap .input-group-text {
  background: #fff;
  border-color: #e5e7eb;
  color: #9ca3af;
  padding-left: 0.75rem;
  padding-right: 0.5rem;
}

.main-panel .admin-dt-search-group .form-control,
.main-panel .shops-search-wrap .form-control {
  border-color: #e5e7eb;
  box-shadow: none;
}

.main-panel .admin-dt-search-group .form-control:focus,
.main-panel .shops-search-wrap .form-control:focus {
  border-color: #1db770;
  box-shadow: 0 0 0 3px rgba(29, 183, 112, 0.14);
}

.main-panel .admin-dt-search-group .form-control:focus,
.main-panel .shops-search-wrap .form-control:focus {
  z-index: 3;
}

.main-panel .dataTables_wrapper .dataTables_filter input,
.main-panel .dataTables_wrapper .dataTables_length select,
.main-panel .admin-dt-filter input,
.main-panel .admin-dt-length select {
  height: 36px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  padding: 0.25rem 0.65rem;
  margin: 0;
  background: #fff;
  color: #1f2a37;
  box-shadow: none;
}

.main-panel .dataTables_wrapper .dataTables_filter .admin-dt-search-group input,
.main-panel .admin-dt-filter .admin-dt-search-group input {
  width: 100%;
  min-width: 0;
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
  margin-left: 0 !important;
}

.main-panel .dataTables_wrapper .dataTables_filter input:not(.form-control),
.main-panel .admin-dt-filter input:not(.form-control) {
  width: min(100%, 14rem);
  min-width: 10rem;
}

.main-panel .dataTables_wrapper .dataTables_filter input:focus,
.main-panel .dataTables_wrapper .dataTables_length select:focus {
  border-color: #1db770;
  outline: 0;
  box-shadow: 0 0 0 3px rgba(29, 183, 112, 0.14);
}

.main-panel .dataTables_wrapper .dataTables_info,
.main-panel .admin-dt-info {
  color: #9ca3af;
  font-size: 0.8125rem;
  padding: 0;
}

.main-panel .dataTables_wrapper .dataTables_paginate {
  float: none !important;
  padding: 0;
}

.main-panel .dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: 8px !important;
  border: 1px solid transparent !important;
  padding: 0.35rem 0.7rem !important;
  margin: 0 0.1rem !important;
  background: transparent !important;
  color: #4b5563 !important;
  box-shadow: none !important;
}

.main-panel .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: #f3f4f6 !important;
  color: #111827 !important;
}

.main-panel .dataTables_wrapper .dataTables_paginate .paginate_button.current,
.main-panel .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: #1db770 !important;
  border-color: #1db770 !important;
  color: #fff !important;
}

.main-panel .dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.main-panel .dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
  opacity: 0.35;
  background: transparent !important;
  color: #9ca3af !important;
}

/* Responsive child rows (mobile) */
.main-panel table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before,
.main-panel table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:before {
  background: #1db770 !important;
  border: 0 !important;
  box-shadow: none !important;
  top: 50% !important;
  transform: translateY(-50%);
}

.main-panel table.dataTable > tbody > tr.child td {
  background: #fafbfc !important;
  padding: 0.75rem 1rem !important;
}

.main-panel table.dataTable > tbody > tr.child ul.dtr-details {
  width: 100%;
  display: grid;
  gap: 0.5rem;
}

.main-panel table.dataTable > tbody > tr.child ul.dtr-details > li {
  border: 0;
  padding: 0.35rem 0;
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 0.75rem;
  align-items: start;
}

.main-panel table.dataTable > tbody > tr.child span.dtr-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: #9ca3af;
  text-transform: none;
  letter-spacing: 0;
}

.main-panel table.dataTable > tbody > tr.child span.dtr-data {
  color: #374151;
  word-break: break-word;
}

/* Breakpoints */
@media (max-width: 991.98px) {
  .main-panel .table,
  .main-panel .admin-table,
  .main-panel table.dataTable {
    min-width: 0;
  }

  .main-panel .admin-dt-top,
  .main-panel .admin-dt-bottom {
    padding: 0.75rem 1rem;
  }

  .main-panel .admin-dt-filter,
  .main-panel .admin-dt-length,
  .main-panel .admin-dt-filter label,
  .main-panel .admin-dt-length label {
    width: 100%;
  }

  .main-panel .dataTables_wrapper .dataTables_filter input,
  .main-panel .admin-dt-filter input,
  .main-panel .admin-dt-search-group,
  .main-panel .shops-search-wrap .input-group {
    width: 100%;
    min-width: 0;
  }

  .main-panel .table thead th,
  .main-panel .table td,
  .main-panel .admin-table thead th,
  .main-panel .admin-table td {
    padding: 0.75rem 0.85rem !important;
  }

  .main-panel .admin-table .td-actions .btn,
  .main-panel .table .td-actions .btn {
    width: 40px;
    min-width: 40px;
    height: 40px;
  }
}

@media (max-width: 575.98px) {
  .main-panel .admin-dt-bottom {
    flex-direction: column;
    align-items: stretch;
  }

  .main-panel .dataTables_wrapper .dataTables_paginate {
    text-align: center;
  }
}
