/* Lugoda Sentinel — Lugoda AI styling.
   Floating launcher (FAB), slide-in right drawer, message bubbles, suggestion chips,
   input bar, typing indicator, and the full-width 'ai' view variant. On-brand dark/red.
   Tokens come from theme.css (--red, --panel, --line, --txt, --muted, --green …). */

/* ---------- nav link accent (the ✦ Lugoda AI nav item) ---------- */
nav.portnav a.ainav{
  background:linear-gradient(90deg, rgba(225,27,34,.16), rgba(225,27,34,.04));
  border:1px solid rgba(225,27,34,.32);
  color:#ffd9da;
  font-weight:600;
}
nav.portnav a.ainav:hover{
  background:linear-gradient(90deg, rgba(225,27,34,.28), rgba(225,27,34,.08));
  color:#fff;
}
nav.portnav a.ainav.active{
  background:linear-gradient(90deg, var(--red), var(--red-dark));
  color:#fff;border-color:transparent;
  box-shadow:0 0 16px rgba(225,27,34,.4);
}

/* ---------- floating launcher (FAB) ---------- */
.ai-fab{
  position:fixed;right:22px;bottom:22px;z-index:60;
  width:58px;height:58px;border:none;border-radius:50%;cursor:pointer;
  font-size:24px;color:#fff;line-height:1;
  background:radial-gradient(120% 120% at 30% 25%, #ff5258, var(--red) 45%, var(--red-dark));
  box-shadow:0 10px 28px rgba(225,27,34,.45), 0 0 0 0 rgba(225,27,34,.5);
  animation:ai-fab-pulse 2.6s ease-out infinite;
  transition:transform .15s ease, box-shadow .2s ease;
}
.ai-fab:hover{transform:translateY(-2px) scale(1.05);box-shadow:0 14px 34px rgba(225,27,34,.6)}
.ai-fab:active{transform:scale(.96)}
.ai-fab.hidden{opacity:0;pointer-events:none;transform:scale(.6)}
@keyframes ai-fab-pulse{
  0%{box-shadow:0 10px 28px rgba(225,27,34,.45), 0 0 0 0 rgba(225,27,34,.5)}
  70%{box-shadow:0 10px 28px rgba(225,27,34,.45), 0 0 0 18px rgba(225,27,34,0)}
  100%{box-shadow:0 10px 28px rgba(225,27,34,.45), 0 0 0 0 rgba(225,27,34,0)}
}

/* ---------- slide-in drawer ---------- */
.ai-drawer{
  position:fixed;top:0;right:0;bottom:0;z-index:70;
  width:380px;max-width:92vw;
  background:linear-gradient(180deg,#1a1a20,#141418);
  border-left:1px solid var(--line);
  box-shadow:-12px 0 40px rgba(0,0,0,.5);
  display:flex;flex-direction:column;
  transform:translateX(105%);transition:transform .26s cubic-bezier(.22,.61,.36,1);
}
.ai-drawer.open{transform:translateX(0)}

.ai-drawer-head{
  display:flex;align-items:center;gap:8px;padding:13px 14px;
  background:linear-gradient(90deg,#231116,#1c1c22);
  border-bottom:1px solid var(--line);
}
.ai-drawer-ttl{display:flex;align-items:center;gap:8px;font-weight:700;font-size:15px;flex:1}
.ai-drawer-actions{display:flex;gap:6px}
.ai-drawer-actions button{
  background:transparent;border:1px solid var(--line);color:var(--muted);
  width:28px;height:28px;border-radius:8px;cursor:pointer;font-size:13px;transition:.15s;
}
.ai-drawer-actions button:hover{color:#fff;border-color:var(--red);background:rgba(225,27,34,.12)}
.ai-drawer-body{flex:1;display:flex;flex-direction:column;min-height:0}

.ai-spark{color:var(--red);text-shadow:0 0 10px rgba(225,27,34,.6)}

/* ---------- status pill ---------- */
.ai-status{
  font-size:11px;font-weight:600;color:var(--muted);
  padding:2px 8px;border-radius:999px;border:1px solid var(--line);white-space:nowrap;
}
.ai-status.on{color:var(--green);border-color:rgba(39,194,129,.4);background:rgba(39,194,129,.08)}
.ai-status.off{color:var(--amber);border-color:rgba(245,166,35,.4);background:rgba(245,166,35,.08)}

/* ---------- shared assistant shell ---------- */
.ai-shell{display:flex;flex-direction:column;min-height:0;flex:1}

.ai-msgs{
  flex:1;overflow-y:auto;padding:14px;display:flex;flex-direction:column;gap:10px;min-height:0;
}
.ai-hello{
  font-size:13px;color:var(--muted);background:var(--panel);
  border:1px solid var(--line);border-radius:12px;padding:12px 13px;line-height:1.55;
}
.ai-hello b{color:var(--txt)}

.ai-msg{display:flex;max-width:100%}
.ai-msg.me{justify-content:flex-end}
.ai-msg.bot{justify-content:flex-start}
.ai-bubble{
  max-width:86%;padding:10px 13px;border-radius:14px;font-size:13.5px;line-height:1.55;
  word-wrap:break-word;overflow-wrap:anywhere;animation:ai-pop .18s ease;
}
@keyframes ai-pop{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
.ai-msg.me .ai-bubble{
  background:linear-gradient(135deg, rgba(225,27,34,.9), var(--red-dark));
  color:#fff;border-bottom-right-radius:5px;
}
.ai-msg.bot .ai-bubble{
  background:var(--panel2);border:1px solid var(--line);color:var(--txt);
  border-bottom-left-radius:5px;
}
.ai-bubble strong{color:#fff;font-weight:700}
.ai-msg.bot .ai-bubble strong{color:#ffd9da}

/* rich-markdown blocks rendered inside bot bubbles */
.ai-bubble>:first-child{margin-top:0}
.ai-bubble>:last-child{margin-bottom:0}
.ai-bubble .ai-p{margin:0 0 8px;line-height:1.55}
.ai-bubble .ai-ul,.ai-bubble .ai-ol{margin:6px 0;padding-left:20px}
.ai-bubble .ai-ul li,.ai-bubble .ai-ol li{margin:3px 0;line-height:1.5}
.ai-bubble .ai-h{
  margin:12px 0 7px;line-height:1.3;font-weight:700;color:#ffd9da;
  letter-spacing:.2px;
}
.ai-bubble h4.ai-h{font-size:15px;padding-bottom:5px;border-bottom:1px solid rgba(225,27,34,.22)}
.ai-bubble h5.ai-h{font-size:13.5px}
.ai-bubble h6.ai-h{font-size:12px;text-transform:uppercase;letter-spacing:.6px;color:var(--muted)}
.ai-bubble .ai-hr{border:none;border-top:1px solid var(--line);margin:11px 0}
.ai-bubble .ai-quote{
  margin:8px 0;padding:8px 12px;border-left:3px solid var(--red);
  background:rgba(225,27,34,.08);border-radius:0 8px 8px 0;color:#f3d9db;font-size:13px;
}
.ai-bubble code{
  font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12px;
  background:rgba(255,255,255,.07);border:1px solid var(--line);border-radius:5px;padding:1px 5px;
}
.ai-bubble .ai-code{
  margin:8px 0;padding:11px 12px;background:#0f0f13;border:1px solid var(--line);
  border-radius:9px;overflow-x:auto;
}
.ai-bubble .ai-code code{background:none;border:none;padding:0;color:#e8e8ec;line-height:1.5}

/* compliance/data tables */
.ai-bubble .ai-table{
  width:100%;border-collapse:collapse;margin:9px 0;font-size:12.5px;
  background:rgba(0,0,0,.18);border:1px solid var(--line);border-radius:9px;overflow:hidden;
}
.ai-bubble .ai-table th,.ai-bubble .ai-table td{
  padding:7px 10px;text-align:left;border-bottom:1px solid var(--line);vertical-align:top;
}
.ai-bubble .ai-table thead th{
  background:linear-gradient(90deg,rgba(225,27,34,.18),rgba(225,27,34,.05));
  color:#ffd9da;font-weight:700;font-size:11px;text-transform:uppercase;letter-spacing:.5px;
  border-bottom:1px solid rgba(225,27,34,.3);white-space:nowrap;
}
.ai-bubble .ai-table tbody tr:last-child td{border-bottom:none}
.ai-bubble .ai-table tbody tr:hover td{background:rgba(225,27,34,.06)}

/* tables/quotes need room — let bot bubbles use the full column */
.ai-msg.bot .ai-bubble:has(.ai-table),
.ai-msg.bot .ai-bubble:has(.ai-h){max-width:96%}

/* typing indicator */
.ai-typing{display:inline-flex;gap:4px;align-items:center;padding:12px 14px}
.ai-typing span{
  width:7px;height:7px;border-radius:50%;background:var(--muted);
  animation:ai-blink 1.2s infinite ease-in-out;
}
.ai-typing span:nth-child(2){animation-delay:.18s}
.ai-typing span:nth-child(3){animation-delay:.36s}
@keyframes ai-blink{0%,80%,100%{opacity:.25;transform:scale(.8)}40%{opacity:1;transform:scale(1)}}

/* ---------- suggestion chips ---------- */
.ai-chips{display:flex;flex-wrap:wrap;gap:7px;padding:0 14px 10px}
.ai-chip{
  font-size:12px;color:#ffd9da;cursor:pointer;
  background:rgba(225,27,34,.1);border:1px solid rgba(225,27,34,.3);
  padding:6px 11px;border-radius:999px;transition:.15s;
}
.ai-chip:hover{background:rgba(225,27,34,.22);color:#fff;border-color:var(--red)}

/* ---------- input bar ---------- */
.ai-inputbar{
  display:flex;gap:8px;padding:11px 14px;border-top:1px solid var(--line);
  background:#15151a;
}
.ai-input{
  flex:1;background:var(--panel);border:1px solid var(--line);border-radius:10px;
  color:var(--txt);padding:10px 12px;font-size:13.5px;font-family:inherit;outline:none;transition:.15s;
}
.ai-input:focus{border-color:var(--red);box-shadow:0 0 0 3px rgba(225,27,34,.15)}
.ai-input::placeholder{color:var(--muted)}
.ai-send{
  background:linear-gradient(135deg,var(--red),var(--red-dark));border:none;color:#fff;
  font-weight:700;font-size:13px;padding:0 16px;border-radius:10px;cursor:pointer;transition:.15s;
}
.ai-send:hover{filter:brightness(1.1);box-shadow:0 4px 14px rgba(225,27,34,.4)}
.ai-send:active{transform:translateY(1px)}

/* ---------- full-width 'ai' view ---------- */
.ai-intro{padding:18px 22px 4px}
.ai-intro h2{font-size:22px;display:flex;align-items:center;gap:9px}
.ai-intro p{margin:8px 0 0;color:var(--muted);font-size:13.5px;line-height:1.6;max-width:880px}
.ai-fullcard{
  margin:14px 22px 22px;background:linear-gradient(180deg,#1b1b21,#16161b);
  border:1px solid var(--line);border-radius:var(--r);box-shadow:var(--shadow);
  display:flex;flex-direction:column;height:calc(100vh - 320px);min-height:420px;overflow:hidden;
}
.ai-shell.ai-full .ai-msgs{padding:18px 22px}
.ai-shell.ai-full .ai-bubble{max-width:72%;font-size:14px}
.ai-shell.ai-full .ai-chips{padding:0 22px 12px}
.ai-shell.ai-full .ai-inputbar{padding:13px 22px}

@media(max-width:980px){
  .ai-fullcard{height:auto;min-height:60vh;margin:14px}
  .ai-shell.ai-full .ai-bubble{max-width:88%}
}
