/**
 * BarrioRadar Research Embed Modal & Button Styles
 * Compliant with BarrioRadar Design System:
 * - System font stack only (zero external fonts)
 * - Accessible focus indicators and high-contrast styling
 * - Clean responsive modal dialog with backdrop blur
 * - Robust CSS Grid bounds (min-width: 0) to prevent horizontal overflow
 */

/* Discoverable Action Button in Research Byline / Sharing Group */
.research-share-btn--embed {
  background: var(--br-color-brand-light, #eff6ff);
  border-color: var(--br-color-brand-accent, #2563eb);
  color: var(--br-color-brand-accent, #2563eb);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.research-share-btn--embed:hover {
  background: var(--br-color-brand-accent, #2563eb);
  color: #ffffff;
  border-color: var(--br-color-brand-accent, #2563eb);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.research-share-btn--embed:focus-visible {
  outline: 2px solid var(--br-color-brand-accent, #2563eb);
  outline-offset: 2px;
}

.research-share-btn--embed i,
.research-share-btn--embed svg {
  flex-shrink: 0;
}

/* Modal Backdrop */
.br-embed-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  box-sizing: border-box;
}

.br-embed-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

/* Modal Dialog Card */
.br-embed-dialog {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
  width: 95vw;
  max-width: 1120px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  animation: brModalSlideUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes brModalSlideUp {
  from {
    transform: translateY(14px) scale(0.985);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* Modal Header */
.br-embed-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  flex-shrink: 0;
  box-sizing: border-box;
}

.br-embed-header-content {
  flex: 1;
  min-width: 0;
}

.br-embed-eyebrow {
  font-size: 0.6875rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #2563eb;
  margin-bottom: 4px;
}

.br-embed-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 4px 0;
  letter-spacing: -0.02em;
}

.br-embed-desc {
  font-size: 0.875rem;
  color: #475569;
  margin: 0;
  line-height: 1.45;
}

.br-embed-close-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #64748b;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.br-embed-close-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.br-embed-close-btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* Modal Body Layout */
.br-embed-body {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 24px;
  padding: 24px;
  overflow-y: auto;
  overflow-x: hidden; /* Strict: Never allow horizontal scrolling on the modal container */
  max-height: calc(100vh - 150px);
  min-width: 0;
  box-sizing: border-box;
}

/* Controls & Code Column */
.br-embed-config-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.br-embed-controls-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.br-embed-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.br-embed-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
}

.br-embed-select {
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.8125rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.br-embed-select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* Code Snippet Box */
.br-embed-snippet-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.br-embed-snippet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

/* Floating copy button inside top-right of code block */
.br-embed-copy-floating-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  background: rgba(51, 65, 85, 0.9);
  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 6px;
  padding: 5px 11px;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.br-embed-copy-floating-btn:hover {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.br-embed-copy-floating-btn.copied {
  background: #059669;
  border-color: #059669;
  color: #ffffff;
}

/* Main primary copy button below code block */
.br-embed-copy-btn-main {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  background: var(--br-color-brand-accent, #2563eb);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
  box-sizing: border-box;
}

.br-embed-copy-btn-main:hover {
  background: #1d4ed8;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.br-embed-copy-btn-main:active {
  transform: scale(0.99);
}

.br-embed-copy-btn-main.copied {
  background: #059669;
  box-shadow: 0 2px 4px rgba(5, 150, 105, 0.2);
}

.br-embed-code-wrapper {
  position: relative;
  background: #0f172a;
  border-radius: 8px;
  padding: 14px 14px 14px 14px;
  padding-top: 40px; /* Leave space for floating copy button */
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid #1e293b;
  max-height: 200px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.br-embed-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.5;
  color: #f8fafc;
  white-space: pre;
  display: block;
}

/* Documentation Footnote Link */
.br-embed-footer-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #2563eb;
  text-decoration: none;
  margin-top: 4px;
}

.br-embed-footer-link:hover {
  text-decoration: underline;
}

/* Live Preview Column */
.br-embed-preview-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.br-embed-preview-card {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 440px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  transition: background 0.2s ease;
}

.br-embed-preview-card.dark-theme {
  background: #090d16;
  border-color: #334155;
}

.br-embed-preview-frame-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  transition: max-width 0.2s ease;
}

.br-embed-preview-frame-wrap.compact-mode {
  max-width: 360px;
}

.br-embed-preview-frame {
  width: 100%;
  height: 440px;
  border: none;
  border-radius: 12px;
  overflow: hidden;
  display: block;
  background: #ffffff;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  transition: height 0.15s ease;
  min-width: 0;
}

.br-embed-preview-card.dark-theme .br-embed-preview-frame {
  background: #0b111e;
}

.br-embed-preview-attribution {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 11px;
  color: #64748b;
  margin: 6px 0 0 0;
  text-align: right;
  min-width: 0;
}

.br-embed-preview-attribution a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
}

.br-embed-preview-attribution a:hover {
  text-decoration: underline;
}

/* Responsive Breakpoints */
@media (max-width: 960px) {
  .br-embed-body {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 18px;
    max-height: calc(100vh - 120px);
  }

  .br-embed-preview-card {
    min-height: auto;
  }
}

@media (max-width: 580px) {
  .br-embed-controls-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .br-embed-header {
    padding: 14px 18px;
  }

  .br-embed-body {
    padding: 14px;
  }
}
