/**
 * Rich Agent Rendering - CSS Styles
 * Styles for interactive HTML forms, external link modals,
 * agent content badges, and expand/collapse UI.
 * 
 * Design: Matches existing glassmorphism dark theme with
 * emerald/cyan/amber accent colors.
 */

/* ============================================================================
   Rich Content Wrapper
   ============================================================================ */

.rich-content-wrapper {
  position: relative;
  margin: 0.5rem 0;
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.rich-content-wrapper:hover {
  border-color: rgba(6, 182, 212, 0.4);
}

/* ============================================================================
   Agent Content Badge
   ============================================================================ */

.rich-content-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  margin: 0.625rem 0.75rem 0;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.025em;
  color: rgb(147, 197, 253);
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 9999px;
  user-select: none;
}

.rich-content-badge svg {
  width: 0.875rem;
  height: 0.875rem;
  opacity: 0.8;
}

/* ============================================================================
   Rich Content Header
   ============================================================================ */

.rich-content-header {
  padding: 0.625rem 0.75rem 0;
}

.rich-content-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.rich-content-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: rgb(226, 232, 240);
  line-height: 1.4;
}

.rich-content-description {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: rgb(148, 163, 184);
  line-height: 1.5;
}

/* ============================================================================
   Expand/Collapse Toggle
   ============================================================================ */

.rich-content-toggle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 0.375rem;
  background: rgba(148, 163, 184, 0.08);
  color: rgb(148, 163, 184);
  cursor: pointer;
  transition: all 0.15s ease;
}

.rich-content-toggle:hover {
  background: rgba(148, 163, 184, 0.15);
  color: rgb(226, 232, 240);
  border-color: rgba(148, 163, 184, 0.3);
}

.rich-toggle-icon {
  width: 1rem;
  height: 1rem;
  transition: transform 0.2s ease;
}

.rich-toggle-icon.rich-toggle-collapsed {
  transform: rotate(180deg);
}

/* ============================================================================
   Rich Content Body
   ============================================================================ */

.rich-content-body {
  padding: 0.75rem;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.3s ease;
  max-height: 2000px;
  opacity: 1;
}

.rich-content-body.rich-content-collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

/* ============================================================================
   Rich Content Popup Viewer
   ============================================================================ */

body.rich-popup-open {
  overflow: hidden;
}

.rich-content-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 240;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(4px);
}

.rich-content-popup-panel {
  width: min(1300px, calc(100vw - 2.5rem));
  height: min(900px, calc(100vh - 2.5rem));
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 1rem;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.98);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.55);
}

.rich-content-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(15, 23, 42, 0.8);
}

.rich-content-popup-title-wrap {
  min-width: 0;
}

.rich-content-popup-kicker {
  display: block;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgb(56, 189, 248);
}

.rich-content-popup-title {
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: rgb(226, 232, 240);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rich-content-popup-close-btn {
  flex-shrink: 0;
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: rgb(226, 232, 240);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 0.45rem;
  background: rgba(51, 65, 85, 0.65);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.rich-content-popup-close-btn:hover {
  background: rgba(71, 85, 105, 0.85);
  border-color: rgba(148, 163, 184, 0.45);
}

.rich-content-popup-body {
  flex: 1;
  overflow: auto;
  padding: 1rem;
}

/* Preserve rich message layout while allowing full-window scrolling in popup */
.rich-content-popup-body .rich-content-wrapper {
  margin-top: 0;
}

/* ============================================================================
   Form Element Styles (within rich content)
   ============================================================================ */

.rich-content-body form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.rich-content-body fieldset {
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 0.5rem;
  padding: 0.75rem;
  margin: 0;
}

.rich-content-body legend {
  font-size: 0.8125rem;
  font-weight: 600;
  color: rgb(203, 213, 225);
  padding: 0 0.375rem;
}

.rich-content-body label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgb(203, 213, 225);
  margin-bottom: 0.25rem;
}

.rich-content-body input[type="text"],
.rich-content-body input[type="email"],
.rich-content-body input[type="url"],
.rich-content-body input[type="tel"],
.rich-content-body input[type="number"],
.rich-content-body input[type="password"],
.rich-content-body input[type="search"],
.rich-content-body input[type="date"],
.rich-content-body input[type="time"],
.rich-content-body input[type="datetime-local"],
.rich-content-body textarea,
.rich-content-body select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: rgb(226, 232, 240);
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 0.5rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.rich-content-body input[type="text"]:focus,
.rich-content-body input[type="email"]:focus,
.rich-content-body input[type="url"]:focus,
.rich-content-body input[type="tel"]:focus,
.rich-content-body input[type="number"]:focus,
.rich-content-body input[type="password"]:focus,
.rich-content-body input[type="search"]:focus,
.rich-content-body input[type="date"]:focus,
.rich-content-body input[type="time"]:focus,
.rich-content-body input[type="datetime-local"]:focus,
.rich-content-body textarea:focus,
.rich-content-body select:focus {
  border-color: rgba(6, 182, 212, 0.5);
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.15);
}

