/* Staff screens in the app style (D-098 A3): overview, content, leads and review as cards on
   phones and tablets. Builds on member-app.css (.m-*); the desktop keeps its tables. */

/* One markup, two layouts: .s-app shows below 1024px, .s-desk from 1024px up. */
@media (min-width: 1024px) {
  .s-app {
    display: none !important;
  }
}
@media (max-width: 1023px) {
  .s-desk {
    display: none !important;
  }
}

.m-avatar.s-ic {
  border-radius: 12px;
}
.s-wrap {
  white-space: normal;
}

/* Shortcut tiles */
.s-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.s-tile {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  min-height: 84px;
  padding: 10px 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.84rem;
  text-align: center;
  text-decoration: none;
}
.s-tile:hover {
  border-color: var(--green);
}
.s-tile:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.s-tile-ic {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--soft);
  color: var(--green);
}
.s-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
a.m-stat {
  display: block;
  text-decoration: none;
}
a.m-stat:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.s-activity {
  min-height: 56px;
}
.s-activity .m-title {
  font-weight: 400;
  font-size: 0.88rem;
}

/* Content type switch made of links */
.m-segment a {
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 8px 4px;
  border-radius: 10px;
  color: var(--ink);
  font-size: 0.9rem;
  text-decoration: none;
}
.m-segment a[aria-current="page"] {
  background: var(--paper);
  font-weight: 600;
  box-shadow: 0 1px 3px rgb(16 42 67 / 0.15);
}
.m-segment a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

/* A lead row is a button that opens the detail sheet */
.s-rowbtn {
  width: 100%;
  border-width: 0 0 1px;
  border-style: solid;
  border-color: var(--line);
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

/* Review cards keep their buttons under the title */
.s-card {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.s-card:last-child {
  border-bottom: 0;
}
.s-card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.s-card-actions {
  justify-content: flex-start;
  margin: 10px 0 0 54px;
}
.s-card .caution {
  color: var(--danger);
  white-space: normal;
}
.s-call {
  margin-bottom: 4px;
}

@media (max-width: 1023px) {
  /* The cards replace the table, so the panel loses its frame and the bulk tools step aside
     (rows on a phone have their own buttons). */
  .s-panel {
    border: 0;
    background: none;
  }
  /* Status filters as chips. The tab bar's `.tab` rule (app-shell.css) also matches these
     buttons, so this undoes its column layout first. */
  .s-panel .tabs {
    display: flex;
    gap: 8px;
    padding: 0 0 10px;
    border: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .s-panel .tabs .tab {
    flex: none;
    flex-direction: row;
    gap: 6px;
    min-height: 40px;
    padding: 7px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--paper);
    color: var(--ink);
    font-size: 0.88rem;
  }
  .s-panel .tabs .tab[aria-pressed="true"],
  .s-panel .tabs .tab.active {
    border-color: #102a43;
    background: #102a43;
    color: #fff;
  }
  html[data-theme="dark"] .s-panel .tabs .tab[aria-pressed="true"],
  html[data-theme="dark"] .s-panel .tabs .tab.active {
    border-color: var(--green);
    background: var(--green);
    color: #0d1823;
  }
  .s-panel .tabs .tab .count {
    padding: 0;
    background: none;
    color: inherit;
  }
  .s-panel .tabs .tab:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
  }
  /* Search first, as in the prototype; the other filters follow. */
  .s-panel .filters,
  .s-panel .bulkbar {
    padding: 0 0 10px;
  }
  .s-panel .filters .filter-search,
  .s-panel .filters .field:has(input[type="search"]) {
    order: -1;
  }
  #content-list .bulkbar > #bulk-action,
  #content-list .bulkbar > #bulk-apply,
  #content-list .bulkbar > #bulk-count,
  #review-list .bulkbar > #bulk-action,
  #review-list .bulkbar > #bulk-apply,
  #review-list .bulkbar > #bulk-count {
    display: none;
  }
}
@media (max-width: 380px) {
  .s-card-actions {
    margin-left: 0;
  }
}

/* ---- A4: members, media, proposals and the writing screen (D-098) ---- */

/* Action-sheet rows that are buttons look like the link rows in app-shell.css. */
button.sheet-row {
  width: 100%;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.sheet-row.danger .sheet-title,
.sheet-row.danger .sheet-ic {
  color: var(--danger);
}
.s-thumb {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg);
}

@media (max-width: 1023px) {
  /* Media: two thumbnails per row instead of one picture filling the phone. */
  .s-panel .media-dense {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 0;
  }
  .s-panel .panel-head {
    padding: 0 0 10px;
    border: 0;
  }

  /* Proposals: each change reads top to bottom (part, now, proposed). */
  .pr-table thead {
    display: none;
  }
  .pr-table,
  .pr-table tbody,
  .pr-table tr,
  .pr-table th,
  .pr-table td {
    display: block;
    width: auto;
  }
  .pr-table tr {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
  }
  .pr-table th[scope="row"] {
    padding: 0 0 6px;
    border: 0;
    background: none;
    color: var(--ink);
    font-weight: 600;
  }
  .pr-table td {
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
  }
  .pr-table td::before {
    display: block;
    color: var(--muted);
    font-size: 0.75rem;
    content: "ตอนนี้";
  }
  .pr-table td.pr-after::before {
    content: "ร่างใหม่";
  }
  .tablewrap:has(.pr-table) {
    overflow: visible;
  }
  /* The general `.tablewrap table { min-width: 600px }` would keep it wider than the phone. */
  .tablewrap .pr-table {
    min-width: 0;
  }
  .pr-table td {
    overflow-wrap: anywhere;
  }

  /* Writing screen: the top bar carries the title and back button, so the page head steps
     aside; the formatting bar sticks under the top bar on one scrollable row. */
  .app.task .pagehead:has(+ form .editor-layout) {
    display: none;
  }
  .app.task .rich-toolbar {
    position: sticky;
    top: 56px;
    z-index: 6;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    background: var(--paper);
  }
  .app.task .rich-toolbar > * {
    flex: none;
  }
}
