/* ===================== ModiinChatBot.css (FULL) ===================== */
/* Scope: everything under #modiin-chatbot */
#modiin-chatbot .cw-root{
  --cw-primary:#2563eb;
  --cw-primary-2:#1d4ed8;
  --cw-bg:#ffffff;
  --cw-surface:#f8fafc;
  --cw-border:#e5e7eb;
  --cw-text:#0f172a;
  --cw-muted:#64748b;
  --cw-bot:#f1f5ff;
  --cw-user:#2563eb;
  --cw-user-text:#ffffff;
  --cw-radius:18px;
  --cw-shadow: 0 20px 50px rgba(2,6,23,.18);
  --cw-font: system-ui, -apple-system, "Segoe UI", Arial, "Assistant", sans-serif;

  --cw-link:#1d4ed8;
  --cw-code-bg:#0b1220;
  --cw-code-text:#e5e7eb;

  /* System bubble (grey) variables */
  --cw-system-bg:#f1f3f5;
  --cw-system-text:#334155;
  --cw-system-border: rgba(0,0,0,.08);

  direction: rtl;
  font-family: var(--cw-font);
}

/* Auto Dark Mode */
@media (prefers-color-scheme: dark){
  #modiin-chatbot .cw-root{
    --cw-bg:#0b1220;
    --cw-surface:#0f172a;
    --cw-border:#1f2a44;
    --cw-text:#e5e7eb;
    --cw-muted:#9aa7bd;
    --cw-bot:#111b2e;
    --cw-user:#2563eb;
    --cw-user-text:#ffffff;
    --cw-shadow: 0 20px 55px rgba(0,0,0,.55);
    --cw-link:#93c5fd;
    --cw-code-bg:#050a14;
    --cw-code-text:#e5e7eb;

    --cw-system-bg:#0f172a;
    --cw-system-text:#cbd5e1;
    --cw-system-border: rgba(255,255,255,.10);
  }
}

/* minimal isolation */
#modiin-chatbot .cw-root, 
#modiin-chatbot .cw-root *{
  box-sizing:border-box;
}

/* Launcher */
#modiin-chatbot .cw-launcher{
  position:fixed;
  bottom:18px;
  right:18px;
  width:60px;height:60px;
  border-radius:999px;
  border:0 !important;
  cursor:pointer;
  background: linear-gradient(135deg, var(--cw-primary), var(--cw-primary-2)) !important;

  /* ✅ Shadow more to the bottom */
  box-shadow:
    0 18px 34px rgba(2,6,23,.30),
    0 10px 22px rgba(37,99,235,.28) !important;

  display:flex;align-items:center;justify-content:center;
  z-index:999999;
  transition: transform .12s ease, box-shadow .12s ease;
}
#modiin-chatbot .cw-launcher:hover{
  transform: translateY(-1px);
  box-shadow:
    0 22px 40px rgba(2,6,23,.34),
    0 12px 26px rgba(37,99,235,.30) !important;
}
#modiin-chatbot .cw-launcher:active{ transform: translateY(0); }
#modiin-chatbot .cw-launcher:focus{ outline: 3px solid rgba(37,99,235,.35); outline-offset: 3px; }
#modiin-chatbot .cw-launcher span{ color:#fff !important; }

/* Panel */
#modiin-chatbot .cw-panel{
  position:fixed;
  bottom:92px;
  right:18px;
  width:min(380px, calc(100vw - 36px));
  height:min(640px, calc(100vh - 130px));
  background:var(--cw-bg);
  border:1px solid var(--cw-border);
  border-radius: var(--cw-radius);
  box-shadow: var(--cw-shadow);
  overflow:hidden;
  display:none;
  flex-direction:column;
  z-index:999999;
  direction: rtl;
}
#modiin-chatbot .cw-panel[data-open="true"]{ display:flex; }

/* Header */
#modiin-chatbot .cw-header{
  padding:12px 12px;
  background: linear-gradient(180deg, var(--cw-bg), var(--cw-surface));
  border-bottom:1px solid var(--cw-border);
  display:flex;
  align-items:center;
  gap:10px;
}
#modiin-chatbot .cw-avatar{
  width:38px;height:38px;border-radius:14px;
  background: rgba(37,99,235,.10);
  display:flex;align-items:center;justify-content:center;
  border:1px solid rgba(37,99,235,.18);
  flex:0 0 auto;
}
#modiin-chatbot .cw-title{ flex:1; min-width:0; display:flex; flex-direction:column; gap:2px; }
#modiin-chatbot .cw-title strong{ font-size:14px; color:var(--cw-text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#modiin-chatbot .cw-title span{ font-size:12px; color:var(--cw-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

#modiin-chatbot .cw-close{
  border:0;background:transparent;cursor:pointer;
  width:34px;height:34px;border-radius:12px;
  color:var(--cw-muted);
  display:flex;align-items:center;justify-content:center;
}
#modiin-chatbot .cw-close:hover{ background: rgba(255,255,255,.06); }
#modiin-chatbot .cw-close:focus{ outline: 3px solid rgba(37,99,235,.25); outline-offset: 2px; }

/* Messages */
#modiin-chatbot .cw-messages{
  flex:1;
  overflow:auto;
  padding:14px 12px;
  background:
    radial-gradient(1200px 500px at 85% 0%, rgba(37,99,235,.10), transparent 55%),
    linear-gradient(180deg, var(--cw-bg), var(--cw-bg));
}
#modiin-chatbot .cw-row{ display:flex; margin:10px 0; }

