/* =============================================================
   Styles for powerpages-transformations.js
   Covers: renderSubgridAsCards, renderSubgridAsLists,
           renderMirrorBlock
   Load this file on any page that uses the transformation
   functions (as a web file or via the custom CSS field).
   ============================================================= */

/* --------------------------------------------- */
/* Shared: section header used by all renderers  */
/* Scoped to transformation-generated headers    */
/* --------------------------------------------- */

.pp-transform-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pp-transform-section-head h2,
.pp-transform-section-head .section-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.pp-transform-section-head .section-sub {
  color: var(--muted, #5b5b62);
  margin: 8px 0 16px;
  font-size: 14px;
}

/* Empty-state message rendered when a subgrid has no rows */
.cards-empty.pp-transform-cards-empty {
  text-align: center;
  padding: 32px 12px;
  color: var(--muted, #5b5b62);
  font-size: 14px;
}

/* --------------------------------------------- */
/* renderSubgridAsCards                          */
/* Classes: .cards, .card.site-card, .card-head, */
/* .site-icon, .status, .site-edit, .card-body,  */
/* .kv, .site-callout, .site-cards-actions       */
/* --------------------------------------------- */

/* Card list wrapper (scoped to transformation-generated cards) */
.cards.pp-transform-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  border-radius: 16px;
  background: #DEF2F480;
}

/* Individual site card (scoped to transformation-generated cards) */
.card.site-card.pp-transform-site-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--card-ring, #DEF2F480);
  border-radius: 16px;
  box-shadow: var(--card-shadow, 0 8px 24px rgba(28, 31, 74, 0.08));
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 80% 20%;
  gap: 10px;
}

/* Card header row: icon + title + status + edit link */
.pp-transform-site-card .card-head {
  max-width: 100%;
  overflow: hidden;
}