.rich-content-body input::placeholder,
.rich-content-body textarea::placeholder {
  color: rgba(148, 163, 184, 0.5);
}

.rich-content-body textarea {
  resize: vertical;
  min-height: 4rem;
}

.rich-content-body select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1rem;
  padding-right: 2rem;
}

.rich-content-body select option {
  background: rgb(30, 41, 59);
  color: rgb(226, 232, 240);
}

/* Checkbox and radio */
.rich-content-body input[type="checkbox"],
.rich-content-body input[type="radio"] {
  width: 1rem;
  height: 1rem;
  margin-right: 0.5rem;
  accent-color: rgb(6, 182, 212);
  cursor: pointer;
  vertical-align: middle;
}

/* Range input */
.rich-content-body input[type="range"] {
  width: 100%;
  accent-color: rgb(6, 182, 212);
  cursor: pointer;
}

/* Color input */
.rich-content-body input[type="color"] {
  width: 3rem;
  height: 2rem;
  padding: 0.125rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 0.375rem;
  background: rgba(30, 41, 59, 0.8);
  cursor: pointer;
}

/* File input */
.rich-content-body input[type="file"] {
  font-size: 0.8125rem;
  color: rgb(148, 163, 184);
}

/* Buttons */
.rich-content-body button[type="submit"],
.rich-content-body input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: rgb(15, 23, 42);
  background: rgb(6, 182, 212);
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.rich-content-body button[type="submit"]:hover,
.rich-content-body input[type="submit"]:hover {
  background: rgb(34, 211, 238);
  box-shadow: 0 4px 16px rgba(6, 182, 212, 0.4);
}

.rich-content-body button[type="submit"]:active,
.rich-content-body input[type="submit"]:active {
  transform: scale(0.98);
}

