/* =========================================================
   Roiatek AI · assistant.css
   The Roiatek AI Assistant (js/assistant.js): animated robot avatar,
   launcher, chat panel and contact card. Every class is prefixed
   "aic-" except the robot ("robot", "rb-").
   ========================================================= */

/* =================== Animated robot =================== */
.robot {
  --w: 44px;
  position: relative;
  display: inline-block;
  flex: none;
  width: var(--w);
  aspect-ratio: 120 / 150;
}
.robot svg { width: 100%; height: 100%; overflow: visible; }
.robot * { transform-box: fill-box; transform-origin: center; }

.rb-shadow { fill: rgba(34, 228, 245, 0.28); animation: rb-shadow 4s ease-in-out infinite; }
.rb-body { animation: rb-float 4s ease-in-out infinite; }
.rb-ant { fill: var(--cyan); animation: rb-ant 2s ease-in-out infinite; }
.rb-ant-glow { animation: rb-glow 2s ease-in-out infinite; }
.rb-ear { fill: var(--cyan); animation: rb-led 2.4s ease-in-out infinite; }
.rb-ear--r { animation-delay: 1.2s; }
.rb-scan { fill: rgba(34, 228, 245, 0.16); transform-box: view-box; animation: rb-scan 3s ease-in-out infinite alternate; }
.rb-eyes { animation: rb-look 9s ease-in-out infinite; }
.rb-eye { fill: var(--cyan); filter: drop-shadow(0 0 3px rgba(34, 228, 245, 0.9)); animation: rb-blink 5s ease-in-out infinite; }
.rb-smile { fill: none; stroke: var(--cyan); stroke-width: 2; stroke-linecap: round; transition: opacity 0.2s; }
.rb-mouth { opacity: 0; fill: var(--cyan); transition: opacity 0.2s; }
.rb-t1 { font-family: var(--font-display); font-stretch: 108%; font-size: 10.5px; font-weight: 700; fill: #fff; letter-spacing: 0.02em; }
.rb-t2 { font-family: var(--font-body); font-size: 7.4px; font-weight: 600; fill: var(--cyan); letter-spacing: 0.02em; }
.rb-bar { animation: rb-bar 2.6s ease-in-out infinite; }
.rb-core { fill: var(--cyan); animation: rb-led 1.8s ease-in-out infinite; }
.rb-arm--l { transform-origin: 50% 8%; }
.rb-arm--r { transform-origin: 50% 8%; }

/* Talking: mouth equalizer replaces the smile */
.robot.is-talking .rb-smile { opacity: 0; }
.robot.is-talking .rb-mouth { opacity: 1; }
.robot.is-talking .rb-mouth rect { animation: rb-talk 0.42s ease-in-out infinite alternate; }
.robot.is-talking .rb-mouth rect:nth-child(2) { animation-delay: -0.12s; }
.robot.is-talking .rb-mouth rect:nth-child(3) { animation-delay: -0.28s; }
.robot.is-talking .rb-mouth rect:nth-child(4) { animation-delay: -0.06s; }
.robot.is-talking .rb-mouth rect:nth-child(5) { animation-delay: -0.2s; }

/* Thinking: eyes look up, antenna and scanner speed up */
.robot.is-thinking .rb-eyes { animation: rb-think 1.6s ease-in-out infinite; }
.robot.is-thinking .rb-ant { animation-duration: 0.6s; }
.robot.is-thinking .rb-ant-glow { animation-duration: 0.6s; }
.robot.is-thinking .rb-scan { animation-duration: 0.9s; }

/* Waving hello */
.robot.is-waving .rb-arm--r { animation: rb-wave 1.8s ease-in-out 1; }

@keyframes rb-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes rb-shadow { 0%, 100% { transform: scaleX(1); opacity: 1; } 50% { transform: scaleX(0.82); opacity: 0.6; } }
@keyframes rb-ant { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes rb-glow { 0%, 100% { opacity: 0.9; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.75); } }
@keyframes rb-led { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes rb-scan { from { transform: translateY(0); } to { transform: translateY(27px); } }
@keyframes rb-blink { 0%, 90%, 100% { transform: scaleY(1); } 94% { transform: scaleY(0.12); } }
@keyframes rb-look { 0%, 38%, 100% { transform: translate(0, 0); } 44%, 58% { transform: translate(3px, 0); } 64%, 80% { transform: translate(-3px, 1px); } }
@keyframes rb-think { 0%, 100% { transform: translate(-2px, -3px); } 50% { transform: translate(2px, -3px); } }
@keyframes rb-talk { from { transform: scaleY(0.35); } to { transform: scaleY(1.25); } }
@keyframes rb-bar { 0%, 100% { opacity: 0.55; transform: scaleX(0.7); } 50% { opacity: 1; transform: scaleX(1); } }
@keyframes rb-wave {
  0%, 100% { transform: rotate(0deg); }
  15% { transform: rotate(-150deg); }
  30% { transform: rotate(-120deg); }
  45% { transform: rotate(-150deg); }
  60% { transform: rotate(-120deg); }
  75% { transform: rotate(-150deg); }
}

/* Sizes */
.robot--launch { --w: 138px; }
.robot--head { --w: 36px; }
.robot--msg { --w: 30px; align-self: flex-end; }
.robot--hero { --w: 112px; }
.robot--inline { --w: 28px; margin: -6px 0; }

/* =================== Launcher: the robot itself =================== */
.aic-launch {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 0;
  background: none;
  border: 0;
  transition: transform 0.35s var(--ease), opacity 0.25s;
}
.aic-launch:hover { transform: translateY(-4px) scale(1.04); }
.aic-launch:focus-visible { outline-offset: 6px; border-radius: 24px; }
.aic-launch .robot { filter: drop-shadow(0 12px 22px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 18px rgba(34, 228, 245, 0.35)); }
.aic-launch-glow {
  position: absolute;
  inset: 12% -12% 4%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(34, 228, 245, 0.28), rgba(140, 92, 255, 0.14) 60%, transparent);
  animation: aic-glow 3.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes aic-glow { 0%, 100% { opacity: 0.7; transform: scale(0.94); } 50% { opacity: 1; transform: scale(1.05); } }
.aic-open .aic-launch { opacity: 0; pointer-events: none; transform: scale(0.9); }

/* Speech bubble next to the robot */
.aic-nudge {
  position: fixed;
  right: calc(max(18px, env(safe-area-inset-right)) + 142px);
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 112px);
  z-index: 90;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  width: max-content;
  max-width: min(350px, calc(100vw - 190px));
  padding: 14px 10px 14px 18px;
  border-radius: 20px 20px 6px 20px;
  background: linear-gradient(135deg, rgba(24, 50, 116, 0.98), rgba(12, 28, 72, 0.98));
  border: 1px solid rgba(34, 228, 245, 0.5);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.9), 0 0 26px -8px rgba(34, 228, 245, 0.55);
  opacity: 0;
  transform: translateY(10px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.4s var(--ease), transform 0.45s var(--ease);
}
.aic-nudge::after {
  content: "";
  position: absolute;
  right: -7px;
  bottom: 14px;
  width: 14px;
  height: 14px;
  background: rgba(14, 32, 80, 0.98);
  border-right: 1px solid rgba(34, 228, 245, 0.5);
  border-bottom: 1px solid rgba(34, 228, 245, 0.5);
  transform: rotate(-45deg);
}
.aic-nudge.is-in { opacity: 1; transform: none; }
.aic-nudge-open { display: grid; gap: 3px; text-align: left; line-height: 1.4; }
.aic-nudge-open strong { font-family: var(--font-display); font-stretch: 106%; font-size: 1rem; font-weight: 650; color: #fff; }
.aic-nudge-open span { font-size: 0.8438rem; color: var(--text-2); }
.aic-nudge-close { flex: none; width: 28px; height: 28px; border-radius: 8px; font-size: 1.2rem; line-height: 1; color: var(--text-3); }
.aic-nudge-close:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }

/* =================== Panel =================== */
.aic-backdrop {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(3, 8, 24, 0.45);
  opacity: 0;
  transition: opacity 0.25s var(--ease);
}
.aic-backdrop.is-in { opacity: 1; }
.aic-open, .aic-open body { overflow: hidden; }

.aic {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 120;
  width: min(440px, calc(100vw - 32px));
  height: min(720px, calc(100vh - 48px));
  height: min(720px, calc(100dvh - 48px));
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(12, 28, 70, 0.98), rgba(6, 15, 42, 0.98));
  opacity: 0;
  transform: translateY(18px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 0.26s var(--ease), transform 0.32s var(--ease);
}
.aic.is-in { opacity: 1; transform: none; }
.aic.led::after { opacity: 0.8; }
.aic-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: inherit;
  overflow: hidden;
}
.aic-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(70% 35% at 50% 0%, rgba(61, 107, 255, 0.18), transparent 70%),
    radial-gradient(50% 30% at 100% 100%, rgba(140, 92, 255, 0.12), transparent 70%);
}