.pp-transform-site-card .card-head-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.pp-transform-site-card .folder {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.pp-transform-site-card .card-title-section {
  min-width: 0;
  /* width: 0; */
  /* flex: 1 1 auto; */
  line-height: 1.3;
  max-width: 100%;
  overflow: hidden;
}

/* Create action button wrapper above the card list */
.pp-transform-cards .site-cards-actions {
  margin-bottom: 12px;
}

.pp-transform-cards .site-cards-actions .btn.btn-primary,
.pp-transform-cards .site-cards-actions .btn-primary {
  margin: 0;
}

/* Card title text */
.pp-transform-site-card .card-title {
  font-weight: 800;
  color: var(--text, #1a1a1a);
  font-size: 18px;
  margin-bottom: 2px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 1.3;
  max-width: 100%;
}

.pp-transform-site-card .card-subtitle {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted, #5b5b62);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 1.3;
  max-width: 100%;
}

/* Site icon: rendered as an image via background url */
.pp-transform-site-card .site-icon {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  display: block;
  background: url(/site-icon.png) no-repeat center / contain;
}

/* Completion status badge */
.pp-transform-site-card .status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-start;
  /* margin-left: auto; */
  padding: 4px 8px !important;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-weight: 700;
  font-size: 12px;
  background: var(--success-bg, #D9E6AE);
  color: var(--success-text, #0F0F0F);
  white-space: nowrap;
}

.pp-transform-site-card .status.incomplete {
  background: var(--border, #E0E0E0);
  color: var(--muted, #0F0F0F);
}

/* Card actions (edit/delete links) */
.pp-transform-site-card .card-actions {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: flex-end;
}

.pp-transform-site-card .card-actions .edit,
.pp-transform-site-card .card-actions .delete {
  align-items: center;
  font-weight: 600;
  color: var(--brand-600, #2a1f86);
  text-decoration: none;
  font-size: 14px;
  display: inline-flex !important;
  position: static !important;
  top: auto !important;
  margin-right: 10px;
}

.site-card .card-actions .edit:hover,
.site-card .card-actions .delete:hover {
  text-decoration: underline;
}

/* Legacy support for old .site-edit class (scoped) */
.pp-transform-site-card .site-edit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text, #1a1a1a);
  text-decoration: none;
  padding: 6px 8px;
  border-radius: 8px;
  margin-left: auto;
}

.pp-transform-site-card .site-edit:hover,
.pp-transform-site-card .site-edit:focus {
  text-decoration: underline;
}

.pp-transform-site-card .site-edit .fa {
  width: 16px;
  height: 16px;
  font-size: 16px;
  line-height: 1;
}

/* Card body: horizontal key/value field list */
.pp-transform-site-card .card-body {
  display: grid;
  grid-column: 1 / -1;
  margin-top: 12px;
  gap: 16px;
}

.pp-transform-site-card .kv {
  min-width: 0;
}

.pp-transform-site-card .kv .label {
  font-size: 12px;
  color: var(--muted, #5b5b62);
  margin-bottom: 4px;
  padding: 0;
  font-weight: 400;
  line-height: 1.3;
  text-align: left;
  white-space: normal;
  border-radius: 0;
  display: block;
  background-color: transparent;
}

.pp-transform-site-card .kv .value {
  font-size: 16px;
  color: var(--text, #1a1a1a);
  font-weight: 700;
  word-break: break-word;
}

/* Incomplete callout banner at the bottom of a card */
.pp-transform-site-card .site-callout {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--progress-bg, #fff7db);
  color: var(--progress-text, #8a6d00);
  border-radius: 12px;
  padding: 14px;
  border: 1px solid rgba(138, 109, 0, 0.18);
}

.pp-transform-site-card .site-callout__left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.pp-transform-site-card .site-callout__text {
  font-weight: 700;
  font-size: 14px;
  color: var(--progress-text, #8a6d00);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pp-transform-site-card .site-callout .fa {
  width: 20px;
  height: 20px;
  font-size: 20px;
  line-height: 1;
  flex: 0 0 auto;
}

/* Responsive card/body layout mirrors the reference template. */
@media (max-width: 1200px) {
  .pp-transform-site-card .card-body { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}

@media (max-width: 900px) {
  .pp-transform-site-card .card-body { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}

@media (max-width: 560px) {
  .card.site-card.pp-transform-site-card { grid-template-columns: 1fr; }
  .pp-transform-site-card .card-body { grid-template-columns: 1fr !important; }
  .pp-transform-site-card .site-callout__text { white-space: normal; }
}

/* --------------------------------------------- */
/* renderSubgridAsLists (dw-*)                   */
/* Note: core dw-* rules are also injected at    */
/* runtime via ensureDwStyles() in the script.   */
/* Defining them here allows pages to load them  */
/* as a CSS asset instead of relying on JS.      */
/* --------------------------------------------- */

/* Outer wrapper: surfaced on top of the OOTB grid */
.dw-cards.pp-transform-dw {
  background: var(--dw-surface-bg, #FFF5E6);
  padding: 20px 24px;
  border-radius: 12px;
  overflow: auto;
  margin: 30px 0;
}

/* Column header row */
.pp-transform-dw .dw-header {
  display: grid;
  gap: 16px;
  color: var(--dw-header-color, #333);
  font-weight: 600;
  padding: 8px 12px;
  grid-template-columns: var(--dw-grid-template-active, var(--dw-grid-template, 1fr));
  width: max-content;
  min-width: 100%;
  box-sizing: border-box;
}

.pp-transform-dw .dw-col--head {
  user-select: none;
}

/* Sortable column headers */
.pp-transform-dw .dw-sortable {
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pp-transform-dw .dw-sortable.dw-sort-asc::after {
  content: "▲";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-55%);
  font-size: 10px;
  color: var(--dw-header-color, #333);
  opacity: 0.5;
}

.pp-transform-dw .dw-sortable.dw-sort-desc::after {
  content: "▼";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-45%);
  font-size: 10px;
  color: var(--dw-header-color, #333);
  opacity: 0.5;
}

/* Row list */
.pp-transform-dw .dw-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
  align-items: flex-start;
}

/* Individual data row */
.pp-transform-dw .dw-row {
  display: grid;
  gap: 16px;
  align-items: center;
  background: var(--dw-card-bg, #fff);
  border-radius: 10px;
  padding: 16px 12px;
  grid-template-columns: var(--dw-grid-template-active, var(--dw-grid-template, 1fr));
  width: max-content;
  min-width: 100%;
  box-sizing: border-box;
}

/* First column is the primary identifier — bold */
.pp-transform-dw .dw-col:first-child {
  font-weight: 700;
}

.pp-transform-dw .dw-col {
  color: var(--dw-cell-color, #1F1F1F);
}

/* Edit link cell */
.pp-transform-dw .dw-edit {
  justify-self: end;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: var(--dw-action-width, 70px);
  text-decoration: none;
  color: var(--dw-edit-color, #1F1F1F);
  font-weight: 600;
  gap: 16px;
}

.pp-transform-dw .dw-edit .edit-link {
  display: inline-flex;
}

/* Edit column header cell */
.pp-transform-dw .dw-col--edit {
  justify-self: end;
  width: var(--dw-action-width, 70px);
}

/* Delete action link */
.pp-transform-dw .dw-delete {
  display: inline-flex;
  gap: 5px;
}

/* Create/add action button wrapper above the list */
.pp-transform-dw .dw-actions {
  margin-bottom: 12px;
}

/* Responsive: collapse to single-column card layout on mobile */
@media (max-width: 768px) {
  .dw-cards.pp-transform-dw {
    padding: 16px;
  }

  .pp-transform-dw.pp-transform-dw--stacked {
    --dw-grid-template-active: 1fr;
  }

  .pp-transform-dw.pp-transform-dw--stacked .dw-header { display: none; }
  .pp-transform-dw.pp-transform-dw--stacked .dw-row {
    gap: 10px;
    padding: 14px 16px;
  }

  .pp-transform-dw.pp-transform-dw--stacked .dw-col,
  .pp-transform-dw.pp-transform-dw--stacked .dw-edit {
    display: grid;
    grid-template-columns: minmax(110px, 40%) 1fr;
    gap: 10px;
    align-items: start;
    width: 100%;
    justify-self: stretch;
  }

  .pp-transform-dw.pp-transform-dw--stacked .dw-col::before,
  .pp-transform-dw.pp-transform-dw--stacked .dw-edit::before {
    content: attr(data-label);
    font-size: 12px;
    font-weight: 600;
    color: var(--dw-header-color, #333);
  }

  .pp-transform-dw.pp-transform-dw--stacked .dw-edit {
    justify-content: flex-start;
    margin-top: 0;
    width: 100%;
  }

  .pp-transform-dw.pp-transform-dw--stacked .dw-edit .edit-link {
    justify-self: start;
  }

  .pp-transform-dw.pp-transform-dw--stacked .dw-col--primary {
    font-weight: 700;
  }
}

@media (max-width: 520px) {
  .pp-transform-dw.pp-transform-dw--stacked .dw-col,
  .pp-transform-dw.pp-transform-dw--stacked .dw-edit {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* --------------------------------------------- */
/* renderMirrorBlock (.ha-cohort-*)              */
/* Cohort input block that mirrors form fields   */
/* --------------------------------------------- */

/* Block container */
.ha-cohort-block {
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  overflow: hidden;
  margin-bottom: 1.5rem;
  font-family: Aptos, sans-serif;
  font-size: 16px;
  font-style: normal;
  font-weight: 400;
  line-height: 120%;
}

/* Grid rows – column ratio applied inline by JS from columnRatio config */
.ha-cohort-row {
  display: grid;
  align-items: center;
  column-gap: 1rem;
  padding: 12px 24px;
}

/* Header row */
.ha-cohort-row--header {
  background-color: #f5f5f5;
  font-weight: 600;
  font-size: 0.9rem;
  border-bottom: 1px solid #e0e0e0;
  border-radius: 8px 8px 0 0;
}

/* Data rows – no shading */
.ha-cohort-row--odd,
.ha-cohort-row--even { background-color: transparent; }

/* Total/summary row – shaded to match header */
.ha-cohort-row--total {
  background-color: #f5f5f5;
  border-top: 1px solid #e0e0e0;
  border-radius: 0 0 8px 8px;
}

/* Label cell */
.ha-cohort-label {
  font-size: 0.9rem;
  line-height: 1.4;
  cursor: default;
}

/* Show help cursor when a tooltip title is present */
.ha-cohort-label[title] {
  cursor: help;
}

/* Total row typography */
.ha-cohort-total-label,
.ha-cohort-total-value {
  font-weight: 700;
  font-size: 0.9rem;
}
.ha-cohort-total-value {
  padding-left: 16px;
}

/* Pill-style input – spin buttons removed */
.ha-cohort-input {
  -moz-appearance: textfield; /* remove Firefox number spinner */
  appearance: textfield;

  width: 100%;
  box-sizing: border-box;
  border: 1px solid #d9d9d9;
  border-radius: 999px;
  background-color: #f0f0f0;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #333;
  text-align: left;
  outline: none;
  transition: border-color 0.15s, background-color 0.15s;
}

/* Remove webkit spin buttons */
.ha-cohort-input::-webkit-outer-spin-button,
.ha-cohort-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.ha-cohort-input:focus {
  border-color: #999;
  background-color: #fff;
}
