/* "Client tab access" (ATLAS-3503): the agency Owner's switch per business and Ask David tab. */

/* The screen brings its own navy surfaces, so it reads the same in the console and in the frame. */
.dta {
  /* The business column's width. The sticky column and the scroll padding both follow it. */
  --dta-name: 128px;
  display: grid;
  /* One track that may shrink to nothing: the table scrolls in its own box, never the page. */
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  padding: 12px;
  border-radius: 14px;
  background: #0b111c;
  color: #e6ecf5;
  font-size: 14px;
  line-height: 1.5;
}
.dta :focus-visible {
  outline: 2px solid var(--dw-cyan);
  outline-offset: 2px;
}
.dta .dta-lead,
.dta .dta-note,
.dta .dta-legend,
.dta .dta-empty,
.dta .dta-error-text {
  margin: 0;
}
.dta .dta-lead,
.dta .dta-note {
  max-width: 76ch;
}
.dta .dta-lead {
  color: #e6ecf5;
}
.dta .dta-note,
.dta .dta-legend,
.dta .dta-empty {
  color: #93a1b5;
  font-size: 13px;
}
.dta .dta-empty:empty {
  display: none;
}
.dta-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
}

/* --- Find a business ------------------------------------------------------------------------ */
.dta-search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
}
.dta-search[hidden] {
  display: none;
}
.dta-search-label {
  color: #93a1b5;
  font-size: 13px;
  font-weight: 600;
}
/* As specific as the frame's own rule for a field in a room, and later, so this one is kept. */
.dta .dta-search input.dta-search-input {
  flex: 1 1 200px;
  min-width: 0;
  max-width: 360px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #60728c;
  border-radius: 10px;
  background: #121a28;
  color: #e6ecf5;
  font: inherit;
  /* A phone zooms into a field whose text is smaller than this. */
  font-size: 16px;
}