.aic-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 12px 18px;
  border-bottom: 1px solid var(--line);
}
.aic-id { flex: 1; min-width: 0; }
.aic-id h2 { font-size: 1rem; font-stretch: 110%; letter-spacing: -0.01em; }
.aic-id p { display: flex; align-items: center; gap: 7px; margin-top: 2px; font-size: 0.78rem; color: var(--text-2); }
.aic-id .dot { width: 7px; height: 7px; }
.aic-icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 12px;
  color: var(--text-2);
  border: 1px solid var(--line);
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}
.aic-icon-btn:hover { color: var(--text); border-color: var(--line-strong); background: rgba(255, 255, 255, 0.05); }
.aic-icon-btn .ico { width: 17px; height: 17px; }

/* =================== Conversation =================== */
.aic-log {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 18px 10px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--navy-700) transparent;
}
.aic-msg { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 14px; animation: aic-in 0.35s var(--ease) both; }
.aic-msg--user { justify-content: flex-end; }
.aic-bubble {
  max-width: 82%;
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 0.9219rem;
  line-height: 1.58;
}
.aic-bubble p + p, .aic-bubble p + ul, .aic-bubble ul + p { margin-top: 8px; }
.aic-bubble ul { margin: 6px 0 0; display: grid; gap: 4px; }
.aic-bubble li { position: relative; padding-inline-start: 18px; }
.aic-bubble li::before {
  content: "";
  position: absolute;
  inset-inline-start: 3px;
  top: 0.62em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1.5px solid var(--cyan);
}
.aic-bubble strong { color: #fff; font-weight: 600; }
.aic [dir="auto"] { unicode-bidi: plaintext; font-family: var(--font-body), "IBM Plex Sans Arabic", sans-serif; }
.aic-msg--ai .aic-bubble {
  color: var(--text);
  background: linear-gradient(180deg, rgba(26, 52, 116, 0.55), rgba(14, 30, 74, 0.55));
  border: 1px solid rgba(120, 160, 255, 0.18);
  border-bottom-left-radius: 6px;
}
.aic-msg--user .aic-bubble {
  color: #fff;
  background: linear-gradient(135deg, #2f6bff, #7a4dff);
  border-bottom-right-radius: 6px;
  box-shadow: 0 10px 26px -14px rgba(122, 77, 255, 0.9);
}
.aic-msg.is-error .aic-bubble { border-color: rgba(255, 140, 180, 0.45); background: rgba(80, 20, 50, 0.35); }
.aic-msg.aic-sent .aic-bubble { border-color: rgba(70, 224, 138, 0.45); background: rgba(20, 70, 50, 0.3); }
.aic-retry {
  display: inline-block;
  margin-top: 10px;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--cyan);
  border: 1px solid rgba(34, 228, 245, 0.5);
}
.aic-w { opacity: 0; animation: aic-word 0.35s ease forwards; }
@keyframes aic-word { from { opacity: 0; filter: blur(3px); } to { opacity: 1; filter: none; } }
@keyframes aic-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.aic-typing .aic-bubble { display: inline-flex; padding: 14px 16px; }
.aic-dots { display: inline-flex; gap: 4px; }
.aic-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); animation: aic-dot 1s ease-in-out infinite; }
.aic-dots i:nth-child(2) { animation-delay: 0.15s; background: var(--blue); }
.aic-dots i:nth-child(3) { animation-delay: 0.3s; background: var(--violet); }
@keyframes aic-dot { 0%, 100% { transform: translateY(0); opacity: 0.4; } 50% { transform: translateY(-4px); opacity: 1; } }

