/* Ads tab (admin) */

#adsPanel {
  margin-top: 10px;
  min-width: 0;
  overflow: hidden;
}

.ads-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  margin-bottom: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.ads-tabs-left {
  display: flex;
  gap: 6px;
}

.ads-tabs-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.ads-tab {
  border: 1px solid transparent;
  background: transparent;
  padding: 10px 12px;
  border-radius: var(--r);
  font-weight: 750;
  color: var(--admin-muted);
  cursor: pointer;
  white-space: nowrap;
}

.ads-tab:hover {
  background: rgba(17, 18, 20, 0.04);
  color: var(--admin-text);
}

.ads-tab.is-active {
  background: var(--admin-orange-weak);
  color: var(--admin-text);
  border-color: rgba(255, 138, 0, 0.25);
  box-shadow: none;
}

.ads-table {
  overflow: hidden;
  background: transparent;
  border: none;
  border-radius: 0;
  max-height: none;
}

.ads-table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 56px - 18px - 28px - 14px - 52px - 12px - 44px - 38px);
}

.ads-table-inner {
  display: grid;
  gap: 6px;
  min-width: max-content;
  padding: 10px 0 10px 0;
}

.ads-table-total-host {
  position: sticky;
  z-index: 49;
}

.ads-table-head > .ads-col-name,
.ads-table-row > .ads-col-name {
  justify-content: flex-start;
}

.ads-table-head-bg + .ads-table-head {
  display: none;
}

.ads-table-head-bg {
  display: none;
}

.ads-table-head,
.ads-table-row {
  display: grid;
  gap: 0;
  /* Important: keep grid items stretched so sticky/frozen cells cover full row height. */
  align-items: stretch;
  padding: 0;
}

.ads-table-head > div,
.ads-table-row > div {
  display: flex;
  align-items: center;
  min-height: 100%;
  padding: 10px 12px;
  justify-content: flex-start;
  text-align: left;
  justify-self: stretch;
  border-right: 1px solid var(--admin-border);
}

.ads-table-head [data-sort-key] {
  cursor: pointer;
  user-select: none;
}

.ads-table-head [data-sort-key][data-sort-state="asc"]::after {
  content: " ↑";
  color: var(--admin-muted);
  font-weight: 900;
  display: inline-block;
  margin-left: 4px;
}

.ads-table-head [data-sort-key][data-sort-state="desc"]::after {
  content: " ↓";
  color: var(--admin-muted);
  font-weight: 900;
  display: inline-block;
  margin-left: 4px;
}

.ads-table-head > .ads-col-check,
.ads-table-row > .ads-col-check,
.ads-table-head > .ads-col-status,
.ads-table-row > .ads-col-status,
.ads-table-head > .ads-col-name,
.ads-table-row > .ads-col-name {
  border-right: none;
}

.ads-table-head > div:last-child,
.ads-table-row > div:last-child {
  border-right: none;
}

.ads-table-head > .t-right,
.ads-table-row > .t-right {
  justify-content: flex-start;
  text-align: left;
  justify-self: stretch;
}

.ads-table-head > .t-center,
.ads-table-row > .t-center {
  justify-content: flex-start;
  text-align: left;
  justify-self: stretch;
}

.ads-table-row > .ads-col-check,
.ads-table-head > .ads-col-check {
  justify-content: center;
}

.ads-table-head {
  background: #f5f5f7;
  border: 1px solid var(--admin-border);
  border-radius: var(--r);
  color: var(--admin-muted);
  font-weight: 800;
  font-size: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
  overflow: visible;
}

