@use '../variables' as v;
@use '../mixins' as m;

// ─────────────────────────────────────────────
// Lists page - Audience tab bar
// ─────────────────────────────────────────────
.aud-tabs {
  display: flex;
  gap: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: v.$radius-md;
  margin-bottom: 20px;
  overflow-x: auto;
  white-space: nowrap;
  @include m.scrollbar-thin;
}


.aud-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  font-size: v.$font-size-sm;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color v.$transition-base, border-color v.$transition-base, background v.$transition-base;
  white-space: nowrap;

  svg {
    width: 16px;
    height: 16px;
  }

  &:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
  }

  &.is-active {
    color: var(--info);
    border-bottom-color: var(--info);
    background: var(--bg-surface);
    font-weight: 600;
  }
}

@media (max-width: 640px) {
  .aud-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow-x: visible;
    white-space: normal;
  }

  .aud-tab {
    justify-content: center;
    padding: 12px 10px;
    font-size: 13px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);

    &:nth-child(2n) {
      border-right: none;
    }

    &:nth-last-child(-n+2) {
      border-bottom: none;
    }

    &.is-active {
      color: var(--info);
      background: var(--active-bg);
      border-bottom: 2px solid var(--info);
      font-weight: 600;
    }
  }
}

// ─────────────────────────────────────────────
// Section header row
// ─────────────────────────────────────────────
.section-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;

  @media (max-width: 640px) {
    flex-direction: column;
    align-items: stretch;
  }
}

.section-hdr-left {
  h2 {
    font-size: v.$font-size-xl;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
  }

  p {
    font-size: v.$font-size-xs;
    color: var(--text-secondary);
    margin-top: 3px;
  }
}

.section-hdr-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;

  @media (max-width: 640px) {
    width: 100%;
    justify-content: flex-start;

    .tbl-search {
      flex: 1;
      width: 100%;

      input {
        width: 100%;
      }
    }
  }
}

// ─────────────────────────────────────────────
// Search input
// ─────────────────────────────────────────────
.tbl-search {
  position: relative;

  input {
    padding: 7px 12px 7px 34px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: v.$font-size-sm;
    color: var(--text-primary);
    background: var(--bg-surface);
    width: 200px;
    outline: none;
    font-family: inherit;

    &:focus {
      border-color: var(--info-border);
    }
  }

  svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: var(--text-muted);
  }
}

// ─────────────────────────────────────────────
// Colored icon action buttons
// ─────────────────────────────────────────────
.act-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: opacity v.$transition-base;

  &:hover {
    opacity: .85;
  }

  svg {
    width: 14px;
    height: 14px;
    color: #fff;
    stroke: currentColor;
  }
}

.act-btn--edit {
  background: var(--info);
}

.act-btn--settings {
  background: var(--info);
}

.act-btn--delete {
  background: var(--danger);
}

// ─────────────────────────────────────────────
// Table title link
// ─────────────────────────────────────────────
.tbl-title-link {
  color: var(--info);
  text-decoration: none;
  font-weight: 500;
  font-size: v.$font-size-sm;

  &:hover {
    text-decoration: underline;
  }
}

// ─────────────────────────────────────────────
// Subscriber sub-line
// ─────────────────────────────────────────────
.sub-label {
  font-size: v.$font-size-2xs;
  color: var(--text-secondary);
  display: block;
}

// ─────────────────────────────────────────────
// Modal overrides
// ─────────────────────────────────────────────
.modal-body-gray {
  background: var(--bg-hover);
  padding: 24px;
}

.modal-field-grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

// ─────────────────────────────────────────────
// Responsive Table Cards
// ─────────────────────────────────────────────
@media (max-width: 1024px) {
  .data-table thead {
    display: none;
  }
  .data-table tbody tr {
    display: block;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
    position: relative;
  }
  .data-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: none;
    padding: 8px 0;
    font-size: 13px;
    text-align: right;
  }
  .data-table tbody td.cell-checkbox {
    position: absolute;
    top: 16px;
    left: 16px;
    padding: 0;
    z-index: 2;
  }
  .data-table tbody td.cell-id {
    display: none !important;
  }
  .data-table tbody td.cell-title,
  .data-table tbody td.cell-name {
    display: block;
    text-align: left;
    padding-top: 5px;
    padding-left: 40px !important;
    padding-right: 0px;
    font-weight: 600;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    flex-direction: column;
    width: 100%;

    &[data-label]::before {
      display: none !important;
    }
  }
  .data-table tbody td.cell-actions {
    position: absolute;
    top: 10px;
    right: 12px;
    padding: 0;
    z-index: 2;

    &[data-label]::before {
      display: none !important;
    }
  }
  .data-table tbody td[data-label]::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.05em;
    margin-right: 8px;
  }
}
@media (max-width: 576px) {
  .modal-field-grid2 {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}