/* OSAS administrator assistant. Scoped to the floating panel so it cannot
   affect the dashboard layout or the sign-in screen. */

.agent-root {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}

.agent-fab {
  position: absolute;
  right: 24px;
  bottom: 88px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 1px solid #542136;
  border-radius: 50%;
  background: #542136;
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .01em;
  box-shadow: 0 5px 16px rgba(35, 12, 24, .2);
  cursor: pointer;
  pointer-events: auto;
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}

.agent-fab:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow: 0 8px 20px rgba(35, 12, 24, .24);
}

.agent-fab:focus-visible {
  outline: 3px solid rgba(233, 185, 202, .9);
  outline-offset: 3px;
}

.agent-fab i { color: #F8D98B; font-size: 20px; line-height: 1; }

.agent-panel {
  position: absolute;
  right: 24px;
  bottom: 150px;
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 32px));
  height: min(590px, calc(100dvh - 190px));
  min-height: 360px;
  overflow: hidden;
  border: 1px solid #d9d0c7;
  border-radius: 14px;
  background: #fbfaf8;
  box-shadow: 0 16px 42px rgba(35, 12, 24, .22);
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px) scale(.985);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
}

.agent-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
}

.agent-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 13px 13px 15px;
  background: #542136;
  color: #fff;
}

.agent-header-logo {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  object-fit: contain;
}

.agent-header-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  line-height: 1.25;
}

.agent-header-text strong {
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: .01em;
}

.agent-icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: rgba(255, 255, 255, .72);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.agent-icon-btn:hover {
  background: rgba(255, 255, 255, .12);
  color: #fff;
}

.agent-icon-btn:focus-visible {
  outline: 2px solid #F8D98B;
  outline-offset: 1px;
}

.agent-messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 14px 18px;
  background: #f7f5f1;
  scrollbar-width: thin;
  scrollbar-color: rgba(122, 27, 56, .28) transparent;
}

.agent-messages::-webkit-scrollbar { width: 6px; }
.agent-messages::-webkit-scrollbar-thumb { background: rgba(122, 27, 56, .24); border-radius: 999px; }

.agent-welcome {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 18px 4px 12px;
  text-align: left;
}

.agent-welcome-kicker {
  margin: 0 0 6px !important;
  color: #765b67 !important;
  font-size: 10px !important;
  font-weight: 700;
  letter-spacing: .09em;
}

.agent-welcome h3 {
  margin: 0;
  color: #30282c;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.agent-welcome p {
  max-width: 310px;
  margin: 7px 0 0;
  color: #6B5B62;
  font-size: 12px;
  line-height: 1.6;
}

.agent-suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 6px;
  margin-top: 12px;
}

