/* ==========================================================
   Admin AI — page-specific styling only
   Core visual system comes from admin.css

   This file should only contain styles unique to admin-ai.html.
   Keep selectors scoped to .cmsAiPage so they do not leak into
   other admin pages.
========================================================== */

/* Top header spacing for the AI page */
.cmsAiPage .cmsTopbar {
  margin-bottom: 16px;
}

/* Main page title */
.cmsAiPage .cmsTopbarTitle {
  font-size: 20px;
  font-weight: 900;
  margin: 0 0 6px;
}

/* Small descriptive text under the title */
.cmsAiPage .cmsTopbarSubtext {
  margin: 0;
}

/* Main form card padding */
.cmsAiPage .cmsForm {
  padding: 14px 16px 18px;
}

/* Remove extra bottom gap from the last field in a form block */
.cmsAiPage .cmsForm .field:last-child {
  margin-bottom: 0;
}

/* Small helper note under section labels or inputs */
.cmsAiPage .cmsSectionNote {
  margin-top: 6px;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.62);
}

/* Inline action row for buttons and controls */
.cmsAiPage .cmsInlineActions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* Metadata row above the editor, such as current mode / article info */
.cmsAiPage .cmsEditorMeta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* Small meta text in the editor header */
.cmsAiPage .cmsEditorMetaText {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.92);
}

/* Highlight important meta text */
.cmsAiPage .cmsEditorMetaText strong {
  color: #fff;
}

/* Preview panel scroll behavior on desktop */
.cmsAiPage .cmsPreviewPane {
  overflow: auto;
}

/* White article preview background */
.cmsAiPage .articlePreview {
  background: #fff;
}

/* Inner article preview spacing */
.cmsAiPage .articlePreview .container.article {
  margin: 0;
  padding: 0 16px 24px;
}

/* Preview article title */
.cmsAiPage .articlePreview h1 {
  margin: 16px 0 6px;
  line-height: 1.12;
}

/* Intro line inside the live preview */
.cmsAiPage .articlePreviewIntro {
  font-size: 15px;
  line-height: 1.6;
  font-weight: 600;
}

/* Main article body inside the live preview */
.cmsAiPage .articlePreviewBody {
  line-height: 1.72;
  font-size: 15px;
}

/* Section headers inside the preview body */
.cmsAiPage .articlePreviewBody h2 {
  margin: 28px 0 10px;
  line-height: 1.2;
  font-size: 22px;
  font-weight: 800;
}

/* Paragraph and content spacing inside the preview body */
.cmsAiPage .articlePreviewBody p,
.cmsAiPage .articlePreviewBody ul,
.cmsAiPage .articlePreviewBody ol,
.cmsAiPage .articlePreviewBody blockquote {
  margin: 0 0 14px;
}

/* List indentation inside the preview body */
.cmsAiPage .articlePreviewBody ul,
.cmsAiPage .articlePreviewBody ol {
  padding-left: 22px;
}