/* Intro */
.aic-intro { display: grid; justify-items: center; padding-top: 4px; text-align: center; animation: aic-in 0.5s var(--ease) both; }
.aic-intro .robot { margin-bottom: 10px; filter: drop-shadow(0 14px 28px rgba(34, 228, 245, 0.25)); }
.aic-intro h3 { font-size: 1.3rem; font-stretch: 110%; letter-spacing: -0.015em; }
.aic-intro > p { margin-top: 8px; color: var(--text-2); font-size: 0.9063rem; }
.aic-starters { display: grid; gap: 8px; width: 100%; margin-top: 20px; }
.aic-starter {
  padding: 11px 14px;
  border-radius: 14px;
  text-align: start;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--text-2);
  background: rgba(16, 34, 78, 0.5);
  border: 1px solid var(--line);
  transition: border-color 0.25s, color 0.25s, transform 0.25s var(--ease), box-shadow 0.25s;
}
.aic-starter:hover {
  color: var(--text);
  border-color: rgba(34, 228, 245, 0.45);
  transform: translateY(-1px);
  box-shadow: 0 12px 26px -16px rgba(34, 228, 245, 0.6);
}

/* Suggestions + composer */
.aic-suggest { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 16px; }
.aic-suggest:not(:empty) { padding-bottom: 10px; }
.aic-chip-btn {
  padding: 6px 12px;
  border-radius: var(--r-pill);
  font-size: 0.8125rem;
  text-align: start;
  color: var(--cyan);
  border: 1px solid rgba(34, 228, 245, 0.4);
  background: rgba(34, 228, 245, 0.06);
  animation: aic-in 0.4s var(--ease) both;
  transition: background-color 0.2s, color 0.2s;
}
.aic-chip-btn:hover { background: rgba(34, 228, 245, 0.16); color: #fff; }
.aic-compose {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0 14px;
  padding: 7px 7px 7px 16px;
  border-radius: 20px;
  background: rgba(5, 12, 34, 0.75);
  border: 1px solid var(--line-strong);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.aic-compose:focus-within { border-color: rgba(34, 228, 245, 0.6); box-shadow: 0 0 0 3px rgba(34, 228, 245, 0.12), 0 0 24px -8px rgba(34, 228, 245, 0.5); }
.aic-compose textarea {
  flex: 1;
  min-height: 40px;
  max-height: 130px;
  padding: 9px 0;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 0.9375rem;
  line-height: 1.5;
}
.aic-compose textarea::placeholder { color: var(--text-3); }
.aic-send {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 13px;
  color: #03112b;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  box-shadow: 0 0 18px -4px rgba(34, 228, 245, 0.6);
  transition: transform 0.2s, opacity 0.2s;
}
.aic-send:hover { transform: scale(1.05); }
.aic-send:disabled { opacity: 0.45; transform: none; }
.aic-send .ico { width: 18px; height: 18px; }
.aic-fine { padding: 8px 12px 12px; text-align: center; font-size: 0.72rem; color: var(--text-3); }
.aic-fine-link { font-size: inherit; color: var(--text-2); text-decoration: underline; text-underline-offset: 2px; }
.aic-fine-link:hover { color: var(--cyan); }

/* Contact card */
.aic-card {
  display: grid;
  gap: 8px;
  width: 100%;
  max-width: 86%;
  padding: 14px;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  background:
    radial-gradient(80% 60% at 0% 0%, rgba(34, 228, 245, 0.1), transparent 60%),
    linear-gradient(180deg, rgba(26, 52, 116, 0.6), rgba(14, 30, 74, 0.6));
  border: 1px solid rgba(34, 228, 245, 0.4);
}
.aic-card strong { font-size: 0.9375rem; }
.aic-card > p { margin: -4px 0 4px; font-size: 0.8438rem; line-height: 1.5; color: var(--text-2); }
.aic-card input {
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 11px;
  font-size: 0.9375rem;
  color: var(--text);
  background: rgba(5, 11, 31, 0.6);
  border: 1px solid var(--line-strong);
}
.aic-card input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34, 228, 245, 0.15); }
.aic-card-actions { display: flex; align-items: center; gap: 14px; margin-top: 4px; }
.aic-card-actions .btn { min-height: 40px; padding: 8px 22px; }
.aic-link { font-size: 0.8438rem; font-weight: 600; color: var(--text-2); }
.aic-link:hover { color: var(--cyan); }
.aic-card-status { min-height: 1.1em; font-size: 0.8125rem; color: var(--text-2); }
.aic-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* =================== In-page entry points =================== */
.aic-cta {
  display: flex;
  justify-content: center;
  margin: -22px 0 clamp(36px, 4vw, 52px);
}
.aic-cta .btn { gap: 12px; }
.aic-inline-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--cyan);
}
.aic-inline-link:hover { color: #fff; }

/* =================== Responsive =================== */
@media (max-width: 640px) {
  .robot--launch { --w: 105px; }
  .aic-nudge {
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 142px);
    max-width: min(300px, calc(100vw - 24px));
    border-radius: 18px 18px 6px 18px;
  }
  .aic-nudge::after { right: 47px; bottom: -7px; transform: rotate(45deg); }
  .aic-nudge-open strong { font-size: 0.9375rem; }
  .aic {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
  }
  .aic.led::before, .aic.led::after { display: none; }
  .robot--hero { --w: 100px; }
  .aic-bubble, .aic-card { max-width: 88%; }
}

@media (prefers-reduced-motion: reduce) {
  .aic, .aic-backdrop { transition: none; }
  .aic-w { opacity: 1; animation: none; }
}