.agent-chip {
  max-width: 100%;
  padding: 7px 9px;
  border: 1px solid #d9d0c7;
  border-radius: 6px;
  background: transparent;
  color: #513644;
  font-family: inherit;
  font-size: 11.5px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.agent-chip:hover {
  border-color: #805367;
  background: #fff;
  color: #542136;
}

.agent-row {
  display: flex;
  margin: 0 0 9px;
}

.agent-row.is-user { justify-content: flex-end; }

.agent-bubble {
  max-width: 86%;
  padding: 9px 11px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.agent-bubble.is-assistant {
  border: 1px solid #e6dde1;
  border-bottom-left-radius: 5px;
  border-radius: 15px 15px 15px 5px;
  background: #fff;
  color: #332B2F;
  box-shadow: 0 2px 9px rgba(58, 16, 36, .055);
  padding: 14px 15px 15px;
}

.agent-bubble.is-user {
  border: 1px solid #542136;
  border-bottom-right-radius: 3px;
  background: #542136;
  color: #fff;
  box-shadow: none;
}

.agent-bubble.is-error {
  border-color: #F3C7C7;
  background: #FFF6F6;
  color: #8F1D1D;
}

.agent-bubble-text { white-space: pre-wrap; }
.agent-bubble.is-assistant { max-width: 100%; min-width: 0; }
.agent-record-fields {
  margin: 12px 0;
  border: 1px solid #eee4e8;
  border-radius: 11px;
  overflow: hidden;
  background: #fcfafb;
}
.agent-record-field {
  display: grid;
  grid-template-columns: minmax(76px, 108px) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 9px 11px;
}
.agent-record-field + .agent-record-field { border-top: 1px solid #eee8eb; }
.agent-record-field dt {
  color: #775e6a;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
}
.agent-record-field dd {
  min-width: 0;
  margin: 0;
  color: #30262c;
  font-size: 12.5px;
  font-weight: 500;
  overflow-wrap: anywhere;
  line-height: 1.5;
}
.agent-rich-text .agent-section-heading {
  margin: 14px 0 7px;
  padding-left: 9px;
  border-left: 2px solid #b87892;
  color: #552b3d;
  font-size: 13px;
  font-weight: 760;
}
.agent-rich-text > :first-child.agent-section-heading { margin-top: 0; }
.agent-rich-text {
  white-space: normal;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.7;
  letter-spacing: .002em;
}
.agent-rich-text > * { margin: 0 0 10px; }
.agent-rich-text > :last-child { margin-bottom: 0; }
.agent-rich-text h1,
.agent-rich-text h2,
.agent-rich-text h3,
.agent-rich-text h4 {
  font-size: 14px;
  line-height: 1.4;
  font-weight: 750;
  color: #3e2030;
  margin: 14px 0 7px;
}
.agent-rich-text > :first-child:is(h1,h2,h3,h4) { margin-top: 0; }
.agent-rich-text h1 { font-size: 17px; }
.agent-rich-text h2 { font-size: 15px; }
.agent-rich-text p { margin: 0 0 10px; }
.agent-rich-text strong { font-weight: 750; color: #2d2028; }
.agent-rich-text em { font-style: italic; }
.agent-rich-text ol,
.agent-rich-text ul { padding-left: 24px; margin: 6px 0 13px; }
.agent-rich-text ol { list-style-type: decimal; }
.agent-rich-text ul { list-style-type: disc; }
.agent-rich-text li { padding-left: 2px; margin-bottom: 8px; }
.agent-rich-text li:last-child { margin-bottom: 0; }
.agent-rich-text li::marker { color: #87516b; font-weight: 700; }
.agent-rich-text code {
  display: inline;
  padding: 2px 5px;
  border-radius: 5px;
  background: #f3ecee;
  color: #672e4d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  overflow-wrap: anywhere;
}
.agent-rich-text pre {
  overflow-x: auto;
  max-width: 100%;
  margin: 9px 0 12px;
  padding: 12px;
  border: 1px solid #e7dce0;
  border-radius: 8px;
  background: #f7f3f4;
  line-height: 1.45;
  white-space: pre;
}
.agent-rich-text pre code {
  display: block;
  padding: 0;
  background: none;
  color: #433640;
  font-size: 12px;
  white-space: pre;
}
.agent-rich-text blockquote {
  border-left: 3px solid #a9778f;
  padding: 6px 10px;
  color: #5c4a55;
  background: #faf6f8;
  border-radius: 0 6px 6px 0;
}
.agent-rich-text hr { border: 0; border-top: 1px solid #e6dce0; margin: 12px 0; }
.agent-rich-text a {
  color: #753353;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.agent-table-scroll {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 10px 0;
}
.agent-table-scroll table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.agent-table-scroll th,
.agent-table-scroll td {
  padding: 7px 9px;
  text-align: left;
  vertical-align: top;
  border: 1px solid #e7dade;
}
.agent-table-scroll th {
  background: #f7f1f4;
  font-weight: 750;
  color: #50293d;
}


.agent-typing-row { margin-bottom: 4px; }

.agent-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 46px;
  padding: 12px 13px;
}

.agent-typing span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #B49AA5;
  animation: agent-dot 1.05s infinite ease-in-out;
}

.agent-typing span:nth-child(2) { animation-delay: .16s; }
.agent-typing span:nth-child(3) { animation-delay: .32s; }

@keyframes agent-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.agent-command-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 5px);
  left: 11px;
  right: 11px;
  max-height: min(280px, 42dvh);
  overflow-y: auto;
  z-index: 4;
  padding: 5px;
  border: 1px solid #dbd1ce;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(35, 12, 24, .16);
}

.agent-command-menu.is-visible { display: block; }

.agent-command-item {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px 11px;
  width: 100%;
  border: 0;
  border-radius: 7px;
  padding: 9px 11px;
  background: transparent;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}

.agent-command-item:hover,
.agent-command-item.is-selected {
  background: #f6eef1;
}

.agent-command-item:focus-visible {
  outline: 2px solid #75435b;
  outline-offset: -2px;
}

.agent-command-name {
  color: #542136;
  font-weight: 700;
  font-size: 12px;
}

.agent-command-description {
  color: #6b5b62;
  font-size: 11px;
}

.agent-page-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding: 6px 9px;
  border: 1px solid #d9c3cd;
  border-radius: 6px;
  color: #542136;
  background: #fcf7f9;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.agent-page-link:hover,
.agent-page-link:focus-visible {
  border-color: #542136;
  background: #f5eaf0;
}

.agent-composer {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 11px 7px;
  border-top: 1px solid #e2dcd4;
  background: #fbfaf8;
}

.agent-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid #E4DACE;
  border-radius: 8px;
  background: #fff;
  color: #332B2F;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  resize: none;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.agent-input::placeholder { color: #9B8C93; }

.agent-input:focus {
  border-color: rgba(122, 27, 56, .45);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(122, 27, 56, .09);
}

.agent-input:disabled { opacity: .65; }

.agent-send {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 13px;
  background: #542136;
  color: #fff;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease, opacity .15s ease;
}

.agent-send:hover:not(:disabled) { background: #3e1729; }
.agent-send:disabled { opacity: .45; cursor: wait; }
.agent-send:focus-visible { outline: 3px solid rgba(122, 27, 56, .25); outline-offset: 2px; }

.agent-footnote {
  margin: 0;
  padding: 0 14px 10px;
  background: #fbfaf8;
  color: #9A8B91;
  font-size: 10px;
  line-height: 1.45;
  text-align: center;
}

@media (max-width: 640px) {
  .agent-fab {
    right: 16px;
    bottom: 78px;
    padding: 12px;
    border-radius: 8px;
  }

  .agent-panel {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    min-height: 0;
    border-radius: 0;
    transform: translateY(10px) scale(.99);
    z-index: 75;
  }

  .agent-panel.is-open { transform: none; }
  .agent-messages { padding: 14px 12px 18px; }
  .agent-bubble { max-width: 90%; font-size: 13px; }
  .agent-bubble.is-assistant { max-width: 96%; padding: 13px 13px 14px; }
  .agent-record-field { grid-template-columns: minmax(70px, 90px) minmax(0, 1fr); gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .agent-fab,
  .agent-panel,
  .agent-chip,
  .agent-send,
  .agent-icon-btn {
    transition: none;
  }

  .agent-typing span { animation: none; opacity: .7; }
}

@media print {
  .agent-root { display: none !important; }
}

/* Conversation overlay, saved-session history, media composer */
.agent-panel.is-open {
  animation: agent-enter .26s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes agent-enter {
  0% { opacity: 0; transform: translateY(18px) scale(.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.agent-startup,
.agent-resume,
.agent-history { padding: 22px 8px; }
.agent-startup { min-height: 230px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px; color: #755c68; font-size: 13px; }
.agent-loader { width: 27px; height: 27px; display: inline-block; border: 3px solid #eddde4; border-top-color: #683048; border-radius: 50%; animation: agent-spin .55s linear infinite; }
@keyframes agent-spin { to { transform: rotate(360deg); } }
.agent-resume { display: flex; flex-direction: column; align-items: flex-start; gap: 13px; }
.agent-resume-mark { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid #ecdde4; border-radius: 13px; background: #fff; color: #783d57; }
.agent-resume h3, .agent-history h3 { font-size: 17px; font-weight: 750; color: #33202a; margin: 0; }
.agent-resume p { font-size: 12px; color: #7d6a73; line-height: 1.5; margin: 0; }
.agent-last-conversation { width: 100%; display: flex; flex-direction: column; gap: 6px; border: 1px solid #e8dce1; border-radius: 11px; background: #fff; padding: 13px 14px; overflow-wrap: anywhere; }
.agent-last-conversation strong { font-size: 13px; color: #3b2831; }
.agent-last-conversation span { font-size: 11px; color: #877783; }
.agent-session-actions { display: flex; flex-wrap: wrap; width: 100%; gap: 8px; }
.agent-primary-action, .agent-secondary-action { display: inline-flex; align-items: center; justify-content: center; gap: 5px; border-radius: 8px; padding: 10px 12px; border: 1px solid #542136; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.agent-primary-action { background: #542136; color: #fff; flex: 1 1 100%; }
.agent-secondary-action { background: #fff; color: #542136; flex: 1 1 auto; }
.agent-history { padding-top: 8px; }
.agent-history-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.agent-history-heading .agent-secondary-action { flex: none; padding: 7px 9px; }
.agent-history-list { display: grid; gap: 8px; }
.agent-history-item { display: flex; align-items: center; border: 1px solid #e8dce1; border-radius: 11px; background: #fff; overflow: hidden; }
.agent-history-open { display: grid; flex: 1; gap: 4px; min-width: 0; padding: 12px 13px; text-align: left; border: 0; background: transparent; color: inherit; cursor: pointer; }
.agent-history-open strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-history-open small, .agent-history-open span { font-size: 11px; color: #8b7781; }
.agent-history-delete { flex: none; width: 40px; height: 42px; border: 0; background: none; color: #987281; cursor: pointer; }
.agent-empty-history { font-size: 12px; line-height: 1.6; color: #7d6a73; }
.agent-history-skeletons { display: grid; gap: 15px; padding: 16px 5px; }
.agent-skeleton-bubble { width: 85%; display: grid; gap: 10px; padding: 15px 12px; background: white; border: 1px solid #f1e9ec; border-radius: 12px; }
.agent-skeleton-bubble.right { width: 62%; justify-self: end; }
.agent-skeleton-line { height: 11px; width: 65%; border-radius: 6px; background: linear-gradient(110deg, #ede7e8 12%, #f9f6f6 38%, #ede7e8 70%); background-size: 220% 100%; animation: agent-shimmer 1.2s ease-in-out infinite; }
.agent-skeleton-line.wide { width: 95%; }
.agent-skeleton-line.short { width: 40%; }
@keyframes agent-shimmer { to { background-position-x: -220%; } }
.agent-attachment-status[hidden] { display: none !important; }
.agent-attachment-status { display: flex; align-items: center; gap: 9px; flex: none; margin: 0 11px; padding: 8px 10px; border: 1px solid #ede0e5; border-radius: 8px; background: #fff; font-size: 11px; color: #5f4551; }
.agent-attachment-thumb { width: 38px; height: 38px; border-radius: 6px; object-fit: cover; }
.agent-attachment-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-remove-attachment { color: #542136; }
.agent-image-btn { flex: none; display: grid; place-items: center; height: 40px; width: 35px; border: 0; background: transparent; color: #71435a; cursor: pointer; }
.agent-sent-image { display: block; margin: 8px 0 0; max-width: 100%; max-height: 160px; border-radius: 9px; object-fit: contain; }
.agent-saved-image-note { display: block; font-size: 10px; opacity: .8; margin-top: 7px; }
.agent-history-delete:hover, .agent-image-btn:hover { color: #391522; background: #f9eef3; }
@media (max-width: 640px) {
  .agent-panel.is-open { animation: agent-mobile-enter .22s ease-out both; }
  @keyframes agent-mobile-enter { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
  .agent-startup, .agent-resume, .agent-history { padding-left: 7px; padding-right: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  .agent-panel.is-open, .agent-loader, .agent-skeleton-line { animation: none; }
}

/* Session choice and history show before the message composer. */
.agent-panel[data-chat-screen="startup"] .agent-composer,
.agent-panel[data-chat-screen="startup"] .agent-footnote,
.agent-panel[data-chat-screen="resume"] .agent-composer,
.agent-panel[data-chat-screen="resume"] .agent-footnote,
.agent-panel[data-chat-screen="history"] .agent-composer,
.agent-panel[data-chat-screen="history"] .agent-footnote,
.agent-panel[data-chat-screen="loading"] .agent-composer,
.agent-panel[data-chat-screen="loading"] .agent-footnote { display: none; }