/* List of previously published articles */
.cmsAiPage .publishedArticles {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Individual article card/button in the published list */
.cmsAiPage .publishedArticleItem {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: #fff;
  padding: 12px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease,
    background 0.15s ease;
}

/* Hover effect for published article cards */
.cmsAiPage .publishedArticleItem:hover {
  background: #f7fbff;
  transform: translateY(-1px);
}

/* Article card title */
.cmsAiPage .publishedArticleTitle {
  font-weight: 800;
  line-height: 1.35;
  margin: 0 0 4px;
}

/* Small metadata line under article title */
.cmsAiPage .publishedArticleMeta {
  font-size: 12px;
  color: rgba(0, 0, 0, 0.62);
  margin: 0 0 6px;
}

/* Excerpt text in the article list */
.cmsAiPage .publishedArticleExcerpt {
  font-size: 13px;
  line-height: 1.5;
  color: rgba(0, 0, 0, 0.8);
}

/* "Editing existing article" style badge */
.cmsAiPage .editModeBadge {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #c9defc;
  background: linear-gradient(180deg, #eef6ff 0%, #e3f0ff 100%);
}

/* Cover image preview thumbnail */
.cmsAiPage .cmsCoverThumb {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

/* Bottom save/publish area */
.cmsAiPage .saveBottomWrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

/* Sticky action bar at the bottom of the page */
.cmsAiPage .cmsActionBar {
  position: sticky;
  bottom: 0;
  z-index: 20;
}

/* Tablet layout: shrink left column and hide published panel */
@media (max-width: 1100px) {
  .cmsAiPage .cmsGrid {
    grid-template-columns: 360px minmax(0, 1fr);
  }

  .cmsAiPage .publishedPanel {
    display: none;
  }
}

/* Mobile layout: stack the page into one column */
@media (max-width: 860px) {
  .cmsAiPage .cmsGrid {
    grid-template-columns: 1fr;
  }

  .cmsAiPage .cmsPreviewPane {
    overflow: visible;
  }
}

/* 
   Wraps a button plus its local inline status message.
   Use this around Generate Article / Generate Cover Prompt / Generate Cover Image.
*/
.cmsAiPage .adminAiAction {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

/* 
   Small live status text shown directly under the action button.
   Default state = neutral helper text.
*/
.cmsAiPage .adminAiInlineStatus {
  min-height: 1.2em;
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--muted, #8ea0b8);
}

/* Error state for the inline status */
.cmsAiPage .adminAiInlineStatus.isError {
  color: var(--danger, #c0392b);
}

/* Busy / loading state for the inline status */
.cmsAiPage .adminAiInlineStatus.isBusy {
  color: var(--brand-gold, #d4af37);
}

/* ==========================================================
   Social post cards
========================================================== */

.cmsAiPage .socialPostList {
  display: grid;
  gap: 12px;
}

.cmsAiPage .socialPostCard {
  position: relative;
  background: #fff;
  border: 1px solid rgba(21, 48, 84, 0.14);
  border-radius: 14px;
  padding: 12px 44px 12px 12px;
  box-shadow: 0 4px 14px rgba(11, 24, 44, 0.06);
}

.cmsAiPage .socialPostCard pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  font: inherit;
  line-height: 1.5;
  color: #10233f;
}

.cmsAiPage .socialCopyBtn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(21, 48, 84, 0.16);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.cmsAiPage .socialCopyBtn:hover {
  background: #f4f7fb;
  border-color: rgba(21, 48, 84, 0.28);
}

.cmsAiPage .socialCopyBtn:active {
  transform: scale(0.96);
}

.cmsAiPage .socialCopyBtn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  color: #153054;
}

.cmsAiPage .socialCopyBtn.isCopied {
  background: #e8f7ee;
  border-color: rgba(30, 120, 60, 0.35);
}

.cmsAiPage .socialCopyBtn.isCopied svg {
  color: #1e7a3c;
}

/* ==========================================================
   AI Writer author-help labels and tooltips
   Keep this in admin-ai.css, not inline in ai-writer.html.
   This structure avoids conflicts with admin.css .field > span.
========================================================== */

.cmsAiPage .field > .aiWriterFieldLabelText {
  display: block;
  margin: 0 0 6px 2px;
  color: #111;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.25px;
  line-height: 1.35;
  overflow: visible !important;
}

.cmsAiPage .aiWriterHelpWrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 6px;
  overflow: visible !important;
}

.cmsAiPage .aiWriterHelpIcon {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(37, 99, 235, 0.28);
  border-radius: 999px;
  background: rgba(239, 246, 255, 0.98);
  color: #1d4ed8;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  cursor: help;
}

.cmsAiPage .aiWriterTooltip {
  position: absolute;
  left: 50%;
  top: calc(100% + 10px);
  z-index: 7000;
  width: min(360px, calc(100vw - 64px));
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 12px;
  background: #0f172a;
  color: #ffffff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.28);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0;
  white-space: normal;
  opacity: 0;
  transform: translate(-18px, -4px);
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.cmsAiPage .aiWriterTooltip::after {
  content: "";
  position: absolute;
  left: 14px;
  top: -14px;
  border: 7px solid transparent;
  border-bottom-color: #0f172a;
}

.cmsAiPage .aiWriterHelpWrap:hover .aiWriterTooltip,
.cmsAiPage .aiWriterHelpWrap:focus-within .aiWriterTooltip {
  opacity: 1;
  transform: translate(-18px, 0);
}

.cmsAiPage .aiWriterPrimaryPane,
.cmsAiPage .aiWriterPrimaryPane .cmsPaneHead,
.cmsAiPage .aiWriterPrimaryPane .cmsForm,
.cmsAiPage .aiWriterPrimaryPane .field {
  overflow: visible !important;
}

.cmsAiPage #aiExtra {
  min-height: 260px;
  resize: vertical;
}

@media (max-width: 560px) {
  .cmsAiPage .field > .aiWriterFieldLabelText {
    position: relative;
    overflow: visible !important;
  }

  .cmsAiPage .aiWriterHelpWrap {
    position: static;
  }

  .cmsAiPage .aiWriterTooltip {
    left: 0;
    right: auto;
    top: calc(100% + 10px);
    width: min(320px, calc(100vw - 96px));
    max-width: calc(100vw - 96px);
    transform: translateY(-4px);
  }

  .cmsAiPage .aiWriterHelpWrap:hover .aiWriterTooltip,
  .cmsAiPage .aiWriterHelpWrap:focus-within .aiWriterTooltip {
    transform: translateY(0);
  }

  .cmsAiPage .aiWriterTooltip::after {
    left: 12px;
    right: auto;
  }

  .cmsAiPage #aiExtra {
    min-height: 300px;
  }
}

/* ==========================================================
   AI Writer prominent primary action buttons
   Makes Proofread/Finalize and Cover Image actions stand out.
========================================================== */

.cmsAiPage .aiWriterButtonStack {
  gap: 14px;
  margin-top: 6px;
}

.cmsAiPage .aiWriterButtonStack .adminAiAction {
  width: 100%;
}

.cmsAiPage .aiWriterButtonStack button.primary {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 58px;
  padding: 16px 18px;
  border: 0;
  border-radius: 18px;
  color: #ffffff;
  font: inherit;
  font-size: 16px;
  font-weight: 950;
  line-height: 1.2;
  letter-spacing: 0.01em;
  text-align: center;
  cursor: pointer;
  box-shadow:
    0 14px 30px rgba(15, 23, 42, 0.20),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    filter 0.16s ease;
}

.cmsAiPage .aiWriterButtonStack button.primary::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(
    110deg,
    transparent 0%,
    rgba(255, 255, 255, 0.26) 38%,
    transparent 72%
  );
  transform: translateX(-115%);
  transition: transform 0.55s ease;
}

.cmsAiPage .aiWriterButtonStack button.primary:hover,
.cmsAiPage .aiWriterButtonStack button.primary:focus-visible {
  transform: translateY(-2px);
  filter: saturate(1.08);
  box-shadow:
    0 18px 38px rgba(15, 23, 42, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.cmsAiPage .aiWriterButtonStack button.primary:hover::before,
.cmsAiPage .aiWriterButtonStack button.primary:focus-visible::before {
  transform: translateX(115%);
}

.cmsAiPage .aiWriterButtonStack button.primary:focus-visible {
  outline: 3px solid rgba(201, 141, 38, 0.38);
  outline-offset: 3px;
}

.cmsAiPage .aiWriterButtonStack button.primary:active {
  transform: translateY(0);
  box-shadow:
    0 9px 20px rgba(15, 23, 42, 0.20),
    inset 0 2px 8px rgba(15, 23, 42, 0.18);
}

.cmsAiPage .aiWriterButtonStack button.primary:disabled,
.cmsAiPage .aiWriterButtonStack button.primary[aria-disabled="true"] {
  cursor: not-allowed;
  filter: grayscale(0.2) saturate(0.75);
  opacity: 0.68;
  transform: none;
  box-shadow: none;
}

.cmsAiPage #btnGenerateArticle.primary {
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.20), transparent 34%),
    linear-gradient(135deg, #0b2447 0%, #1d4ed8 54%, #2563eb 100%);
}

.cmsAiPage #btnGenerateCoverImage.primary {
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.26), transparent 34%),
    linear-gradient(135deg, #7c4a03 0%, #c98d26 48%, #f59e0b 100%);
}

