/* MORA AI cho MORA Platform — khung chat nhúng. Token brand.mora.vn: xanh #0077B2, navy #0B1220, chữ Plus Jakarta Sans.
   Mọi lớp mang tiền tố .mai- để không đè CSS của trang chủ. Đo 320/375/768/1280/1440 trước khi phát hành. */
@font-face { font-family: "MAI Jakarta"; font-weight: 400 800; font-display: swap; src: url("fonts/pjs-vietnamese.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: "MAI Jakarta"; font-weight: 400 800; font-display: swap; src: url("fonts/pjs-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212; }

.mai-root {
  --mai-blue: #0077B2; --mai-blue-h: #00669A; --mai-blue-soft: #E6F2F8; --mai-deep: #1E3A8A; --mai-sky: #38BDF8;
  --mai-navy: #0B1220; --mai-ink: #1F2328; --mai-ink2: #3B4252; --mai-mute: #5B6478; --mai-line: #E3E8EF;
  --mai-bg: #F6F8FC; --mai-surface: #FFFFFF; --mai-surface2: #F1F4F9;
  --mai-ok: #047857; --mai-ok-soft: #E3F4EC; --mai-warn: #B45309; --mai-warn-soft: #FDF1E1; --mai-err: #C8102E; --mai-err-soft: #FCE8EC;
  --mai-shadow: 0 1px 2px rgba(16,24,40,.06), 0 12px 40px rgba(16,24,40,.16);
  font: 15px/1.55 "MAI Jakarta", "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--mai-ink); -webkit-font-smoothing: antialiased;
}
@media (prefers-color-scheme: dark) {
  .mai-root:not([data-theme="light"]) {
    --mai-blue: #38A3D8; --mai-blue-h: #5BB6E3; --mai-blue-soft: #10283A; --mai-navy: #E6EDF5; --mai-ink: #E6EDF5; --mai-ink2: #C3CDD9;
    --mai-mute: #93A0B2; --mai-line: #273244; --mai-bg: #0E141F; --mai-surface: #151D2B; --mai-surface2: #1B2536;
    --mai-ok-soft: #0F2E25; --mai-warn-soft: #33240E; --mai-err-soft: #3A1520; --mai-ok: #34D399; --mai-warn: #F5A54A; --mai-err: #F87171;
  }
}
.mai-root[data-theme="dark"] {
  --mai-blue: #38A3D8; --mai-blue-h: #5BB6E3; --mai-blue-soft: #10283A; --mai-navy: #E6EDF5; --mai-ink: #E6EDF5; --mai-ink2: #C3CDD9;
  --mai-mute: #93A0B2; --mai-line: #273244; --mai-bg: #0E141F; --mai-surface: #151D2B; --mai-surface2: #1B2536;
  --mai-ok-soft: #0F2E25; --mai-warn-soft: #33240E; --mai-err-soft: #3A1520; --mai-ok: #34D399; --mai-warn: #F5A54A; --mai-err: #F87171;
}
.mai-root *, .mai-root *::before, .mai-root *::after { box-sizing: border-box; }
.mai-root button, .mai-root textarea { font: inherit; color: inherit; }
.mai-root [hidden] { display: none !important; }
.mai-root :focus-visible { outline: 3px solid rgba(0,119,178,.45); outline-offset: 2px; border-radius: 8px; }

/* nút nổi */
.mai-fab { position: fixed; right: 20px; bottom: 20px; z-index: 2147483000; display: inline-flex; align-items: center; gap: 8px;
  height: 48px; padding: 0 18px 0 14px; border: 0; border-radius: 24px; cursor: pointer; color: #fff; font-weight: 700;
  background: linear-gradient(135deg, var(--mai-sky), var(--mai-blue) 55%, var(--mai-deep)); box-shadow: var(--mai-shadow); }
.mai-fab svg { width: 22px; height: 22px; }
.mai-fab:hover { filter: brightness(1.06); }

/* ngăn chat */
.mai-panel { position: fixed; right: 20px; bottom: 20px; z-index: 2147483001; width: 420px; height: min(720px, calc(100vh - 40px));
  display: flex; flex-direction: column; background: var(--mai-bg); border: 1px solid var(--mai-line); border-radius: 16px;
  box-shadow: var(--mai-shadow); overflow: hidden; }
@media (max-width: 560px) { .mai-panel { right: 0; bottom: 0; width: 100vw; height: 100dvh; border-radius: 0; border: 0; } .mai-fab { right: 16px; bottom: 16px; } }
.mai-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; background: var(--mai-surface); border-bottom: 1px solid var(--mai-line); }
.mai-logo { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; flex: none;
  background: linear-gradient(135deg, var(--mai-sky), var(--mai-blue) 55%, var(--mai-deep)); }
