/*
 * The admin panel's stylesheet (sc-1053). Served at /admin/assets/admin.css and
 * added to every AdminJS page through `assets.styles` (see
 * src/admin/branding/admin-branding.ts).
 *
 * Theme tokens come first; a rule lands here only when no token reaches what
 * it changes. Every rule says what it targets, because the selectors are
 * AdminJS's own hooks (`adminjs_*` classes and `data-css` attributes) and an
 * AdminJS upgrade can rename them. Keep this file small; a rule nobody can
 * explain is a rule to delete.
 */

/* Every list table (`adminjs_Table`): the card around it draws the frame, so the
   table's own left/right borders go. */
.adminjs_Table {
  border-left: 0;
  border-right: 0;
}

/* Table headers (`adminjs_TableHead`): no header background, small muted
   labels instead of bold dark ones. */
.adminjs_TableHead {
  background: transparent;
}

/* The header cells and their sort links. */
.adminjs_TableHead td,
.adminjs_TableHead a {
  color: #6b7280;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* Header cells sit flush with the card: no top border, slimmer padding. */
.adminjs_TableHead td {
  border-top: 0;
  padding: 10px 12px;
}

/* Body cells (`adminjs_TableCell`): one thin divider below each row, roomier
   padding, and no zebra stripes (AdminJS has none; the hover below is the only
   row tint). */
.adminjs_TableCell {
  border-top: 0;
  border-bottom: 1px solid #e5e7eb;
  padding: 12px;
}

/* The last row's cells: the card's border closes the table, so no divider. */
.adminjs_TableBody .adminjs_TableRow:last-child .adminjs_TableCell {
  border-bottom: 0;
}

/* Property cells (`data-property-name`, i.e. not the checkbox or the actions
   cell): long values are cut with an ellipsis so each row stays one line. The
   value sits in a block (`<Resource>-list-<property>`) inside the cell, so the
   ellipsis goes on that block; the cell only caps the width. The actions cell
   is left alone because its dropdown must overflow. */
.adminjs_TableCell[data-property-name] {
  max-width: 200px;
  white-space: nowrap;
  word-break: normal;
}
.adminjs_TableCell[data-property-name] > .adminjs_Box {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Uuid cells (`data-property-name="uuid"`): narrower than other columns, so a
   list with a uuid, two people and a status still fits a laptop screen. The
   full id is on hover and is what a click copies (sc-1059). */
.adminjs_TableCell[data-property-name='uuid'] {
  max-width: 140px;
}

/* Row hover: a faint tint, replacing the design system's near-invisible one. */
.adminjs_TableRow:not(.selected):hover {
  background: #f8fafc;
}

/* The list page's table wrapper (`<Resource>-list-table-wrapper`): the table
   as a card, with a soft border and rounded corners instead of a bare white
   block, and no inner padding so the rows run edge to edge. The card grows
   with a table too wide for the page (one-line rows can be wider than it)
   rather than clipping it: the row-action dropdown is positioned inside the
   table, so any `overflow` here would cut it off; the content area scrolls
   sideways instead, as it does in stock AdminJS. The attribute is repeated to
   outrank the design system's own `min-width: 0`, which is injected later. */
[data-css$='-list-table-wrapper'][data-css] {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0 0 16px;
  width: max-content;
  min-width: 100%;
}

/* Pagination (`adminjs_PaginationLink` buttons inside their bordered wrapper):
   quieter, rounded, and no heavy dividers between the arrows and the pages. */
[data-css$='-list-table-wrapper'] .adminjs_Text > section {
  border-radius: 8px;
}
[data-css$='-list-table-wrapper'] .adminjs_Text > section > :first-child,
[data-css$='-list-table-wrapper'] .adminjs_Text > section > :last-child {
  border-left: 0;
  border-right: 0;
}

/* The sidebar's logo link (`data-css="sidebar-logo"`): our logo at a sensible
   size, with the padding the default wordmark no longer needs. */
[data-css='sidebar-logo'] {
  padding: 20px 24px 16px;
}
[data-css='sidebar-logo'] > img {
  max-width: 128px;
  display: block;
}

/* Sidebar section labels ("Navigation", "Pages"): small and muted. */
[data-css='sidebar'] .adminjs_Label {
  color: #9ca3af;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

/* Sidebar items (every navigation link): compact rows with rounded corners and
   a soft teal hover. The selected item's tint comes from the theme's primary
   colour; the design system exposes no hook for it. */
[data-css='sidebar'] li > a {
  border-radius: 6px;
  padding: 7px 10px;
  margin: 1px 0;
  font-size: 14px;
}
[data-css='sidebar'] li > a:hover {
  background-color: rgba(13, 148, 136, 0.12);
}

/* The icon in each sidebar item: a little closer to its label. */
[data-css='sidebar'] li > a > .icon-box {
  padding-right: 10px;
}

/* Thin separators between sidebar groups (a group is a top-level item with its
   own nested list, e.g. Payments). */
[data-css='sidebar-resources'] > section > ul > li:has(> ul) + li,
[data-css='sidebar-resources'] > section > ul > li + li:has(> ul) {
  border-top: 1px solid #f1f5f9;
  margin-top: 6px;
  padding-top: 6px;
}

/* Resources inside a group: indented under their group heading. */
[data-css='sidebar'] ul ul > li > a {
  padding-left: 36px;
}

/* Page titles (the H2 of every action header): a touch heavier and tighter
   than the design system's light display face. */
[data-css='app-content'] h2 {
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Buttons (`adminjs_Button`), inputs (`adminjs_Input`) and selects (the
   react-select control inside `adminjs_Select`): the same corner radius
   everywhere, in place of the design system's 4px/2px pair. This squares the
   design system's pill buttons too (the list header's "Create new" and
   "Filter" come from a `rounded` ButtonGroup), on purpose: one radius. */
.adminjs_Button {
  border-radius: 8px;
}
.adminjs_Input {
  border-radius: 8px;
}
.adminjs_Select [class$='-control'] {
  border-radius: 8px;
}

/* Cards (`adminjs_Box_Card`, `adminjs_Box_White`): rounded, with a hairline
   border so they read as cards on the light page background without a heavy
   shadow. */
.adminjs_Box_Card,
.adminjs_Box_White {
  border-radius: 10px;
  border: 1px solid #e5e7eb;
}

/* Record pages (`<Resource>-show-drawer-content`, `-edit-` and `-new-`): the
   record sits in a card like the lists do, and its fields flow in two
   columns. The selector goes through the route wrapper
   (`<Resource>-record-show-route-wrapper` and kin; a form sits between them
   on edit and new pages) and repeats the attribute, because AdminJS styles
   this container from a nested rule on that wrapper, injected after this
   sheet. */
[data-css$='-route-wrapper'] [data-css$='-show-drawer-content'][data-css],
[data-css$='-route-wrapper'] [data-css$='-edit-drawer-content'][data-css],
[data-css$='-route-wrapper'] [data-css$='-new-drawer-content'][data-css] {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 24px 24px 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 32px;
}

/* Long fields on those pages, by name: the only hook a default field has is
   `<Resource>-<action>-<property>`, so the free-text and JSON columns the
   panel shows or edits outside a sectioned layout are listed here. A
   sectioned layout marks its own (`record-field-wide`, below). */
[data-css$='-drawer-content'] > [data-css$='-bio'],
[data-css$='-drawer-content'] > [data-css$='-details'],
[data-css$='-drawer-content'] > [data-css$='-message'],
[data-css$='-drawer-content'] > [data-css$='-payload'],
[data-css$='-drawer-content'] > [data-css$='-lastError'],
[data-css$='-drawer-content'] > [data-css$='-metadata'],
[data-css$='-drawer-content'] > [data-css$='-oldValue'],
[data-css$='-drawer-content'] > [data-css$='-newValue'],
[data-css$='-drawer-content'] > [data-css$='-consentText'],
[data-css$='-drawer-content'] > [data-css$='-moderationReason'],
[data-css$='-drawer-content'] > [data-css$='-adminNotes'] {
  grid-column: 1 / -1;
}

/* Record pages built from sections (`record-section`, emitted by
   recordLayout() in src/admin/resources/record-layout.ts): the page's own
   container stops being a card, because each section is one. Same
   specificity as the rule above, and later, so it wins. */
[data-css$='-route-wrapper']
  [data-css$='-drawer-content']:has(> [data-css='record-section']) {
  display: block;
  background: transparent;
  border: 0;
  padding: 0;
}

/* A section: a card, with a gap before the next one. */
[data-css='record-section'] {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 20px 24px 4px;
}
[data-css='record-section'] + [data-css='record-section'] {
  margin-top: 16px;
}

/* A section's heading (the `adminjs_Header` recordLayout() puts first in it):
   a small bold title in place of the design system's display size and
   margins. The attribute is repeated to outrank the heading's own first-child
   margin rule. */
[data-css='record-section'][data-css] > .adminjs_Header {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 600;
  line-height: 24px;
  color: #1f2933;
}

/* A section's fields (`record-fields`): two columns, with `record-field-wide`
   fields (free text, lists, panels) spanning both. */
[data-css='record-fields'] {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 32px;
}
[data-css='record-field-wide'] {
  grid-column: 1 / -1;
}

/* Narrow windows: one column on every record page (the first three selectors
   match the card rule above, so they outrank it). */
@media (max-width: 900px) {
  [data-css$='-route-wrapper'] [data-css$='-show-drawer-content'][data-css],
  [data-css$='-route-wrapper'] [data-css$='-edit-drawer-content'][data-css],
  [data-css$='-route-wrapper'] [data-css$='-new-drawer-content'][data-css],
  [data-css='record-fields'] {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Field labels on show pages (`adminjs_Label` in a value group): muted, like
   the table headers. */
[data-css='app-content'] .adminjs_Label {
  color: #6b7280;
}

/* The login page (`login__Wrapper`): a rounded card, and without AdminJS's
   astronaut illustrations. They sit in the card's first child, the teal
   panel; the form's own icons (the failed-login message) keep theirs. */
.login__Wrapper > section {
  border-radius: 12px;
  overflow: hidden;
}
.login__Wrapper > section > section:first-child svg {
  display: none;
}