/* --- Which is which ------------------------------------------------------------------------- */
.dta .dta-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}
.dta-mark {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid var(--dw-gold);
  border-radius: 999px;
  color: var(--dw-gold);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.dta-mark-none {
  border-color: #60728c;
  color: #93a1b5;
}

/* --- The table: scrolls in its own box, with the tabs and the business names kept in view ---- */
.dta-scroll {
  max-width: 100%;
  max-height: max(320px, 72vh);
  overflow: auto;
  /* A sideways swipe at the end of the table stays in the table: it is not "back". */
  overscroll-behavior-x: contain;
  /* A switch the keyboard brings into view stops clear of the sticky header and column. */
  scroll-padding: 48px 0 0 var(--dta-name);
  border: 1px solid #1f2a3d;
  border-radius: 12px;
  background: #121a28;
}
.dta-table {
  min-width: 100%;
  /* Separate borders: a collapsed one does not travel with a sticky cell. */
  border-collapse: separate;
  border-spacing: 0;
}
.dta-table th,
.dta-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #1f2a3d;
  background: #121a28;
  color: #e6ecf5;
  font-weight: 400;
  text-align: center;
  vertical-align: top;
}
.dta-table tbody tr:last-child > * {
  border-bottom: 0;
}
.dta-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px 6px;
  background: #0b111c;
  color: #93a1b5;
  font-size: 12px;
  font-weight: 600;
  vertical-align: middle;
  white-space: nowrap;
}
.dta-table .dta-corner,
.dta-table .dta-name {
  position: sticky;
  left: 0;
  z-index: 1;
  width: var(--dta-name);
  min-width: var(--dta-name);
  max-width: var(--dta-name);
  border-right: 1px solid #1f2a3d;
  text-align: left;
}
.dta-table thead .dta-corner {
  z-index: 3;
  padding-left: 10px;
}
.dta-table .dta-name {
  padding: 10px 8px 6px 10px;
}
.dta-row[hidden] {
  display: none;
}
/* The default sits with the header, apart from the clients that follow it. */
.dta-row-default > th,
.dta-row-default > td {
  border-bottom-width: 2px;
  background: #0b111c;
}
.dta-table .dta-row-default > .dta-name {
  box-shadow: inset 3px 0 0 var(--dw-gold);
}
.dta-name-text {
  display: block;
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.dta-name-detail {
  display: block;
  color: #93a1b5;
  font-size: 12px;
}
.dta .dta-reset {
  display: inline-flex;
  align-items: center;
  /* A pointer needs less room than a finger: the 44 px floor is set for touch at the end. */
  min-height: 28px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--dw-cyan);
  font: inherit;
  font-size: 13px;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.dta .dta-reset:disabled {
  color: #93a1b5;
  text-decoration: none;
  opacity: 0.7;
  cursor: default;
}
/* What was just done to a row is said beside its button, or under it when there is no room. */
.dta-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 10px;
  /* The default row has no button: room for one line is kept, so it does not jump at "Saved". */
  min-height: 18px;
}
.dta-status {
  flex: 0 1 auto;
  min-width: 0;
  color: #93a1b5;
  font-size: 12px;
  line-height: 18px;
  overflow-wrap: anywhere;
}
.dta-status[data-tone='ok'] {
  color: var(--dw-ok, #4fe0a6);
}
.dta-status[data-tone='error'] {
  color: var(--dw-red, #ff7b92);
}

/* --- A Default change asks first ------------------------------------------------------------ */
/* It changes every client that follows the default, so the Default row says what it will do and
 * waits for "Change it". The line sits under the row's name, in the column that stays in view. */
.dta-confirm {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--dw-gold);
  border-radius: 10px;
  background: #121a28;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
}
.dta-confirm[hidden] {
  display: none;
}
.dta-confirm-text {
  overflow-wrap: anywhere;
}
.dta-confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.dta .dta-confirm-yes,
.dta .dta-confirm-no {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.dta .dta-confirm-yes {
  border: 1px solid var(--dw-gold);
  background: var(--dw-gold);
  color: #1a1406;
}
.dta .dta-confirm-no {
  border: 1px solid #60728c;
  background: #121a28;
  color: #e6ecf5;
}
/* The switch being asked about. */
.dta-cell[data-asking='true'] .dw-switch::before {
  box-shadow:
    0 0 0 2px #0b111c,
    0 0 0 4px var(--dw-cyan);
}

/* --- One switch ----------------------------------------------------------------------------- */
.dta-cell {
  min-width: 60px;
}
.dta-cell .dw-switch {
  display: block;
  margin: 0 auto;
}
.dta .dw-switch:disabled {
  opacity: 0.6;
  cursor: progress;
}
/* Under the switch: "Set" for a client's own switch, or what an automatic default follows. */
.dta-caption {
  display: block;
  min-height: 14px;
  /* The 44 px target leaves 9 px of air under the track. */
  margin-top: -5px;
  color: #93a1b5;
  font-size: 11px;
  line-height: 14px;
}
.dta-cell[data-own='true'] .dta-caption {
  color: var(--dw-gold);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
/* A client's own switch also wears a ring, so it is told apart at a glance. */
.dta-cell[data-own='true'] .dw-switch::before {
  box-shadow:
    0 0 0 2px #121a28,
    0 0 0 4px var(--dw-gold);
}
/* The default's third state: automatic, by a fact about each business. That one control is a
   checkbox, the role "mixed" is valid on, drawn as a switch: matched by class, never by role. */
.dta .dw-switch[aria-checked='mixed']::before {
  border-color: var(--dw-gold);
  background: color-mix(in srgb, var(--dw-gold) 24%, transparent);
}
.dta .dw-switch[aria-checked='mixed'] .dw-switch-knob {
  left: 13px;
  background: var(--dw-gold);
}

/* --- Loading failed ------------------------------------------------------------------------- */
.dta-error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--dw-red, #ff7b92);
  border-radius: 12px;
  background: #121a28;
}
.dta .dta-error-text {
  flex: 1 1 220px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.dta .dta-button {
  min-width: 88px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid #60728c;
  border-radius: 10px;
  background: #121a28;
  color: #e6ecf5;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* --- Recent changes ------------------------------------------------------------------------- */
.dta-changes {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  margin-top: 4px;
}
.dta .dta-changes-title {
  margin: 0;
  color: #e6ecf5;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
}
.dta .dta-changes-list {
  margin: 0;
  padding: 0;
  border: 1px solid #1f2a3d;
  border-radius: 12px;
  background: #121a28;
  list-style: none;
}
.dta-change {
  padding: 8px 12px;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.dta-change + .dta-change {
  border-top: 1px solid #1f2a3d;
}
.dta-change time {
  color: #93a1b5;
}

/* --- Agency only: the tabs with no column in the table, and why ----------------------------- */
.dta-agency {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  max-width: 76ch;
}
.dta-agency[hidden] {
  display: none;
}
.dta .dta-agency-title {
  margin: 0;
  color: #e6ecf5;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
}
.dta .dta-agency-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  color: #93a1b5;
  font-size: 13px;
  list-style: none;
}
.dta-agency-item {
  overflow-wrap: anywhere;
}
.dta-agency-name {
  color: #e6ecf5;
  font-weight: 600;
}

/* A narrow screen, or any screen worked with a finger: the same test the shell uses. */
@media (max-width: 767px), (pointer: coarse) {
  .dta .dta-reset,
  .dta .dta-confirm-yes,
  .dta .dta-confirm-no {
    min-height: 44px;
  }
}
@media (min-width: 720px) {
  .dta {
    --dta-name: 220px;
    padding: 20px;
  }
  .dta-table th,
  .dta-table td {
    padding: 8px 10px;
  }
}
