/**
 * Layout helpers — list pages inside Main iframe.
 */

/* Fallback for legacy .aspx pages in #main without cms-list-page / cms-page */
body.cms-in-main-frame {
  padding-top: var(--cms-frame-top-inset, 0px);
  box-sizing: border-box;
}

.cms-page {
  padding: 12px 16px 24px;
  padding-top: calc(12px + var(--cms-frame-top-inset, 0px));
  max-width: 100%;
  box-sizing: border-box;
}

.cms-page-header {
  margin-bottom: 12px;
}

.cms-page-header .cmsHeader {
  margin: 0;
}

.cms-results-scroll {
  overflow: auto;
  border: 1px solid var(--cms-surface-muted);
  border-radius: var(--cms-radius);
  background: var(--cms-surface);
}

/* Legacy pages in #main without cms-list-page flex shell */
body:not(.cms-list-page) .cms-results-scroll {
  max-height: var(--cms-results-max-height);
}

.cms-results-scroll table {
  width: 100%;
}

/* List pages — fill #main iframe height; grid scrolls inside .cms-results-scroll */
html.cms-list-page {
  height: 100%;
  min-height: 100%;
  margin: 0;
  box-sizing: border-box;
}

html.cms-list-page body.cms-list-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: var(--cms-list-viewport-height, 100%);
  margin: 0;
  padding: 0;
  overflow: hidden;
  box-sizing: border-box;
}

html.cms-list-page body.cms-list-page.cms-page {
  padding: 0;
}

.cms-list-shell {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  box-sizing: border-box;
  padding: 12px 16px 16px;
  padding-top: calc(12px + var(--cms-frame-top-inset, 0px));
}

.cms-list-shell .cms-list-chrome {
  flex: 0 0 auto;
}

html.cms-list-page .cms-list-chrome .cmsHeader {
  margin-top: 0;
}

.cms-list-shell .cms-list-chrome .cms-page,
.cms-list-shell > .cms-page {
  padding: 0;
  max-width: 100%;
}

.cms-list-shell > form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
}

.cms-list-shell > form .cms-results-scroll,
.cms-list-shell > .cms-results-scroll {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

html.cms-list-page .cms-results-scroll {
  max-height: none;
}

.cms-toolbar-links {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 16px;
}

.cms-toolbar-links a {
  font-weight: 500;
}

/* ContentEdit.aspx — full-height shell inside #main iframe */
html.cms-content-edit-page,
html.cms-list-page {
  height: 100%;
}

html.cms-content-edit-page,
html.cms-content-edit-page body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  box-sizing: border-box;
}

html.cms-content-edit-page body.cms-content-edit-page {
  padding-top: var(--cms-frame-top-inset, 0px);
}

.cms-content-edit-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  box-sizing: border-box;
}

.cms-content-edit-toolbar {
  flex: 0 0 auto;
  flex-shrink: 0;
  padding: 8px 12px;
  background: var(--cms-surface-muted);
  border-bottom: 1px solid var(--cms-chrome-border);
  overflow-x: auto;
  overflow-y: visible;
  position: relative;
  z-index: 10;
}

.cms-content-edit-toolbar .cms-edit-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  width: 100%;
  min-height: 2.25rem;
}

.cms-content-edit-toolbar .cms-edit-action {
  flex: 0 0 auto;
}

.cms-content-edit-toolbar .cms-edit-action--hidden {
  display: none;
}

.cms-content-edit-toolbar .cms-edit-action--wide {
  min-width: 88px;
}

.cms-content-edit-toolbar .cms-edit-action--grammar {
  min-width: 110px;
}

.cms-content-edit-toolbar .cms-edit-action--retire-now {
  min-width: 138px;
}

.cms-content-edit-toolbar .cms-edit-options {
  padding: 6px 0 2px 0;
}

.cms-content-edit-toolbar .cms-edit-options--hidden {
  display: none;
}

.cms-content-edit-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

.cms-content-edit-frame-wrap {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  position: relative;
}