.cmsAiPage #btnGenerateArticle.primary::after,
.cmsAiPage #btnGenerateCoverImage.primary::after {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-left: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  font-size: 15px;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.cmsAiPage #btnGenerateArticle.primary::after {
  content: "✓";
}

.cmsAiPage #btnGenerateCoverImage.primary::after {
  content: "★";
}

.cmsAiPage .aiWriterButtonStack .adminAiInlineStatus {
  width: 100%;
  padding-left: 4px;
  font-size: 13px;
}

@media (max-width: 560px) {
  .cmsAiPage .aiWriterButtonStack button.primary {
    min-height: 54px;
    padding: 14px 16px;
    border-radius: 16px;
    font-size: 15px;
  }
}

/* ==========================================================
   Mobile viewport stability fix
   Prevents the page from zooming/shrinking after article or cover actions.
========================================================== */
@media (max-width: 860px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .adminPage.cmsAiPage,
  .cmsAiPage .cmsShell,
  .cmsAiPage .aiWriterThreeColumnLayout,
  .cmsAiPage .aiWriterLeftColumn,
  .cmsAiPage .aiWriterMiddleColumn,
  .cmsAiPage .aiWriterArticleListColumn,
  .cmsAiPage .cmsPane,
  .cmsAiPage .cmsForm,
  .cmsAiPage .articlePreview,
  .cmsAiPage .articlePreview * {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .cmsAiPage input,
  .cmsAiPage textarea,
  .cmsAiPage select,
  .cmsAiPage button {
    font-size: 16px;
  }

  .cmsAiPage img,
  .cmsAiPage video,
  .cmsAiPage canvas,
  .cmsAiPage svg {
    max-width: 100%;
    height: auto;
  }

  .cmsAiPage .articlePreview,
  .cmsAiPage .articlePreviewBody,
  .cmsAiPage .articlePreviewInner,
  .cmsAiPage .articlePreview p,
  .cmsAiPage .articlePreview h1,
  .cmsAiPage .articlePreview h2,
  .cmsAiPage .articlePreview li,
  .cmsAiPage .articlePreview pre {
    overflow-wrap: anywhere;
    word-break: normal;
  }

  html[data-ai-writer-mode="edit"] .aiWriterMiddleColumn,
  html[data-ai-writer-has-generated="true"] .aiWriterMiddleColumn {
    display: none !important;
  }

  .cmsAiPage .coverImageBusyOverlay {
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .cmsAiPage .coverImageBusyCard {
    width: calc(100vw - 32px);
    max-width: 420px;
  }
}


/* ==========================================================
   AI Writer cover update adjustments
========================================================== */

.cmsAiPage .aiWriterCoverAdjustmentsWrap {
  width: 100%;
  margin-top: 4px;
  padding: 12px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 14px;
  background: rgba(239, 246, 255, 0.72);
}

.cmsAiPage .aiWriterCoverAdjustmentsWrap[hidden] {
  display: none !important;
}

.cmsAiPage .aiWriterCoverAdjustmentsInput {
  width: 100%;
  min-height: 112px;
  resize: vertical;
}

.cmsAiPage .aiWriterCoverAdjustmentsInput.isRequiredError {
  border-color: rgba(185, 28, 28, 0.65);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.12);
}

.cmsAiPage .aiWriterCoverAdjustmentsHelp {
  display: block;
  margin-top: 8px;
  line-height: 1.45;
}


/* Cover adjustment tooltip: keep the example out of the textarea and beside the label. */
.cmsAiPage .aiWriterCoverAdjustmentsWrap .aiWriterFieldLabelText {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.cmsAiPage .aiWriterCoverAdjustmentsWrap .aiWriterHelpWrap {
  margin-left: 0;
}

.cmsAiPage .aiWriterCoverAdjustmentsWrap .aiWriterTooltip {
  width: min(420px, calc(100vw - 64px));
}


/* ==========================================================
   AI Writer / Admin AI right-column article card title sizing
   Keep the title compact so the thumbnail and excerpt remain readable.
   This overrides older inline page-level title sizing.
========================================================== */

html .cmsAiPage .publishedArticles .publishedArticleItem .publishedArticleTitle,
html .cmsAiPage .publishedArticleItem .publishedArticleTitle,
html .cmsAiPage .publishedArticleTitle {
  font-size: 15px !important;
  line-height: 1.24 !important;
  font-weight: 900 !important;
  letter-spacing: 0 !important;
  margin: 0 0 5px !important;
}

@media (max-width: 560px) {
  html .cmsAiPage .publishedArticles .publishedArticleItem .publishedArticleTitle,
  html .cmsAiPage .publishedArticleItem .publishedArticleTitle,
  html .cmsAiPage .publishedArticleTitle {
    font-size: 14px !important;
    line-height: 1.24 !important;
  }
}


/* Article engagement statistics row for admin-ai.html article cards */
.cmsAiPage .publishedArticleStats {
  display: flex;
  align-items: center;
  gap: 10px;
  clear: none;
  margin: 4px 0 8px;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}

.cmsAiPage .publishedArticleStats span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}