/* ✅ Requests on the right, replies on the left */
/* RTL FIX: user on the right, bot on the left */
#modiin-chatbot .cw-row[data-role="user"]{
  justify-content: flex-start; /* RIGHT in RTL */
}

#modiin-chatbot .cw-row[data-role="bot"]{
  justify-content: flex-end;   /* LEFT in RTL */
}


#modiin-chatbot .cw-bubble{
  max-width: 86%;
  padding:10px 12px;
  border-radius: 14px;
  font-size:14px;
  line-height:1.6;
  word-break:break-word;
  overflow-wrap:anywhere;
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: 0 8px 18px rgba(2,6,23,.10);
}
#modiin-chatbot .cw-row[data-role="bot"] .cw-bubble{
  background: var(--cw-bot);
  color: var(--cw-text);
  border-top-right-radius: 6px;
}
#modiin-chatbot .cw-row[data-role="user"] .cw-bubble{
  background: var(--cw-user);
  color: var(--cw-user-text);
  border-top-left-radius: 6px;
  box-shadow: 0 10px 22px rgba(37,99,235,.25);
  border: 1px solid rgba(255,255,255,.14);
}

/* ===== System (grey) bubble ===== */
#modiin-chatbot .cw-row.cw-row--system{ justify-content:center; }
#modiin-chatbot .cw-row.cw-row--system .cw-bubble{
  background: var(--cw-system-bg);
  color: var(--cw-system-text);
  border: 1px solid var(--cw-system-border);
  box-shadow: none;
  font-size: 12.5px;
  line-height: 1.25;
  max-width: 92%;
  text-align: center;
}

/* Markdown inside bot bubble */
#modiin-chatbot .cw-bubble h1, 
#modiin-chatbot .cw-bubble h2, 
#modiin-chatbot .cw-bubble h3{
  margin: 6px 0 6px;
  line-height: 1.25;
}
#modiin-chatbot .cw-bubble h1{ font-size: 18px; }
#modiin-chatbot .cw-bubble h2{ font-size: 16px; }
#modiin-chatbot .cw-bubble h3{ font-size: 15px; }

#modiin-chatbot .cw-bubble ul, 
#modiin-chatbot .cw-bubble ol{
  margin: 6px 0 6px;
  padding-right: 18px;
}
#modiin-chatbot .cw-bubble li{ margin: 3px 0; }

#modiin-chatbot .cw-bubble code{
  background: rgba(255,255,255,.10);
  padding: 1px 6px;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  overflow-wrap:anywhere;
}
#modiin-chatbot .cw-bubble pre{
  background: var(--cw-code-bg);
  color: var(--cw-code-text);
  padding: 10px 10px;
  border-radius: 12px;
  overflow: auto;
  margin: 8px 0;
  border: 1px solid rgba(255,255,255,.08);
}
#modiin-chatbot .cw-bubble pre code{
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap:anywhere;
}

#modiin-chatbot .cw-bubble a{
  color: var(--cw-link);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
  overflow-wrap:anywhere;
}
#modiin-chatbot .cw-row[data-role="user"] .cw-bubble a{ color: #fff; }

/* Typing dots */
#modiin-chatbot .cw-typing{ display:inline-flex; gap:5px; align-items:center; }
#modiin-chatbot .cw-dot{
  width:6px;height:6px;border-radius:999px;background: var(--cw-muted);
  opacity:.55; animation: cw-bounce 1.2s infinite;
}
#modiin-chatbot .cw-dot:nth-child(2){ animation-delay:.15s; }
#modiin-chatbot .cw-dot:nth-child(3){ animation-delay:.3s; }
@keyframes cw-bounce{
  0%,80%,100%{ transform: translateY(0); opacity:.45; }
  40%{ transform: translateY(-4px); opacity:.9; }
}

/* Composer */
#modiin-chatbot .cw-composer{
  padding:10px 10px;
  background: var(--cw-surface);
  border-top:1px solid var(--cw-border);
  display:flex;
  gap:8px;
  align-items:center;
}
#modiin-chatbot .cw-input{
  flex:1;
  border:1px solid var(--cw-border);
  background:var(--cw-bg);
  border-radius: 14px;
  padding:10px 12px;
  font-size:14px;
  color:var(--cw-text);
  direction: rtl;
}
#modiin-chatbot .cw-input:focus{
  outline: 3px solid rgba(37,99,235,.18);
  border-color: rgba(37,99,235,.45);
}
#modiin-chatbot .cw-send{
  border:0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--cw-primary), var(--cw-primary-2));
  color:#fff;
  padding:10px 14px;
  cursor:pointer;
  font-size:14px;
  min-width: 72px;
  box-shadow: 0 10px 22px rgba(37,99,235,.25);
}
#modiin-chatbot .cw-send:hover{ filter: brightness(1.02); }
#modiin-chatbot .cw-send:disabled{ opacity:.6; cursor:not-allowed; box-shadow:none; }

#modiin-chatbot .cw-hint{
  padding:8px 12px 10px;
  font-size:11px;
  color:var(--cw-muted);
  background:var(--cw-bg);
  border-top:1px solid var(--cw-border);
}

/* Mobile */
@media (max-width: 420px){
  #modiin-chatbot .cw-panel{ right:12px; width: calc(100vw - 24px); }
  #modiin-chatbot .cw-launcher{ right:12px; }
}