.cms-content-edit-frame-wrap iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Grammar panel: fixed overlay so it is not clipped beside the editor iframe */
.cms-grammar-panel {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: 92%;
  z-index: 5000;
  display: none;
  overflow-x: hidden;
  overflow-y: auto;
  border-left: 1px solid var(--cms-chrome-border, #ccc);
  background: var(--cms-surface, #fff);
  box-sizing: border-box;
  box-shadow: -3px 0 12px rgba(0, 0, 0, 0.12);
}

.cms-grammar-panel-resize {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 12px;
  cursor: ew-resize;
  z-index: 20;
  box-sizing: border-box;
}

.cms-grammar-panel-resize:hover,
.cms-grammar-panel-resize.cms-grammar-panel-resize--active {
  background: rgba(0, 102, 179, 0.12);
}

body.cms-grammar-panel-resizing {
  cursor: ew-resize !important;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.cms-grammar-panel.cms-grammar-panel--open {
  display: block;
}

.cms-grammar-panel-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--cms-chrome-border, #ccc);
  background: var(--cms-surface-muted, #f5f5f5);
}

.cms-grammar-panel-close {
  min-width: 28px;
  padding: 0 6px;
  line-height: 1.2;
}

.cms-grammar-panel-status {
  display: block;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
  border-bottom: 1px solid var(--cms-surface-muted, #eee);
}

.cms-grammar-inline-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  vertical-align: middle;
  border: 2px solid #ccc;
  border-top-color: #0066b3;
  border-radius: 50%;
  animation: cms-grammar-spin 0.75s linear infinite;
}

.cms-grammar-panel-status--error {
  color: #a40000;
  background: #fff5f5;
}

.cms-grammar-panel-status--success {
  color: #0d5c0d;
  background: #f0faf0;
  font-weight: 600;
}

.cms-grammar-panel-status--loading {
  color: var(--cms-text-muted, #555);
}

.cms-grammar-panel-loading {
  display: none;
  padding: 28px 16px 32px;
  text-align: center;
  font-size: 13px;
  color: var(--cms-text-muted, #555);
}

.cms-grammar-panel-loading--visible {
  display: block;
}

.cms-grammar-panel-loading-text {
  margin-top: 12px;
  line-height: 1.4;
}

.cms-grammar-spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto;
  border: 3px solid var(--cms-surface-muted, #ddd);
  border-top-color: var(--cms-accent, #0066b3);
  border-radius: 50%;
  animation: cms-grammar-spin 0.75s linear infinite;
}

@keyframes cms-grammar-spin {
  to {
    transform: rotate(360deg);
  }
}

.cms-grammar-panel-results {
  display: block;
  min-height: 60px;
  padding: 10px 12px 16px;
}

.cms-grammar-issue {
  margin-bottom: 10px;
  padding: 8px;
  border: 1px solid var(--cms-surface-muted, #ddd);
  border-left: 4px solid var(--cms-surface-muted, #ddd);
  border-radius: var(--cms-radius, 4px);
  background: var(--cms-surface, #fff);
  font-size: 12px;
}

/* Editor-facing ADAM Pulse severities: critical | warning | info */
.cms-grammar-issue--critical {
  border-left-color: #b71c1c;
  background: #fdecea;
}

.cms-grammar-issue--warning {
  border-left-color: #b8860b;
  background: #fff8e1;
}

.cms-grammar-issue--info {
  border-left-color: #607d8b;
  background: #f5f7f8;
}

.cms-grammar-issue-meta {
  font-weight: 600;
  margin-bottom: 4px;
}

.cms-grammar-issue-type {
  font-weight: normal;
  font-size: 11px;
  text-transform: capitalize;
  color: var(--cms-text-muted, #666);
}

.cms-grammar-issue-original {
  color: #a40000;
  margin-bottom: 2px;
}

.cms-grammar-issue-suggestion {
  color: #0d5c0d;
  margin-bottom: 2px;
}

.cms-grammar-issue-message {
  color: var(--cms-text-muted, #555);
  font-style: italic;
}

.cms-grammar-warnings {
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--cms-text-muted, #555);
}

.cms-grammar-warnings ul {
  margin: 4px 0 0 16px;
  padding: 0;
}

.cms-grammar-checked-sections {
  margin-bottom: 12px;
  font-size: 11px;
  color: var(--cms-text-muted, #666);
  line-height: 1.35;
}

.cms-grammar-checked-sections strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--cms-text, #333);
}

.cms-grammar-checked-sections ul {
  margin: 0 0 0 16px;
  padding: 0;
  max-height: 180px;
  overflow-y: auto;
}

.cms-grammar-checked-sections li {
  margin-bottom: 2px;
  word-break: break-word;
}

.cms-grammar-empty {
  font-size: 12px;
  color: var(--cms-text-muted, #555);
}

.cms-grammar-empty--ok {
  margin-top: 8px;
  padding: 16px 12px;
  text-align: center;
  border: 1px solid #b8ddb8;
  border-radius: var(--cms-radius, 4px);
  background: #f0faf0;
  color: #333;
}

/* Never-scanned state — red so it reads as "no, not checked yet" (vs green "passed"). */
.cms-grammar-empty--unscanned {
  margin-top: 8px;
  padding: 16px 12px;
  text-align: center;
  border: 1px solid #f1c0bd;
  border-radius: var(--cms-radius, 4px);
  background: #fdecea;
  color: #333;
}

.cms-grammar-empty--unscanned .cms-grammar-empty-icon,
.cms-grammar-empty--unscanned .cms-grammar-empty-title {
  color: #b3261e;
}

.cms-grammar-empty-icon {
  font-size: 28px;
  line-height: 1;
  color: #0d5c0d;
  margin-bottom: 8px;
  font-weight: bold;
}

.cms-grammar-empty-title {
  font-size: 14px;
  font-weight: 600;
  color: #0d5c0d;
  margin-bottom: 6px;
}

.cms-grammar-empty-detail {
  font-size: 12px;
  color: var(--cms-text-muted, #555);
  line-height: 1.4;
}

/* Live-check category filter: one checkbox per category, shown above the category blocks.
   Only "Spelling" is checked on first render; toggling only shows/hides. */
.cms-grammar-live-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 8px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--cms-surface-muted, #ddd);
  font-size: 12px;
}

.cms-grammar-live-filter-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--cms-text, #333);
  white-space: nowrap;
}

.cms-grammar-live-filter-item input[disabled] {
  cursor: default;
}

.cms-grammar-live-category {
  margin-bottom: 12px;
}

.cms-grammar-live-category-header {
  margin-bottom: 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--cms-text-muted, #555);
}

.cms-grammar-live-none {
  font-size: 12px;
  font-style: italic;
  color: var(--cms-text-muted, #666);
}

/* EditContent.aspx — article mode tabs (nested iframe) */
html.cms-edit-content-page,
html.cms-edit-content-page body.cms-edit-content-page {
  height: 100%;
  margin: 0;
  box-sizing: border-box;
}

.cms-edit-tab-host {
  width: 100%;
  max-width: 100%;
  height: 100%;
  box-sizing: border-box;
}

.cms-edit-content-page {
  margin: 0;
  padding: 10px 12px 12px;
  height: 100%;
  box-sizing: border-box;
  overflow: auto;
  background: var(--cms-surface, #fff);
}

.cms-edit-content-page .tab-pane,
.cms-edit-content-page .dynamic-tab-pane-control.tab-pane {
  margin: 0 !important;
  width: 100% !important;
  max-width: 100%;
  box-sizing: border-box;
}

.cms-edit-content-page .dynamic-tab-pane-control .tab-row {
  overflow-x: auto;
  overflow-y: visible;
  min-height: 2em;
  width: 100%;
  box-sizing: border-box;
}

.cms-edit-content-page .dynamic-tab-pane-control .tab-row .tab {
  top: 0;
  margin-top: 2px;
}

.cms-edit-content-page .dynamic-tab-pane-control .tab-row .tab.selected {
  top: 0;
  margin-bottom: 0;
}

.cms-edit-content-page .dynamic-tab-pane-control .tab-page {
  top: 0;
}