.rich-content-body button[type="submit"]:disabled,
.rich-content-body input[type="submit"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.rich-content-body button[type="reset"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgb(148, 163, 184);
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.rich-content-body button[type="reset"]:hover {
  color: rgb(226, 232, 240);
  border-color: rgba(148, 163, 184, 0.4);
  background: rgba(148, 163, 184, 0.08);
}

/* Generic button (not submit/reset) */
.rich-content-body button:not([type]),
.rich-content-body button[type="button"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgb(203, 213, 225);
  background: rgba(51, 65, 85, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.rich-content-body button:not([type]):hover,
.rich-content-body button[type="button"]:hover {
  background: rgba(51, 65, 85, 0.8);
  border-color: rgba(148, 163, 184, 0.3);
}

/* Submitted form state */
.rich-form-submitted {
  background: rgb(16, 185, 129) !important;
  color: white !important;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3) !important;
}

.rich-form-disabled {
  opacity: 0.6;
  pointer-events: none;
}

.rich-form-disabled input,
.rich-form-disabled textarea,
.rich-form-disabled select {
  background: rgba(30, 41, 59, 0.4) !important;
}

/* Progress and meter */
.rich-content-body progress {
  width: 100%;
  height: 0.5rem;
  border-radius: 9999px;
  overflow: hidden;
  appearance: none;
}

.rich-content-body progress::-webkit-progress-bar {
  background: rgba(30, 41, 59, 0.8);
  border-radius: 9999px;
}

.rich-content-body progress::-webkit-progress-value {
  background: linear-gradient(90deg, rgb(6, 182, 212), rgb(59, 130, 246));
  border-radius: 9999px;
}

.rich-content-body meter {
  width: 100%;
  height: 0.5rem;
}

/* ============================================================================
   Tables within Rich Content
   ============================================================================ */

.rich-content-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.rich-content-body th,
.rich-content-body td {
  padding: 0.5rem 0.625rem;
  border: 1px solid rgba(148, 163, 184, 0.15);
  text-align: left;
}

.rich-content-body th {
  font-weight: 600;
  color: rgb(203, 213, 225);
  background: rgba(30, 41, 59, 0.6);
}

.rich-content-body td {
  color: rgb(148, 163, 184);
}

/* ============================================================================
   Typography within Rich Content
   ============================================================================ */

.rich-content-body h1,
.rich-content-body h2,
.rich-content-body h3,
.rich-content-body h4,
.rich-content-body h5,
.rich-content-body h6 {
  color: rgb(226, 232, 240);
  margin: 0.5rem 0 0.25rem;
  line-height: 1.4;
}

.rich-content-body h1 { font-size: 1.25rem; }
.rich-content-body h2 { font-size: 1.125rem; }
.rich-content-body h3 { font-size: 1rem; }
.rich-content-body h4 { font-size: 0.9375rem; }
.rich-content-body h5 { font-size: 0.875rem; }
.rich-content-body h6 { font-size: 0.8125rem; }

.rich-content-body p {
  margin: 0.375rem 0;
  color: rgb(203, 213, 225);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.rich-content-body a {
  color: rgb(56, 189, 248);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s ease;
}

.rich-content-body a:hover {
  color: rgb(125, 211, 252);
}

.rich-content-body ul,
.rich-content-body ol {
  margin: 0.375rem 0;
  padding-left: 1.25rem;
  color: rgb(203, 213, 225);
  font-size: 0.8125rem;
}

.rich-content-body li {
  margin: 0.125rem 0;
}

.rich-content-body blockquote {
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid rgba(6, 182, 212, 0.4);
  background: rgba(6, 182, 212, 0.05);
  border-radius: 0 0.375rem 0.375rem 0;
  color: rgb(148, 163, 184);
  font-style: italic;
}

.rich-content-body code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.8125rem;
  padding: 0.125rem 0.375rem;
  background: rgba(30, 41, 59, 0.8);
  border-radius: 0.25rem;
  color: rgb(251, 191, 36);
}

.rich-content-body pre {
  margin: 0.5rem 0;
  padding: 0.75rem;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 0.5rem;
  overflow-x: auto;
}

.rich-content-body pre code {
  padding: 0;
  background: none;
  color: rgb(203, 213, 225);
}

.rich-content-body hr {
  border: none;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
  margin: 0.75rem 0;
}

.rich-content-body img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin: 0.375rem 0;
}

/* Details/Summary */
.rich-content-body details {
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin: 0.375rem 0;
}

.rich-content-body summary {
  cursor: pointer;
  font-weight: 500;
  color: rgb(203, 213, 225);
  font-size: 0.875rem;
  user-select: none;
}

.rich-content-body summary:hover {
  color: rgb(226, 232, 240);
}

/* ============================================================================
   External Link Confirmation Modal
   ============================================================================ */

.rich-link-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  animation: richModalFadeIn 0.15s ease;
}

@keyframes richModalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.rich-link-modal {
  width: 100%;
  max-width: 28rem;
  margin: 1rem;
  background: rgb(30, 41, 59);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 1rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: richModalSlideIn 0.2s ease;
}

@keyframes richModalSlideIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.rich-link-modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.08), rgba(245, 158, 11, 0.05));
}