.mai-logo svg { width: 18px; height: 18px; }
.mai-title { flex: 1; min-width: 0; }
.mai-title b { display: block; font-size: 15px; color: var(--mai-navy); }
.mai-title span { display: block; font-size: 12px; color: var(--mai-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mai-ib { width: 36px; height: 36px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 9px; cursor: pointer; color: var(--mai-ink2); flex: none; }
.mai-ib:hover { background: var(--mai-surface2); }
.mai-ib svg { width: 20px; height: 20px; }

.mai-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.mai-empty { margin: auto 0; text-align: center; color: var(--mai-mute); padding: 8px; }
.mai-empty h2 { font-size: 18px; color: var(--mai-navy); margin: 0 0 6px; }
.mai-hints { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.mai-hint { border: 1px solid var(--mai-line); background: var(--mai-surface); border-radius: 999px; padding: 6px 12px; font-size: 13.5px; cursor: pointer; color: var(--mai-ink2); text-align: left; }
.mai-hint:hover { border-color: var(--mai-blue); color: var(--mai-blue); }

.mai-msg { max-width: 92%; overflow-wrap: anywhere; }
.mai-msg.u { align-self: flex-end; background: var(--mai-blue); color: #fff; padding: 9px 13px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; }
.mai-msg.u .mai-at { color: #fff; background: rgba(255,255,255,.18); }
.mai-msg.a { align-self: flex-start; color: var(--mai-ink); }
.mai-msg.a p { margin: 0 0 8px; } .mai-msg.a p:last-child { margin-bottom: 0; }
.mai-msg.a ul, .mai-msg.a ol { margin: 4px 0 8px; padding-left: 20px; }
.mai-msg.a code { font: 13px ui-monospace, Consolas, monospace; background: var(--mai-surface2); padding: 1px 5px; border-radius: 5px; }
.mai-msg.note { align-self: stretch; font-size: 13.5px; color: var(--mai-warn); background: var(--mai-warn-soft); padding: 8px 12px; border-radius: 10px; }
.mai-msg.err { align-self: stretch; font-size: 13.5px; color: var(--mai-err); background: var(--mai-err-soft); padding: 8px 12px; border-radius: 10px; }
.mai-at { color: var(--mai-blue); background: var(--mai-blue-soft); border-radius: 6px; padding: 0 4px; font-weight: 600; }

.mai-act { align-self: flex-start; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--mai-mute); }
.mai-act .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mai-blue); flex: none; }
.mai-act.run .dot { animation: mai-pulse 1s infinite ease-in-out; }
.mai-act.ok .dot { background: var(--mai-ok); } .mai-act.bad .dot { background: var(--mai-err); } .mai-act.denied { color: var(--mai-err); }
.mai-act a { color: var(--mai-blue); font-weight: 600; }
@keyframes mai-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .mai-act.run .dot { animation: none; } }

/* thẻ xác nhận */
.mai-card { align-self: stretch; background: var(--mai-surface); border: 1px solid var(--mai-line); border-radius: 14px; padding: 14px; }
.mai-card.danger { border-color: rgba(200,16,46,.35); }
.mai-card h3 { margin: 0 0 10px; font-size: 15px; color: var(--mai-navy); display: flex; align-items: center; gap: 8px; }
.mai-card dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; font-size: 14px; }
.mai-card dt { color: var(--mai-mute); } .mai-card dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.mai-card .body { margin-top: 10px; font-size: 14px; white-space: pre-wrap; background: var(--mai-surface2); border-radius: 10px; padding: 8px 10px; max-height: 160px; overflow: auto; }
.mai-card .grant { margin-top: 10px; font-size: 12.5px; color: var(--mai-ok); background: var(--mai-ok-soft); border-radius: 8px; padding: 6px 10px; }
.mai-card .warn { margin-top: 8px; font-size: 13px; color: var(--mai-warn); background: var(--mai-warn-soft); border-radius: 8px; padding: 6px 10px; }
.mai-card ul.eff { margin: 10px 0 0; padding-left: 18px; font-size: 13px; color: var(--mai-ink2); }
.mai-card .btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.mai-btn { min-height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--mai-line); background: var(--mai-surface); cursor: pointer; font-weight: 600; font-size: 14px; }
.mai-btn:hover { background: var(--mai-surface2); }
.mai-btn.pri { background: var(--mai-blue); border-color: var(--mai-blue); color: #fff; }
.mai-btn.pri:hover { background: var(--mai-blue-h); }
.mai-btn.dan { background: var(--mai-err); border-color: var(--mai-err); color: #fff; }
.mai-btn[disabled] { opacity: .55; cursor: default; }
.mai-card .state { margin-top: 10px; font-size: 13px; font-weight: 600; }
.mai-card .state.ok { color: var(--mai-ok); } .mai-card .state.bad { color: var(--mai-err); } .mai-card .state.off { color: var(--mai-mute); }

/* ô nhập + @nhắc tên */
.mai-foot { position: relative; padding: 10px 12px 12px; background: var(--mai-surface); border-top: 1px solid var(--mai-line); }
.mai-box { display: flex; align-items: flex-end; gap: 8px; border: 1px solid var(--mai-line); border-radius: 12px; padding: 6px 6px 6px 12px; background: var(--mai-bg); }
.mai-box:focus-within { border-color: var(--mai-blue); }
.mai-in { flex: 1; min-width: 0; border: 0; outline: 0; resize: none; background: transparent; max-height: 140px; padding: 6px 0; line-height: 1.45; }
.mai-send { width: 38px; height: 38px; border: 0; border-radius: 10px; background: var(--mai-blue); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.mai-send[disabled] { opacity: .45; cursor: default; }
.mai-send svg { width: 18px; height: 18px; }
.mai-tip { margin-top: 6px; font-size: 11.5px; color: var(--mai-mute); text-align: center; }
.mai-pop { position: absolute; left: 12px; right: 12px; bottom: calc(100% - 4px); background: var(--mai-surface); border: 1px solid var(--mai-line); border-radius: 12px; box-shadow: var(--mai-shadow); max-height: 260px; overflow-y: auto; padding: 4px; }
.mai-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; text-align: left; }
.mai-opt[aria-selected="true"], .mai-opt:hover { background: var(--mai-blue-soft); }
.mai-av { width: 30px; height: 30px; border-radius: 50%; background: var(--mai-blue-soft); color: var(--mai-blue); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.mai-opt b { display: block; font-size: 14px; } .mai-opt span { display: block; font-size: 12px; color: var(--mai-mute); }
.mai-pop .none { padding: 10px; font-size: 13px; color: var(--mai-mute); }