.ads-table-head > div,
.ads-table-row > div {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ads-table-head > .ads-col-status,
.ads-table-row > .ads-col-status {
  /* Must match the grid track width to avoid overlapping sticky columns. */
  min-width: 90px;
}

.ads-table-head > .ads-col-first-metric,
.ads-table-row > .ads-col-first-metric {
  padding-left: 12px;
}

.ads-table-head > .ads-col-metric,
.ads-table-row > .ads-col-metric {
  min-width: 100px;
}

.ads-table-head > .ads-col-name,
.ads-table-row > .ads-col-name {
  /* Allow the resizable "Nome" column to shrink; JS clamps the px width. */
  min-width: 0;
}

.ads-table-head > .ads-col-check,
.ads-table-row > .ads-col-check {
  /* Must match the grid track width (44px) to avoid overlaps. */
  min-width: 44px;
}

.ads-check {
  width: 16px;
  height: 16px;
  accent-color: #1a73e8;
  cursor: pointer;
}

.ads-table-row.is-selected {
  /* Use an opaque bg so frozen sticky cells don't "see through" to scrolled content. */
  background: #eef5ff !important;
  border-color: rgba(26, 115, 232, 0.38);
}

/* Keep sticky cells visually solid (no bleed-through while scrolling). */
.ads-table-row > .ads-col-check,
.ads-table-row > .ads-col-status,
.ads-table-row > .ads-col-name {
  background: inherit;
}

/* Sticky/frozen first column ("Nome") + checkbox, like Meta Ads. */
.ads-table-head > .ads-col-check,
.ads-table-row > .ads-col-check {
  position: sticky;
  left: var(--ads-sticky-left-start, 10px);
  z-index: 20;
  background: inherit;
}

.ads-table-head > .ads-col-status,
.ads-table-row > .ads-col-status {
  position: sticky;
  left: var(--ads-sticky-left-status, 44px);
  z-index: 19;
  background: inherit;
}

.ads-table-head > .ads-col-name,
.ads-table-row > .ads-col-name {
  position: sticky;
  left: var(--ads-sticky-left-name, 134px);
  z-index: 19;
  background: inherit;
}

/* Make the frozen block feel like one continuous left panel */
.ads-table-row > .ads-col-check {
  border-top-left-radius: var(--r);
  border-bottom-left-radius: var(--r);
}

.ads-table-head > .ads-col-check {
  border-top-left-radius: var(--r);
  border-bottom-left-radius: var(--r);
}

.ads-table-head > .ads-col-check,
.ads-table-head > .ads-col-name {
  z-index: 60;
}

.ads-table-head > .ads-col-status {
  z-index: 60;
}

.ads-table-row > .ads-col-name {
  box-shadow: none;
}

.ads-table-head > .ads-col-name,
.ads-table-row > .ads-col-name {
  position: sticky;
  /* keep sticky offsets from earlier rule */
  box-shadow: none;
  overflow: visible;
}

/* Shadow only at the right edge of the frozen "Nome" column. */
.ads-table-head > .ads-col-name::after,
.ads-table-row > .ads-col-name::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: -12px;
  width: 1px;
  pointer-events: none;
  background: var(--admin-border);
}

/* Create breathing room for the first metric after the frozen block. */
.ads-table-head > .ads-col-first-metric,
.ads-table-row > .ads-col-first-metric {
  margin-left: 14px;
}

.ads-table-row > .ads-col-name > .ads-cell-main {
  min-width: 0;
  overflow: visible;
}

.ads-table-head > .ads-col-name,
.ads-table-row > .ads-col-name {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.ads-table-head > .ads-col-name,
.ads-table-row > .ads-col-name,
.ads-title,
.ads-sub {
  white-space: nowrap;
}

.ads-table-row > .ads-col-name,
.ads-table-head > .ads-col-name {
  min-width: 0;
}

/* Only show a soft right-edge shadow after the user scrolls horizontally. */
.ads-table.is-hscrolling .ads-table-head > .ads-col-name::after,
.ads-table.is-hscrolling .ads-table-row > .ads-col-name::after {
  right: -13px;
  width: 14px;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.09), rgba(0, 0, 0, 0));
}

/* (legacy) Date column removed */

.ads-table-rows {
  display: grid;
  gap: 6px;
  overflow: visible;
  max-height: none;
}

.ads-table-row {
  border: 1px solid var(--admin-border);
  border-radius: var(--r);
  background: #fff;
  overflow: visible;
}

.ads-table-row > .ads-cell-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 0;
  width: 100%;
  text-align: left;
}

.ads-table-head > .ads-col-name,
.ads-table-row > .ads-col-name {
  text-align: left;
}

.ads-title {
  font-weight: 700;
  font-size: 15px;
  text-align: left;
  white-space: nowrap;
}

.ads-sub {
  font-size: 12px;
  color: var(--admin-muted);
  font-weight: 650;
}

.ads-switch {
  width: 44px;
  height: 24px;
}

.ads-table-empty,
.ads-table-loading {
  padding: 12px;
  font-weight: 650;
  color: var(--admin-muted);
}

.t-right {
  justify-self: end;
  text-align: right;
}

.t-center {
  justify-self: center;
  text-align: center;
}

/* (Nome) column is not resizable. */

@media (max-width: 980px) {
  .ads-date {
    min-width: 0;
  }
}

@media (max-width: 820px) {
  .ads-tabs {
    margin-bottom: 10px;
  }

  .ads-table {
    max-height: none;
  }
}
