/* MOCBT AI message typography — shared across all AI surfaces */

.ai-message,
.moc-ai-msg--assistant .ai-message,
.moc-ai-msg--assistant > .ai-message,
.moc-assistant-msg--assistant .ai-message,
.moc-assistant-msg--assistant > .ai-message,
.moc-ai-insight-text .ai-message,
#mocAdminAiBody .ai-message,
#mocTicketAiOut .ai-message,
#mocAiCourseOut .ai-message,
#mocStudentAiBody .ai-message {
  font-size: .9rem;
  line-height: 1.6;
  color: #1e293b;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: normal;
  max-width: 100%;
}

.ai-message > *:first-child { margin-top: 0; }
.ai-message > *:last-child { margin-bottom: 0; }

.ai-message p { margin: 0 0 .65rem; }
.ai-message h1 { font-size: 1.05rem; font-weight: 700; margin: .85rem 0 .45rem; color: #0b1f3a; }
.ai-message h2 { font-size: .98rem; font-weight: 700; margin: .8rem 0 .4rem; color: #0b1f3a; }
.ai-message h3 { font-size: .92rem; font-weight: 700; margin: .75rem 0 .35rem; color: #132d52; }
.ai-message h4,
.ai-message h5,
.ai-message h6 { font-size: .88rem; font-weight: 700; margin: .65rem 0 .3rem; color: #334155; }

.ai-message ul.ai-list,
.ai-message ol.ai-list {
  margin: 0 0 .75rem;
  padding-left: 1.25rem;
}

.ai-message li { margin-bottom: .35rem; }
.ai-message li:last-child { margin-bottom: 0; }

.ai-message strong { font-weight: 700; color: #0b1f3a; }
.ai-message em { font-style: italic; }
.ai-message del { opacity: .75; }

.ai-message a {
  color: #0284c7;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}

.ai-message .ai-hr,
.ai-message hr {
  border: 0;
  border-top: 1px solid #e2e8f0;
  margin: .75rem 0;
}

.ai-message .ai-quote,
.ai-message blockquote {
  margin: .65rem 0;
  padding: .55rem .75rem;
  border-left: 3px solid #0ea5e9;
  background: #f8fafc;
  border-radius: 0 8px 8px 0;
  color: #475569;
}

.ai-message .ai-inline-code,
.ai-message code.ai-inline-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82em;
  background: #f1f5f9;
  padding: .1rem .35rem;
  border-radius: 4px;
  color: #0f172a;
}

.ai-message .ai-code-block {
  margin: .65rem 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  background: #0f172a;
  max-width: 100%;
}

.ai-message .ai-code-block pre {
  margin: 0;
  padding: .75rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ai-message .ai-code-block code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem;
  color: #e2e8f0;
  white-space: pre;
}

/* ── Tables ── */
.ai-table-block {
  margin: .75rem 0;
  max-width: 100%;
}

.ai-table-wrapper {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #fff;
}

.ai-message table.ai-table {
  display: table;
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: .84rem;
  table-layout: auto;
  margin: 0;
}

.ai-message table.ai-table thead {
  display: table-header-group;
}

.ai-message table.ai-table tbody {
  display: table-row-group;
}

.ai-message table.ai-table tr {
  display: table-row;
}

.ai-message table.ai-table th,
.ai-message table.ai-table td {
  display: table-cell;
  padding: .6rem .75rem;
  border-bottom: 1px solid #e8edf3;
  border-right: 1px solid #eef2f7;
  text-align: left;
  vertical-align: top;
  min-width: 9rem;
  max-width: 22rem;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
  line-height: 1.5;
}

.ai-message table.ai-table th:last-child,
.ai-message table.ai-table td:last-child {
  border-right: 0;
}

.ai-message table.ai-table th {
  background: #f1f5f9;
  font-weight: 700;
  color: #1e3a5f;
  white-space: normal;
  position: sticky;
  top: 0;
  z-index: 1;
}

.ai-message table.ai-table tr:last-child td {
  border-bottom: 0;
}

.ai-message table.ai-table tbody tr:nth-child(even) td {
  background: #fafbfc;
}

/* Mobile card fallback for wide tables */
.ai-table-cards {
  display: none;
}

.ai-table-card {
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #fff;
  padding: .75rem .85rem;
  margin-bottom: .65rem;
}

.ai-table-card:last-child {
  margin-bottom: 0;
}

.ai-table-card-title {
  font-size: .9rem;
  font-weight: 700;
  color: #0b1f3a;
  margin: 0 0 .5rem;
}

.ai-table-card-dl {
  margin: 0;
}

.ai-table-card-dl dt {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #64748b;
  margin: .45rem 0 .15rem;
}

.ai-table-card-dl dd {
  margin: 0 0 .35rem;
  font-size: .84rem;
  color: #1e293b;
  line-height: 1.5;
}

/* Message containers */
.moc-ai-msg--assistant,
.moc-assistant-msg--assistant,
.moc-ai-messages,
.moc-assistant-messages,
#mocAdminAiBody,
#mocTicketAiOut,
#mocAiCourseOut {
  overflow-x: hidden;
  max-width: 100%;
  min-width: 0;
}

.moc-ai-msg--assistant .ai-table-block,
.moc-assistant-msg--assistant .ai-table-block {
  max-width: 100%;
}

@media (max-width: 640px) {
  .ai-message { font-size: .86rem; }

  .ai-table-block--wide .ai-table-wrapper {
    display: none;
  }

  .ai-table-block--wide .ai-table-cards {
    display: block;
  }

  .ai-message table.ai-table th,
  .ai-message table.ai-table td {
    min-width: 7.5rem;
    padding: .5rem .6rem;
    font-size: .8rem;
  }
}

@media (max-width: 575.98px) {
  .ai-message table.ai-table {
    font-size: .78rem;
  }
}
