/* ============================================================
 * media-md.css — shared markdown + URL embed styling
 * Loaded by every chat surface (dashboard chat, /chat-ui,
 * /dashboard/support-chat) so embeds render identically.
 * ============================================================ */

/* Markdown rich-text */
.msg-body p,
.message p {
  margin: 0 0 8px;
}
.msg-body p:last-child,
.message p:last-child {
  margin-bottom: 0;
}
.msg-body ul, .msg-body ol,
.message ul, .message ol {
  margin: 6px 0 8px;
  padding-left: 22px;
}
.msg-body li,
.message li { margin: 2px 0; }
.msg-body h2, .msg-body h3, .msg-body h4,
.message h2, .message h3, .message h4 {
  margin: 10px 0 6px;
  line-height: 1.25;
}
.msg-body h2, .message h2 { font-size: 1.2rem; }
.msg-body h3, .message h3 { font-size: 1.08rem; }
.msg-body h4, .message h4 { font-size: 0.98rem; }
.msg-body hr, .message hr {
  margin: 10px 0;
  border: 0;
  border-top: 1px solid var(--border, rgba(255,255,255,0.12));
}
.msg-body code, .message code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(127, 127, 127, 0.18);
}
.msg-body pre, .message pre { margin: 0; }
.msg-body .code-block,
.message .code-block {
  margin: 8px 0;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-primary, #0d0d12);
}
.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-muted, rgba(255,255,255,0.55));
  background: rgba(127,127,127,0.08);
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.1));
}
.copy-code-btn {
  background: none;
  border: 1px solid var(--border, rgba(255,255,255,0.15));
  color: inherit;
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
}
.copy-code-btn:hover { background: rgba(127,127,127,0.14); }
.code-block pre {
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.5;
}
.code-block code { background: none; padding: 0; border-radius: 0; }

/* URL media embeds */
.media-embed {
  margin: 10px 0;
  max-width: 560px;
}
.media-embed:last-child { margin-bottom: 0; }

.embed-image {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  background: var(--bg-primary, #0d0d12);
  display: inline-block;
  max-width: 100%;
}
.embed-image a {
  border: none !important;
  display: block;
  line-height: 0;
}
.embed-image img {
  display: block;
  max-width: 100%;
  max-height: 420px;
  width: auto;
  height: auto;
  cursor: zoom-in;
}
.embed-broken {
  padding: 18px 20px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted, rgba(255,255,255,0.55));
}
.embed-broken::before {
  content: '⚠ Media failed to load';
  display: block;
}
.embed-caption {
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-muted, rgba(255,255,255,0.55));
  border-top: 1px solid var(--border, rgba(255,255,255,0.1));
  letter-spacing: 0.01em;
}

.embed-video, .embed-audio {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  background: var(--bg-primary, #0d0d12);
}
.embed-video video {
  display: block;
  width: 100%;
  max-height: 420px;
  background: #000;
}
.embed-audio audio {
  display: block;
  width: 100%;
  padding: 10px 12px;
}

.embed-youtube, .embed-vimeo {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  aspect-ratio: 16 / 9;
  background: #000;
  position: relative;
}
.embed-youtube iframe, .embed-vimeo iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.embed-pdf {
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-primary, #0d0d12);
}
.pdf-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.1));
}
.pdf-icon {
  width: 40px;
  height: 48px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border-radius: 6px;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.25);
}
.pdf-info { flex: 1; min-width: 0; }
.pdf-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #fff);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 2px;
}
.pdf-host {
  font-size: 11px;
  color: var(--text-muted, rgba(255,255,255,0.55));
}
.pdf-open {
  padding: 6px 12px;
  background: var(--accent, #8b5cf6);
  color: #fff !important;
  border: none !important;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  flex-shrink: 0;
}
.pdf-open:hover { background: var(--accent-hover, #7c3aed); }
.pdf-viewer {
  display: block;
  width: 100%;
  height: 420px;
  border: 0;
  background: #1a1a1f;
}

/* Rich-mode toggle button */
.rich-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.rich-toggle .rich-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34,197,94,0.18);
}
.rich-toggle.off .rich-dot {
  background: rgba(127,127,127,0.6);
  box-shadow: 0 0 0 2px rgba(127,127,127,0.15);
}

@media (max-width: 768px) {
  .media-embed { max-width: 100%; }
  .pdf-viewer { height: 320px; }
}