.rich-link-modal-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: rgba(251, 191, 36, 0.15);
  color: rgb(251, 191, 36);
  flex-shrink: 0;
}

.rich-link-modal-body {
  padding: 1.25rem;
}

.rich-link-modal-warning {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: 0.5rem;
}

.rich-link-modal-url {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.625rem 0.75rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 0.5rem;
}

.rich-link-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(148, 163, 184, 0.1);
  background: rgba(30, 41, 59, 0.5);
}

.rich-link-cancel-btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: rgb(148, 163, 184);
  background: transparent;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: color 0.15s ease;
}

.rich-link-cancel-btn:hover {
  color: rgb(226, 232, 240);
}

.rich-link-proceed-btn {
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: rgb(15, 23, 42);
  background: rgb(251, 191, 36);
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.rich-link-proceed-btn:hover {
  background: rgb(252, 211, 77);
  box-shadow: 0 4px 16px rgba(251, 191, 36, 0.4);
}

/* ============================================================================
   Data-Action Interactive Elements
   ============================================================================ */

/* Hidden/Visible state classes used by data-toggle, data-show, data-hide */
.rich-content-body .rich-hidden {
  display: none !important;
}

.rich-content-body .rich-visible {
  display: revert !important;
}

/* Send-message buttons - distinct style to show they send a message */
.rich-content-body [data-send-message] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: rgb(15, 23, 42);
  background: linear-gradient(135deg, rgb(16, 185, 129), rgb(6, 182, 212));
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  position: relative;
}

.rich-content-body [data-send-message]:hover {
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.45);
  transform: translateY(-1px);
}

.rich-content-body [data-send-message]:active {
  transform: scale(0.98);
}

.rich-content-body [data-send-message]::after {
  content: '↗';
  font-size: 0.75rem;
  opacity: 0.7;
}

.rich-content-body [data-send-message].rich-action-sending {
  opacity: 0.7;
  cursor: wait;
}

.rich-content-body [data-send-message].rich-action-sent {
  background: rgb(16, 185, 129) !important;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3) !important;
  cursor: default;
}

.rich-content-body [data-send-message].rich-action-sent::after {
  display: none;
}

/* Toggle buttons */
.rich-content-body [data-toggle] {
  cursor: pointer;
}

/* Tab buttons */
.rich-content-body [data-tab] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgb(148, 163, 184);
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.rich-content-body [data-tab]:hover {
  color: rgb(226, 232, 240);
  background: rgba(148, 163, 184, 0.08);
}

.rich-content-body [data-tab].rich-tab-active {
  color: rgb(6, 182, 212);
  border-bottom-color: rgb(6, 182, 212);
  background: rgba(6, 182, 212, 0.08);
  font-weight: 600;
}

/* Tab bar container (agent can style, but defaults provided) */
.rich-content-body .tab-bar,
.rich-content-body .tabs,
.rich-content-body [role="tablist"] {
  display: flex;
  gap: 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  margin-bottom: 0.75rem;
  overflow-x: auto;
}

/* Tab panel */
.rich-content-body .tab-panel,
.rich-content-body [role="tabpanel"] {
  padding: 0.5rem 0;
}

/* Copy button feedback */
.rich-content-body [data-copy] {
  cursor: pointer;
}

.rich-content-body [data-copy].rich-action-copied {
  color: rgb(16, 185, 129) !important;
}

/* Dismiss button */
.rich-content-body [data-dismiss] {
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

.rich-content-body [data-dismiss]:hover {
  opacity: 1;
}

/* Card-like interactive sections */
.rich-content-body .card,
.rich-content-body .panel {
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 0.5rem;
  padding: 0.75rem;
  margin: 0.375rem 0;
  background: rgba(30, 41, 59, 0.4);
}

/* Button groups */
.rich-content-body .btn-group,
.rich-content-body .button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

/* Alert/notification boxes */
.rich-content-body .alert,
.rich-content-body .notice {
  padding: 0.75rem;
  border-radius: 0.5rem;
  margin: 0.375rem 0;
  font-size: 0.8125rem;
}

.rich-content-body .alert-info,
.rich-content-body .notice-info {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: rgb(147, 197, 253);
}

.rich-content-body .alert-success,
.rich-content-body .notice-success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: rgb(110, 231, 183);
}

