/* Creative MRI / Command Center: setup panel, report summary, ad cards */

/* Main layout: sidebar + report, or full-width report */
.mri-main {
  display: flex;
  flex-direction: row;
  gap: 24px;
  align-items: flex-start;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}
.mri-main.mri-report-view {
  max-width: 2400px;
}
.mri-main.mri-report-view .mri-setup-sidebar-slot {
  display: none;
}
.mri-main.mri-report-view .mri-results {
  flex: 1;
  min-width: 0;
}
.mri-setup-sidebar-slot {
  flex-shrink: 0;
  max-width: 400px;
}
.brands-imports-panel {
  flex-shrink: 0;
  max-width: 400px;
}
.mri-results {
  flex: 1;
  min-width: 0;
}

.mri-report-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.mri-report-header .mri-report-title {
  flex: 1;
  min-width: 0;
  margin: 0;
}
.mri-back-to-setup {
  flex-shrink: 0;
}

/* Report header actions: edit pencil, save, cancel */
.mri-report-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.mri-edit-pencil-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  background: var(--surface, #fff);
  color: var(--muted, #718096);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.mri-edit-pencil-btn:hover {
  background: var(--bg, #f5f7fb);
  color: var(--text, #1a202c);
  border-color: var(--brand-color, #b9f040);
}
.mri-save-btn,
.mri-cancel-btn {
  display: none;
}
.mri-report-header-actions.is-edit-mode .mri-edit-pencil-btn {
  display: none;
}
.mri-report-header-actions.is-edit-mode .mri-save-btn,
.mri-report-header-actions.is-edit-mode .mri-cancel-btn {
  display: inline-flex;
}

/* Edit mode: contenteditable areas */
.mri-edit-mode .mri-summary,
.mri-edit-mode #mriImpactScoreboard {
  outline: 2px solid rgba(185, 240, 64, 0.4);
  outline-offset: 2px;
  border-radius: 6px;
  min-height: 60px;
}

@media (max-width: 768px) {
  .mri-main {
    flex-direction: column;
  }
  .mri-setup-sidebar-slot,
  .brands-imports-panel {
    max-width: none;
  }
}

/* Brands & Imports modal overlay (when "Back to setup" from report view) */
.mri-setup-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.mri-setup-modal-overlay.mri-setup-modal--open {
  opacity: 1;
  visibility: visible;
}
.mri-setup-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
.mri-setup-modal {
  position: relative;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(16px);
  transition: transform 0.2s ease;
}
.mri-setup-modal-overlay.mri-setup-modal--open .mri-setup-modal {
  transform: translateY(0);
}
.mri-setup-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted, #718096);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.2s ease, color 0.2s ease;
}
.mri-setup-modal__close:hover {
  background: var(--bg, #f5f7fb);
  color: var(--text, #1a202c);
}
.mri-setup-modal__body {
  padding-top: 8px;
  padding-right: 36px;
}
.mri-setup-modal__body .brands-imports-panel {
  max-width: none;
  border: none;
  padding: 0;
}

/* Command Center layout */
.command-center-section.health-summary,
.command-center-section.impact-scoreboard {
  margin-bottom: 24px;
}
.command-center-section--full {
  width: 100%;
}
.impact-scoreboard-grid-inner {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 12px;
}
@media (max-width: 900px) {
  .impact-scoreboard-grid-inner {
    grid-template-columns: 1fr;
  }
}
.impact-scoreboard-cell {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.impact-scoreboard-cell:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border-color: rgba(185, 240, 64, 0.4);
}
.impact-scoreboard-cell .mri-action-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}
.impact-scoreboard-cell .mri-action-number {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brand-color, #b9f040);
  background: rgba(185, 240, 64, 0.15);
  border-radius: 8px;
  line-height: 1;
}
.impact-scoreboard-cell .mri-action-header-content {
  flex: 1;
  min-width: 0;
}
.impact-scoreboard-cell .mri-action-header strong {
  display: block;
  font-size: 1.125rem;
  font-weight: 700;
}
.impact-scoreboard-cell .mri-action-header .mri-action-meta {
  display: block;
  margin-top: 4px;
  margin-left: 0;
}
.impact-scoreboard-cell .mri-action-why,
.impact-scoreboard-cell .mri-action-brief {
  margin: 0 0 8px 0;
  line-height: 1.4;
}
.impact-scoreboard-cell .mri-roadmap-phases p {
  margin: 0 0 8px 0;
  font-size: 13px;
}
.impact-scoreboard-cell.mri-action-item {
  padding: 14px 16px;
  border-bottom: none;
}
.impact-scoreboard-cell.mri-roadmap-cell {
  background: linear-gradient(135deg, rgba(185, 240, 64, 0.08) 0%, rgba(185, 240, 64, 0.03) 100%);
  border-left: 4px solid var(--brand-color, #b9f040);
}
.command-center-section {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
/* Report headline hierarchy */
.mri-report-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text, #1a202c);
  margin: 0 0 24px 0;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.mri-section-heading {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text, #1a202c);
  margin: 0 0 16px 0;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--brand-color, #b9f040);
  letter-spacing: -0.01em;
}
.mri-subsection-heading {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text, #1a202c);
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}
#mriContent > h3.mri-section-heading {
  margin-top: 28px;
}
.command-center-section.impact-scoreboard ul {
  margin: 0;
  padding-left: 20px;
}
.command-center-section.impact-scoreboard li {
  margin-bottom: 6px;
  font-size: 13px;
}
.mri-actions-list {
  margin: 0;
  padding-left: 20px;
  list-style: decimal;
}
.mri-actions-list li {
  margin-bottom: 12px;
}
.mri-action-meta {
  font-size: 12px;
  color: var(--muted, #718096);
  margin-left: 6px;
}

/* Tab toggles */
.mri-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  overflow: hidden;
  width: fit-content;
}
.mri-tabs--primary {
  margin-bottom: 24px;
}
.mri-tabs--secondary {
  margin-bottom: 16px;
  margin-top: 4px;
}
.mri-tabs--secondary .mri-tab {
  padding: 8px 16px;
  font-size: 13px;
}
.mri-tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  background: var(--bg, #f5f7fb);
  color: var(--muted, #718096);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.mri-tab:first-child {
  border-right: 1px solid var(--border, #e2e8f0);
}
.mri-tab:hover {
  background: var(--surface, #fff);
  color: var(--text, #1a202c);
}
.mri-tab.mri-tab--active {
  background: var(--surface, #fff);
  color: var(--text, #1a202c);
  font-weight: 600;
}
.mri-tab-pane {
  display: none;
}
.mri-tab-pane.mri-tab-pane--active {
  display: block;
}

/* Panel and section styling */
.mri-panel {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 20px 24px;
}
.mri-panel h2 {
  margin: 0 0 6px 0;
  font-size: 1.125rem;
  font-weight: 600;
}
.mri-panel-desc {
  font-size: 13px;
  color: var(--muted, #718096);
  margin-bottom: 20px;
  line-height: 1.5;
}


/* Form sections and rows - consistent layout */
.mri-form-section {
  min-width: 0;
}
.mri-form-section h3 {
  margin: 0 0 12px 0;
  font-size: 0.9375rem;
  font-weight: 600;
}
.mri-form-row {
  margin-bottom: 14px;
}
.mri-form-row label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #1a202c);
}
.mri-form-row input,
.mri-form-row select {
  width: 100%;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface, #fff);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.mri-form-row input:focus,
.mri-form-row select:focus {
  outline: none;
  border-color: var(--primary, #b9f040);
  box-shadow: 0 0 0 2px rgba(185, 240, 64, 0.2);
}
.mri-form-row--inline {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}
.mri-form-row--inline label {
  margin-bottom: 0;
  flex-shrink: 0;
}
.mri-input-narrow {
  width: 72px !important;
  max-width: 72px !important;
}
.mri-form-section .btn {
  margin-top: 4px;
}

/* Message feedback */
.mri-message {
  margin-top: 12px;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 8px;
  line-height: 1.4;
}
.mri-message--success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.mri-message--error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.mri-results {
  margin-top: 24px;
}
.mri-loading {
  padding: 32px 24px;
  text-align: center;
  color: var(--muted, #718096);
}
.mri-loading--active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}
.mri-loading-prelude {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.mri-loading.mri-loading--progress .mri-loading-prelude {
  display: none;
}
.mri-loading.mri-loading--progress .mri-progress-container {
  margin-top: 0;
  align-self: center;
}
.mri-loading.mri-loading--synthesize .mri-progress-container {
  display: none;
}
.mri-loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border, #e2e8f0);
  border-top-color: var(--brand-color, #b9f040);
  border-radius: 50%;
  animation: mri-spin 1s linear infinite;
  flex-shrink: 0;
}
@keyframes mri-spin {
  to { transform: rotate(360deg); }
}
.mri-loading-title {
  font-weight: 600;
  color: var(--text, #1a202c);
  margin: 0;
  font-size: 15px;
}
.mri-loading-detail {
  font-size: 13px;
  margin: 0;
  max-width: 360px;
  color: var(--muted, #718096);
}
.mri-progress-track {
  height: 8px;
  background: var(--bg, #f5f7fb);
  border-radius: 4px;
  overflow: hidden;
}
.mri-progress-fill {
  height: 100%;
  background: var(--brand-color, #b9f040);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.mri-progress-message {
  font-size: 13px;
  color: var(--muted, #718096);
  margin: 8px 0 0 0;
}
.mri-progress-message:empty {
  display: none;
}
.mri-loading-stuck {
  font-size: 13px;
  color: var(--muted, #718096);
  margin: 12px 0 0 0;
  max-width: 360px;
}

/* Charts */
.mri-charts {
  display: grid;
  gap: 24px;
  margin-bottom: 24px;
}
@media (min-width: 640px) {
  .mri-charts {
    grid-template-columns: repeat(2, 1fr);
  }
}
.mri-chart {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.mri-chart-title {
  margin: 0 0 14px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.mri-chart--d3 {
  min-height: 200px;
}
.mri-chart--d3 > div {
  min-height: 180px;
}
.mri-chart-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mri-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.mri-bar-label {
  flex: 0 0 120px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text, #1a202c);
}
.mri-bar-track {
  flex: 1;
  min-width: 0;
  height: 22px;
  background: var(--bg, #f5f7fb);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}
.mri-bar-fill {
  height: 100%;
  border-radius: 6px;
  background: var(--brand-color, #b9f040);
  transition: width 0.3s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.mri-bar-fill--hook {
  background: linear-gradient(135deg, #74c7e8 0%, #5bb8db 100%);
}
.mri-bar-fill--funnel {
  background: linear-gradient(135deg, #6fd4a1 0%, #4ec289 100%);
}
.mri-bar-value {
  flex: 0 0 36px;
  text-align: right;
  font-weight: 600;
  color: var(--muted, #718096);
}
.mri-summary {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.mri-summary h3.mri-section-heading {
  margin-top: 0;
}
.mri-summary .score {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text, #1a202c);
}
.mri-summary ul {
  margin: 0;
  padding-left: 20px;
}
.mri-summary li {
  margin-bottom: 6px;
  font-size: 13px;
}
.mri-summary-block {
  margin-bottom: 16px;
  padding: 12px 16px;
  background: rgba(185, 240, 64, 0.06);
  border-left: 4px solid var(--brand-color, #b9f040);
  border-radius: 0 8px 8px 0;
}
.mri-summary-block:last-child {
  margin-bottom: 0;
}
.mri-summary-block p {
  margin: 0 0 8px 0;
  font-size: 14px;
  line-height: 1.5;
}
.mri-summary-block p:last-child {
  margin-bottom: 0;
}
.mri-summary-block strong {
  color: var(--text, #1a202c);
}
.mri-action-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.mri-action-item:last-child {
  border-bottom: none;
}
.mri-action-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}
.mri-action-header .mri-action-meta {
  font-size: 12px;
  color: var(--muted, #718096);
}
.mri-action-why {
  margin: 0 0 8px 0;
  font-size: 14px;
  line-height: 1.5;
}
.mri-action-brief {
  margin: 4px 0 0 0;
  padding-left: 20px;
}
.mri-action-brief li {
  margin-bottom: 4px;
  font-size: 13px;
}
.mri-roadmap-phases p {
  margin: 0 0 8px 0;
  font-size: 14px;
  line-height: 1.5;
}
.mri-roadmap-phases p:last-child {
  margin-bottom: 0;
}
.mri-ad-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: var(--font-lato, 'Lato'), sans-serif;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.2s ease;
}
.mri-ad-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.mri-ad-card__mockup {
  flex-shrink: 0;
}
.mri-ad-card__mockup .pe-fb-ad {
  border-radius: 8px 8px 0 0;
  border: none;
}
.mri-ad-card__mockup .pe-fb-ad__media.has-image {
  aspect-ratio: unset;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f7fb;
}
.mri-ad-card__mockup .pe-fb-ad__media.has-image img,
.mri-ad-card__mockup .pe-fb-ad__media.has-image video {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  max-width: 100%;
}
/* MRI card header: labels above ad */
.mri-ad-card__header.ads-card__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
}
.mri-ad-card__labels {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
}
.mri-ad-card__label {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  background: var(--surface, #fff);
  border-radius: 6px;
  border: 1px solid var(--border, #e2e8f0);
  color: var(--text, #1a202c);
}
.mri-ad-card__label:first-child {
  border-left: 3px solid var(--brand-color, #b9f040);
}
.mri-ad-card__transcript-body {
  font-size: 12px;
  color: var(--muted, #718096);
  max-height: 150px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}
/* Masonry newspaper layout (matches ads tab) */
.mri-ads-grid {
  position: relative;
}
.mri-ads-grid-sizer,
.mri-ad-card {
  width: calc(50% - 12px);
}
.mri-ads-gutter-sizer {
  width: 24px;
}
@media (min-width: 1270px) {
  .mri-ads-grid-sizer,
  .mri-ad-card {
    width: calc(33.333% - 16px);
  }
}
@media (min-width: 1680px) {
  .mri-ads-grid-sizer,
  .mri-ad-card {
    width: calc(25% - 18px);
  }
}
@media (min-width: 2100px) {
  .mri-ads-grid-sizer,
  .mri-ad-card {
    width: calc(20% - 19.2px);
  }
}
@media (max-width: 768px) {
  .mri-ads-grid-sizer,
  .mri-ad-card {
    width: 100%;
  }
}

/* History tab */
.mri-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}
.mri-history-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 16px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  background: var(--surface, #fff);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.2s, border-color 0.2s;
}
.mri-history-item:hover {
  background: var(--bg, #f5f7fb);
  border-color: var(--primary, #b9f040);
}
.mri-history-brand {
  font-weight: 600;
  color: var(--text, #1a202c);
}
.mri-history-meta {
  font-size: 13px;
  color: var(--muted, #718096);
}
.mri-history-empty {
  font-size: 14px;
  color: var(--muted, #718096);
  margin: 0;
  padding: 24px 0;
}
