/* R-Code AI assistant widget — brand purple #4D44C5. All rules are scoped to .rai */

.rai { --rai-primary: #4D44C5; --rai-primary-dark: #3F37A8; --rai-ink: #111; --rai-body: #3D4C5E; --rai-muted: #6B7280; --rai-border: #E7E6F0; --rai-soft: #F6F5FC; font-family: var(--ztc-family-font1, system-ui, sans-serif); }
.rai *, .rai *::before, .rai *::after { box-sizing: border-box; }
.rai .rai-sr { position: absolute !important; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Launcher — sits above the existing WhatsApp / scroll-to-top buttons */
.rai-launch {
  position: fixed; right: 24px; bottom: 24px; z-index: 9990;   /* js/float.js overrides right/bottom once the button is dragged */
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 18px 12px 14px;
  font-size: 15px; font-weight: 600; line-height: 1; color: #fff;
  background: var(--rai-primary); border: 0; border-radius: 999px; cursor: pointer;
  box-shadow: 0 10px 24px -8px rgba(77, 68, 197, 0.6);
  transition: background-color 0.2s ease, transform 0.2s ease;
}
.rai-launch:hover { background: var(--rai-primary-dark); transform: translateY(-1px); }
.rai-launch:focus-visible { outline: 3px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 6px var(--rai-primary); }
.rai-launch__icon { display: inline-flex; }
.rai.is-open .rai-launch { display: none; }
@media (max-width: 575px) {
  .rai-launch { right: 22px; bottom: 22px; padding: 14px; }
  .rai-launch__text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}

/* Panel */
.rai-panel {
  position: fixed; right: 24px; bottom: 24px; z-index: 9991;
  display: flex; flex-direction: column;
  width: 380px; height: min(620px, calc(100vh - 48px));
  background: #fff; border: 1px solid var(--rai-border); border-radius: 18px;
  box-shadow: 0 24px 60px -18px rgba(17, 17, 39, 0.35);
  overflow: hidden;
}
.rai-panel[hidden] { display: none; }
/* Phones: the chat opens over the whole screen (it slides up from the bottom) */
.rai-scrim { display: none; }
@media (max-width: 575px) {
  .rai-panel { right: 0; top: 0; bottom: 0 !important; left: 0; width: 100%; height: 100vh; height: 100dvh; max-height: none; border-radius: 0; border: 0; animation: rai-sheet-in .26s cubic-bezier(.22, .8, .25, 1); }
  .rai-scrim, .rai-scrim[hidden] { display: none; }   /* the chat covers the whole screen, so nothing is left to dim */
}
@keyframes rai-sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .rai-panel { animation: none !important; } }

/* Quick links under the header: Build, Client portal, Student portal */
.rai-quick { display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto; background: #fff; border-bottom: 1px solid var(--rai-border); scrollbar-width: none; }
.rai-quick::-webkit-scrollbar { display: none; }
.rai-quick a, .rai-quick button { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; padding: 6px 11px; font: inherit; font-size: 12.5px; font-weight: 600; line-height: 1.2; color: var(--rai-primary); text-decoration: none; white-space: nowrap; background: var(--rai-soft); border: 1px solid #E1DEF7; border-radius: 999px; cursor: pointer; }
.rai-quick a:hover, .rai-quick button:hover { background: #EFEDFC; }
.rai-quick a:focus-visible, .rai-quick button:focus-visible { outline: 2px solid var(--rai-primary); outline-offset: 1px; }
.rai-launch.is-dragging { cursor: grabbing; transform: scale(1.06); transition: none; }
.rai-launch { cursor: grab; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }

.rai-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 14px 14px 16px; color: #fff; background: var(--rai-primary); }
.rai-head__id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rai-avatar { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex: 0 0 36px; font-weight: 700; color: var(--rai-primary); background: #fff; border-radius: 50%; }
.rai-head h2 { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.2; color: #fff; }
.rai-head p { margin: 2px 0 0; font-size: 12.5px; line-height: 1.2; color: rgba(255, 255, 255, 0.82); }
.rai-badge { display: inline-block; margin-left: 4px; padding: 2px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; vertical-align: 2px; color: var(--rai-primary); background: #fff; border-radius: 4px; }
.rai-head__actions { display: flex; gap: 2px; }
.rai-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; color: #fff; background: transparent; border: 0; border-radius: 8px; cursor: pointer; }
.rai-icon-btn:hover { background: rgba(255, 255, 255, 0.14); }
.rai-icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* Messages */
.rai-log { flex: 1; overflow-y: auto; padding: 16px 14px 8px; background: var(--rai-soft); overscroll-behavior: contain; }
.rai-log:focus-visible { outline: 2px solid var(--rai-primary); outline-offset: -2px; }
.rai-msg { max-width: 88%; margin: 0 0 10px; padding: 10px 13px; font-size: 14.5px; line-height: 1.55; color: var(--rai-body); word-wrap: break-word; border-radius: 14px; }
.rai-msg p { margin: 0 0 6px; color: inherit; font-size: inherit; line-height: inherit; }
.rai-msg p:last-child { margin-bottom: 0; }
.rai-msg ul { margin: 4px 0 6px; padding-left: 18px; list-style: disc; }
.rai-msg li { margin: 2px 0; list-style: disc; }
.rai-msg a { color: var(--rai-primary); font-weight: 600; text-decoration: underline; }
.rai-msg--assistant { background: #fff; border: 1px solid var(--rai-border); border-bottom-left-radius: 4px; }
.rai-msg--user { margin-left: auto; color: #fff; background: var(--rai-primary); border-bottom-right-radius: 4px; }
.rai-msg--notice { background: #FFF8EB; border-color: #F5E1B8; }
.rai-msg--brief { max-width: 100%; }

.rai-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 10px; }
.rai-chip { padding: 7px 11px; font-size: 13px; font-weight: 500; color: var(--rai-primary); background: #fff; border: 1px solid #D9D6F5; border-radius: 999px; cursor: pointer; }
.rai-chip:hover { background: #EFEDFC; }
.rai-chip:focus-visible { outline: 2px solid var(--rai-primary); outline-offset: 1px; }

.rai-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.rai-links a { display: inline-block; padding: 7px 11px; font-size: 13px; font-weight: 600; text-decoration: none; color: var(--rai-primary); background: #fff; border: 1px solid #D9D6F5; border-radius: 8px; }
.rai-links a:hover { background: #EFEDFC; }
.rai-links a.rai-primary { color: #fff; background: var(--rai-primary); border-color: var(--rai-primary); }
.rai-links a.rai-primary:hover { background: var(--rai-primary-dark); }

.rai-brief { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 8px 0; font-size: 13.5px; }
.rai-brief dt { font-weight: 600; color: var(--rai-ink); }
.rai-brief dd { margin: 0; }
.rai-brief__missing { font-size: 13px; color: #8A5A00; }
.rai-brief__note { font-size: 12.5px; color: var(--rai-muted); }

.rai-typing { display: inline-flex; gap: 4px; align-items: center; padding: 12px 14px; }
.rai-typing span:not(.rai-sr) { width: 7px; height: 7px; background: #B9B5E6; border-radius: 50%; animation: rai-dot 1.2s infinite ease-in-out; }
.rai-typing span:nth-child(3) { animation-delay: 0.15s; }
.rai-typing span:nth-child(4) { animation-delay: 0.3s; }
@keyframes rai-dot { 0%, 80%, 100% { opacity: 0.35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .rai-typing span { animation: none !important; } .rai-launch { transition: none; } }

/* Brief action + composer */
.rai-brief-bar { padding: 8px 14px 0; background: var(--rai-soft); }
.rai-brief-bar[hidden] { display: none; }
.rai-brief-btn { width: 100%; padding: 9px 12px; font-size: 14px; font-weight: 600; color: var(--rai-primary); background: #fff; border: 1.5px dashed #BDB8EE; border-radius: 10px; cursor: pointer; }
.rai-brief-btn:hover { background: #EFEDFC; }
.rai-brief-btn:disabled { opacity: 0.6; cursor: progress; }

.rai-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; background: #fff; border-top: 1px solid var(--rai-border); }
.rai-form textarea {
  flex: 1; min-height: 42px; max-height: 120px; padding: 10px 12px; resize: none;
  font-family: inherit; font-size: 15px; line-height: 1.4; color: var(--rai-ink);
  background: #fff; border: 1.5px solid var(--rai-border); border-radius: 12px;
}
.rai-form textarea:focus { outline: none; border-color: var(--rai-primary); box-shadow: 0 0 0 3px rgba(77, 68, 197, 0.14); }
.rai-send { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; flex: 0 0 42px; color: #fff; background: var(--rai-primary); border: 0; border-radius: 12px; cursor: pointer; }
.rai-send:hover { background: var(--rai-primary-dark); }
.rai-send:disabled { opacity: 0.55; cursor: progress; }
.rai-send:focus-visible { outline: 2px solid var(--rai-primary); outline-offset: 2px; }
.rai-note { margin: 0; padding: 0 14px 10px; font-size: 11.5px; line-height: 1.4; color: var(--rai-muted); background: #fff; }
.rai-note a { color: var(--rai-muted); text-decoration: underline; }

@media print { .rai { display: none !important; } }

/* team member in the chat */
.rai-msg--human { border-left: 3px solid var(--rai-accent, #4D44C5); }
.rai-who { display: block; font-size: 12px; font-weight: 700; color: var(--rai-accent, #4D44C5); margin-bottom: 2px; }

/* review form inside the chat */
.rai-msg--review { max-width: 100%; width: 100%; }
.rai-review { display: grid; gap: 8px; }
.rai-stars { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; gap: 4px; }
.rai-stars input { position: absolute; opacity: 0; pointer-events: none; }
.rai-stars label { font-size: 30px; line-height: 1; color: #D8D5EE; cursor: pointer; }
.rai-stars label:hover, .rai-stars label:hover ~ label, .rai-stars input:checked ~ label { color: #FFB020; }
.rai-stars input:focus-visible + label { outline: 2px solid var(--rai-primary); outline-offset: 2px; border-radius: 4px; }
.rai-review__f { display: grid; gap: 3px; font-size: 12.5px; font-weight: 600; color: #444; }
.rai-review__f input, .rai-review__f textarea { width: 100%; padding: 9px 11px; font: inherit; font-size: 14px; font-weight: 400; border: 1px solid #d5d2ea; border-radius: 10px; background: #fff; }
.rai-review__f input:focus, .rai-review__f textarea:focus { outline: 2px solid var(--rai-primary); border-color: var(--rai-primary); }
.rai-review__c { display: flex; gap: 6px; align-items: flex-start; font-size: 12.5px; color: #444; }
.rai-review__hp { position: absolute; left: -9999px; height: 0; overflow: hidden; }
.rai-review__msg { margin: 0; padding: 8px 10px; border-radius: 8px; background: #FFE4E4; color: #B42318; font-size: 13px; }
.rai-review__go { padding: 11px 14px; font: inherit; font-weight: 700; color: #fff; background: var(--rai-primary); border: 0; border-radius: 10px; cursor: pointer; }
.rai-review__go:disabled { opacity: .6; cursor: default; }

/* No scrollbars anywhere in the chat: the message box grows as you type and the conversation scrolls by touch, wheel or keys. */
.rai-panel, .rai-panel * { scrollbar-width: none; -ms-overflow-style: none; }
.rai-panel *::-webkit-scrollbar, .rai-panel::-webkit-scrollbar { width: 0; height: 0; display: none; }
.rai-form textarea { overflow-y: auto; }

/* iPhone/iPad: 16px fields stop Safari zooming in when a field is tapped */
@media (hover: none) and (pointer: coarse) {
  input, select, textarea { font-size: 16px !important; }
}