.rich-content-body .alert-warning,
.rich-content-body .notice-warning {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.25);
  color: rgb(252, 211, 77);
}

.rich-content-body .alert-danger,
.rich-content-body .notice-danger,
.rich-content-body .alert-error,
.rich-content-body .notice-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: rgb(252, 165, 165);
}

/* Badge/tag helpers */
.rich-content-body .badge,
.rich-content-body .tag {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  border-radius: 9999px;
  background: rgba(148, 163, 184, 0.15);
  color: rgb(203, 213, 225);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

/* Grid layout helpers */
.rich-content-body .grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.rich-content-body .grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

/* Flex helpers */
.rich-content-body .flex-row {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
}

.rich-content-body .flex-col {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rich-content-body .flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.rich-content-body .flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Spacing helpers */
.rich-content-body .mt-1 { margin-top: 0.25rem; }
.rich-content-body .mt-2 { margin-top: 0.5rem; }
.rich-content-body .mt-3 { margin-top: 0.75rem; }
.rich-content-body .mt-4 { margin-top: 1rem; }
.rich-content-body .mb-1 { margin-bottom: 0.25rem; }
.rich-content-body .mb-2 { margin-bottom: 0.5rem; }
.rich-content-body .mb-3 { margin-bottom: 0.75rem; }
.rich-content-body .mb-4 { margin-bottom: 1rem; }
.rich-content-body .p-1 { padding: 0.25rem; }
.rich-content-body .p-2 { padding: 0.5rem; }
.rich-content-body .p-3 { padding: 0.75rem; }
.rich-content-body .p-4 { padding: 1rem; }

/* Text helpers */
.rich-content-body .text-center { text-align: center; }
.rich-content-body .text-right { text-align: right; }
.rich-content-body .text-sm { font-size: 0.8125rem; }
.rich-content-body .text-lg { font-size: 1.125rem; }
.rich-content-body .text-bold { font-weight: 700; }
.rich-content-body .text-muted { color: rgb(148, 163, 184); }
.rich-content-body .text-cyan { color: rgb(6, 182, 212); }
.rich-content-body .text-green { color: rgb(16, 185, 129); }
.rich-content-body .text-red { color: rgb(239, 68, 68); }
.rich-content-body .text-amber { color: rgb(251, 191, 36); }

/* Scoped agent CSS: agent <style> tags are scoped under .rich-content-body
   so agent CSS rules automatically apply only within the content area */

/* ============================================================================
   Responsive Design
   ============================================================================ */

@media (max-width: 640px) {
  .rich-content-wrapper {
    border-radius: 0.5rem;
  }

  .rich-content-body {
    padding: 0.5rem;
  }

  .rich-content-body input[type="text"],
  .rich-content-body input[type="email"],
  .rich-content-body input[type="url"],
  .rich-content-body input[type="tel"],
  .rich-content-body input[type="number"],
  .rich-content-body input[type="password"],
  .rich-content-body input[type="search"],
  .rich-content-body input[type="date"],
  .rich-content-body input[type="time"],
  .rich-content-body input[type="datetime-local"],
  .rich-content-body textarea,
  .rich-content-body select {
    font-size: 1rem; /* Prevents zoom on iOS */
  }

  .rich-link-modal {
    max-width: none;
    margin: 0.5rem;
  }

  .rich-content-popup-overlay {
    padding: 0.5rem;
  }

  .rich-content-popup-panel {
    width: calc(100vw - 1rem);
    height: calc(100vh - 1rem);
    border-radius: 0.75rem;
  }

  .rich-content-popup-body {
    padding: 0.625rem;
  }
}
