/* =======================================================
   AI Career Agent — Widget CSS v4
   Completely isolated from theme; fixed positioning works.
   All selectors match widget.php exactly.
   ======================================================= */

/* ── Root element — THIS is what is fixed to the screen ── */
#aca-widget {
  /* CSS custom properties — accent color set by inline <style> */
  --acp:    #1a56db;
  --acp-dk: #1044b0;

  /* Primitive tokens */
  --bg:     #ffffff;
  --bg2:    #f8fafc;
  --bg3:    #f1f5f9;
  --txt:    #0f172a;
  --txt2:   #475569;
  --txt3:   #94a3b8;
  --bdr:    #e2e8f0;
  --shad:   0 20px 60px rgba(15,23,42,.18), 0 4px 16px rgba(15,23,42,.08);
  --r:      20px;
  --font:   -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Layout */
  position:   fixed !important;  /* must be fixed to stay in viewport */
  z-index:    999999 !important; /* above everything, including Superio's header */
  bottom:     24px;
  font-family: var(--font);
  font-size:  14px;
  line-height: 1.5;
  color:      var(--txt);

  /* Superio theme reset — prevent any theme styles affecting widget children */
  all:        initial;
  position:   fixed !important;
  z-index:    999999 !important;
  bottom:     24px;
  font-family: var(--font);
  font-size:  14px;
  line-height: 1.5;
  color:      var(--txt);
}

/* Position variants */
#aca-widget.aca-bottom-right { right: 24px; left: auto; }
#aca-widget.aca-bottom-left  { left:  24px; right: auto; }

/* Child reset */
#aca-widget *, #aca-widget *::before, #aca-widget *::after {
  box-sizing: border-box;
  margin: 0; padding: 0;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  /* Undo any Superio resets that might propagate */
  line-height: inherit;
}

/* Superio class name conflicts */
#aca-widget .widget,
#aca-widget .job-listing,
#aca-widget .job-box { all: unset !important; }

/* ── Launcher ─────────────────────────────────────────── */
.aca-launcher {
  display:       flex;
  align-items:   center;
  gap:           10px;
  height:        54px;
  padding:       0 20px 0 16px;
  border-radius: 27px;
  background:    var(--acp);
  border:        none;
  cursor:        pointer;
  color:         #fff;
  box-shadow:    0 6px 24px color-mix(in srgb, var(--acp) 45%, transparent), 0 2px 8px rgba(0,0,0,.1);
  transition:    transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
  position:      relative;
  isolation:     isolate;
  /* Override any global button styles */
  font-size:     14px;
  font-weight:   600;
  letter-spacing:.01em;
  white-space:   nowrap;
}
.aca-launcher:hover  { transform: scale(1.07); }
.aca-launcher:active { transform: scale(.96); }

.aca-l-icon { display: flex; width: 22px; height: 22px; flex-shrink: 0; }
.aca-l-icon svg { width: 22px; height: 22px; }
.aca-l-label { font-size: 13px; font-weight: 700; }

.aca-notif-dot {
  position: absolute; top: -4px; right: -4px;
  background: #ef4444; color: #fff;
  font-size: 14px; line-height: 1;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
  animation: aca-ping 2s infinite;
}
@keyframes aca-ping {
  0%,100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.2); opacity: .8; }
}

/* ── Panel ────────────────────────────────────────────── */
.aca-panel {
  position:      absolute;
  width:         390px;
  max-height:    600px;
  background:    var(--bg);
  border-radius: var(--r);
  box-shadow:    var(--shad);
  border:        1px solid var(--bdr);
  display:       flex;
  flex-direction:column;
  overflow:      hidden;
  bottom:        64px; /* sit above launcher */
}

/* Position the panel relative to the FAB */
.aca-bottom-right .aca-panel { right: 0; }
.aca-bottom-left  .aca-panel { left:  0; }

/* Open/close animation — panel uses hidden attr */
.aca-panel[hidden] {
  display:        flex !important; /* keep in layout for animation */
  opacity:        0;
  transform:      translateY(14px) scale(.97);
  pointer-events: none;
  visibility:     hidden;
  transition:     opacity .25s, transform .25s cubic-bezier(.34,1.56,.64,1), visibility 0s .25s;
}
.aca-panel:not([hidden]) {
  opacity:        1;
  transform:      translateY(0) scale(1);
  pointer-events: all;
  visibility:     visible;
  transition:     opacity .25s, transform .25s cubic-bezier(.34,1.56,.64,1);
}

/* ── Header ───────────────────────────────────────────── */
.aca-hdr {
  display:     flex;
  align-items: center;
  gap:         10px;
  padding:     13px 12px 13px 16px;
  background:  var(--acp);
  color:       #fff;
  flex-shrink: 0;
  transition:  background .3s;
}
.aca-hdr.aca-hdr-employer { background: #1e3a5f; }

.aca-hdr-ava {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.aca-hdr-ava svg { width: 18px; height: 18px; }

.aca-hdr-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.aca-hdr-name { font-size: 14px; font-weight: 700; }
.aca-hdr-sub  { display: flex; align-items: center; gap: 5px; font-size: 11px; opacity: .85; }
.aca-live-dot { width: 6px; height: 6px; border-radius: 50%; background: #4ade80; flex-shrink: 0; animation: aca-live 2.5s ease infinite; }
@keyframes aca-live { 0%,100%{opacity:1} 50%{opacity:.4} }

.aca-hdr-acts { display: flex; align-items: center; gap: 2px; }

/* Token pill in header */
.aca-tok-pill {
  font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 20px;
  background: rgba(255,255,255,.18);
  color: #fff; margin-right: 4px;
  white-space: nowrap; cursor: default;
}

.aca-hdr-btn {
  background: none; border: none; color: rgba(255,255,255,.75);
  cursor: pointer; padding: 5px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  transition: background .15s, color .15s;
}
.aca-hdr-btn svg { width: 15px; height: 15px; }
.aca-hdr-btn:hover { background: rgba(255,255,255,.15); color: #fff; }

/* ── Screen system ────────────────────────────────────── */
/* All screens stack in the same space; hidden attr hides them */
.aca-screen {
  display:        flex;
  flex-direction: column;
  flex:           1;
  overflow:       hidden;
  min-height:     0;
  animation:      aca-fadein .2s ease;
}
.aca-screen[hidden] { display: none !important; }
@keyframes aca-fadein { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:none} }

/* ── Screen: Role Selector ────────────────────────────── */
#aca-s-role {
  overflow-y:     auto;
  padding:        20px 20px 28px;
  background:     linear-gradient(160deg,color-mix(in srgb,var(--acp) 8%,#fff) 0%,#fff 60%);
  justify-content:center;
}
.aca-role-hero {
  text-align: center;
  margin-bottom: 20px;
}
.aca-role-orb { width: 72px; height: 72px; margin: 0 auto 14px; }
.aca-role-orb svg { width: 72px; height: 72px; border-radius: 50%; }
.aca-role-title { font-size: 18px; font-weight: 800; color: var(--txt); letter-spacing: -.02em; }
.aca-role-sub   { font-size: 13px; color: var(--txt2); margin-top: 5px; line-height: 1.5; }

.aca-role-btns { display: flex; flex-direction: column; gap: 10px; }
.aca-role-btn {
  display:       flex;
  align-items:   center;
  gap:           12px;
  padding:       16px 16px 16px 14px;
  background:    var(--bg);
  border:        2px solid var(--bdr);
  border-radius: 14px;
  cursor:        pointer;
  text-align:    left;
  transition:    all .2s;
  font-size:     14px;
}
.aca-role-btn:hover {
  border-color: var(--acp);
  background:   color-mix(in srgb,var(--acp) 5%,#fff);
  transform:    translateX(3px);
  box-shadow:   0 4px 16px color-mix(in srgb,var(--acp) 14%,transparent);
}
.aca-rb-icon { font-size: 28px; flex-shrink: 0; }
.aca-rb-body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.aca-rb-body strong { font-size: 14px; font-weight: 700; color: var(--txt); display: block; }
.aca-rb-body span   { font-size: 11.5px; color: var(--txt2); display: block; }
.aca-rb-arr { font-size: 20px; color: var(--txt3); transition: transform .2s, color .2s; }
.aca-role-btn:hover .aca-rb-arr { transform: translateX(3px); color: var(--acp); }

/* ── Screen: Menu (candidate / employer) ─────────────── */
#aca-s-candidate, #aca-s-employer { background: var(--bg); }

.aca-menu-bar {
  display:      flex;
  align-items:  center;
  gap:          10px;
  padding:      8px 14px;
  border-bottom:1px solid var(--bdr);
  background:   var(--bg2);
  flex-shrink:  0;
  font-size:    12px;
  font-weight:  700;
  color:        var(--txt2);
}

.aca-nav-back {
  background:    none;
  border:        none;
  color:         var(--acp);
  font-size:     12px;
  font-weight:   600;
  cursor:        pointer;
  padding:       3px 7px;
  border-radius: 6px;
  transition:    background .15s;
}
.aca-nav-back:hover { background: color-mix(in srgb,var(--acp) 8%,#fff); }

.aca-tiles {
  display:    grid;
  grid-template-columns: 1fr 1fr;
  gap:        10px;
  padding:    12px;
  overflow-y: auto;
  flex:       1;
}

.aca-tile {
  display:        flex;
  flex-direction: column;
  align-items:    flex-start;
  gap:            5px;
  padding:        13px 11px;
  border-radius:  13px;
  border:         1.5px solid var(--bdr);
  background:     var(--bg);
  cursor:         pointer;
  text-align:     left;
  transition:     all .18s;
  font-size:      14px;
}
.aca-tile:hover {
  border-color: var(--acp);
  background:   color-mix(in srgb,var(--acp) 6%,#fff);
  transform:    translateY(-2px);
  box-shadow:   0 4px 14px color-mix(in srgb,var(--acp) 12%,transparent);
}

.aca-tile-hero {
  grid-column:    span 2;
  flex-direction: row;
  align-items:    center;
  border-color:   var(--acp);
  background:     linear-gradient(135deg, color-mix(in srgb,var(--acp) 8%,#fff), var(--bg));
}
.aca-tile-accent {
  grid-column:  span 2;
  border-color: #d97706;
  background:   linear-gradient(135deg,#fffbeb,var(--bg));
}
.aca-tile-accent:hover { border-color: #b45309; background: #fef3c7; }

.aca-tile-ico  { font-size: 22px; line-height: 1; flex-shrink: 0; }
.aca-tile-body { display: flex; flex-direction: column; gap: 2px; }
.aca-tile-body strong { font-size: 12.5px; font-weight: 700; color: var(--txt); display: block; }
.aca-tile-body span   { font-size: 11px;   color: var(--txt2); display: block; }

/* ── Screen: Chat ─────────────────────────────────────── */
.aca-screen-chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.aca-ctx-bar {
  display:      flex;
  align-items:  center;
  gap:          7px;
  padding:      6px 12px;
  border-bottom:1px solid var(--bdr);
  background:   var(--bg2);
  flex-shrink:  0;
  font-size:    12px;
}
.aca-ctx-label { flex: 1; font-weight: 600; color: var(--txt2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aca-ctx-tok   { font-size: 11px; color: var(--txt3); white-space: nowrap; flex-shrink: 0; }

.aca-match-btn {
  display:       flex;
  align-items:   center;
  gap:           5px;
  padding:       4px 11px;
  border-radius: 8px;
  background:    var(--acp);
  border:        none;
  color:         #fff;
  font-size:     11.5px;
  font-weight:   700;
  cursor:        pointer;
  flex-shrink:   0;
  transition:    background .15s, transform .1s;
  white-space:   nowrap;
}
.aca-match-btn svg { width: 12px; height: 12px; }
.aca-match-btn:hover  { background: var(--acp-dk); }
.aca-match-btn:active { transform: scale(.93); }
.aca-match-btn[hidden] { display: none !important; }

/* Weekly usage bar */
.aca-week-bar  { height: 3px; background: var(--bg3); flex-shrink: 0; }
.aca-week-fill { height: 100%; background: var(--acp); transition: width .4s; }

/* Message stream */
.aca-msgs {
  flex:        1;
  overflow-y:  auto;
  padding:     14px 12px;
  display:     flex;
  flex-direction: column;
  gap:         10px;
  min-height:  0;
  scroll-behavior: smooth;
}
.aca-msgs::-webkit-scrollbar { width: 4px; }
.aca-msgs::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.aca-msg {
  display:    flex;
  gap:        8px;
  align-items:flex-end;
  animation:  aca-msg-in .2s ease-out;
}
.aca-msg-user { flex-direction: row-reverse; }
@keyframes aca-msg-in { from{opacity:0;transform:translateY(5px)} to{opacity:1;transform:none} }

.aca-av {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--acp); color: #fff;
  font-size: 9.5px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.aca-msg-user .aca-av { background: var(--bg3); color: var(--txt2); }

.aca-bubble {
  max-width:     78%;
  padding:       9px 13px;
  border-radius: 16px 16px 16px 4px;
  background:    var(--bg3);
  color:         var(--txt);
  font-size:     13.5px;
  line-height:   1.6;
  word-break:    break-word;
}
.aca-msg-user .aca-bubble {
  background:    var(--acp);
  color:         #fff;
  border-radius: 16px 16px 4px 16px;
}

/* Markdown inside bubbles */
.aca-bubble p  { margin: 0 0 7px; }
.aca-bubble p:last-child { margin-bottom: 0; }
.aca-bubble strong { font-weight: 700; }
.aca-bubble em { font-style: italic; }
.aca-bubble h1,.aca-bubble h2,.aca-bubble h3 { font-size: 14px; font-weight: 800; margin: 10px 0 4px; }
.aca-bubble ul,.aca-bubble ol { padding-left: 18px; margin: 5px 0; }
.aca-bubble li { margin-bottom: 2px; }
.aca-bubble a  { color: var(--acp); text-decoration: underline; word-break: break-all; }
.aca-msg-user .aca-bubble a { color: rgba(255,255,255,.85); }
.aca-bubble hr { border: none; border-top: 1px solid var(--bdr); margin: 8px 0; }
.aca-bubble blockquote { border-left: 3px solid var(--bdr); padding-left: 9px; color: var(--txt2); margin: 5px 0; font-size: 12.5px; }
.aca-bubble code { background: rgba(0,0,0,.07); border-radius: 4px; padding: 1px 4px; font-size: 12px; }
.aca-bubble pre  { background: #1e293b; color: #e2e8f0; border-radius: 8px; padding: 10px; overflow-x: auto; font-size: 11.5px; margin: 7px 0; }

/* Token gate message */
.aca-tok-gate {
  display:       flex;
  gap:           10px;
  padding:       12px 14px;
  background:    #fff7ed;
  border:        1.5px solid #fed7aa;
  border-radius: 13px;
  animation:     aca-msg-in .2s ease-out;
}
.aca-tok-gate-ico  { font-size: 24px; flex-shrink: 0; }
.aca-tok-gate-body strong { display: block; font-size: 13px; font-weight: 700; color: #c2410c; margin-bottom: 3px; }
.aca-tok-gate-body p { font-size: 12.5px; color: #78350f; margin: 0 0 9px; line-height: 1.5; }
.aca-tok-gate-body a { color: inherit; text-decoration: underline; }
.aca-tok-btn { display: inline-block; padding: 6px 13px; border-radius: 7px; background: #ea580c; color: #fff !important; font-size: 12px; font-weight: 700; text-decoration: none !important; margin-right: 5px; transition: background .15s; }
.aca-tok-btn:hover { background: #c2410c; }
.aca-tok-btn-sec   { background: #fff3eb !important; color: #c2410c !important; border: 1.5px solid #fed7aa; }

/* Copy button */
.aca-copy-btn {
  display:       inline-flex;
  align-items:   center;
  gap:           4px;
  margin-top:    9px;
  padding:       5px 11px;
  border:        1.5px solid var(--acp);
  border-radius: 7px;
  background:    transparent;
  color:         var(--acp);
  font-size:     11.5px;
  font-weight:   600;
  cursor:        pointer;
  transition:    background .15s;
  font-family:   var(--font);
}
.aca-copy-btn:hover { background: color-mix(in srgb,var(--acp) 8%,#fff); }

/* Match results drawer */
.aca-drawer {
  border-top:  1px solid var(--bdr);
  background:  var(--bg2);
  max-height:  230px;
  overflow-y:  auto;
  flex-shrink: 0;
}
.aca-drawer[hidden] { display: none !important; }
.aca-drawer::-webkit-scrollbar { width: 4px; }
.aca-drawer::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.aca-drawer-hdr {
  display:        flex;
  align-items:    center;
  justify-content:space-between;
  padding:        7px 14px;
  font-size:      10.5px;
  font-weight:    800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color:          var(--txt2);
  border-bottom:  1px solid var(--bdr);
  background:     var(--bg2);
  position:       sticky;
  top:            0;
}
.aca-drawer-hdr button { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--txt3); }

.aca-match-row {
  display:        flex;
  align-items:    center;
  gap:            10px;
  padding:        9px 13px;
  border-bottom:  1px solid var(--bdr);
  text-decoration:none;
  color:          inherit;
  transition:     background .15s;
}
.aca-match-row:hover { background: color-mix(in srgb,var(--acp) 5%,#fff); }
.aca-score {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 800;
}
.s-hi  { background: #dcfce7; color: #166534; }
.s-mid { background: #fef9c3; color: #854d0e; }
.s-lo  { background: #fee2e2; color: #991b1b; }
.aca-mi { flex: 1; min-width: 0; }
.aca-mi-name { font-size: 12.5px; font-weight: 700; color: var(--acp); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aca-mi-meta { font-size: 11px; color: var(--txt2); margin-top: 1px; }
.aca-mi-why  { font-size: 10.5px; color: var(--txt3); font-style: italic; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Typing indicator */
.aca-typing {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px 8px; flex-shrink: 0;
}
.aca-typing[hidden] { display: none !important; }
.aca-dots {
  display: flex; gap: 4px; align-items: center;
  background: var(--bg3); padding: 9px 13px;
  border-radius: 16px 16px 16px 4px;
}
.aca-dots span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--txt3);
  animation: aca-bounce 1.4s infinite;
}
.aca-dots span:nth-child(2) { animation-delay: .18s; }
.aca-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes aca-bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-6px)} }

/* Input area */
.aca-input-wrap { border-top: 1px solid var(--bdr); padding: 9px 11px 7px; flex-shrink: 0; background: var(--bg); }
.aca-input-row  { display: flex; gap: 7px; align-items: flex-end; }
.aca-input {
  flex:          1;
  border:        1.5px solid var(--bdr);
  border-radius: 11px;
  padding:       8px 11px;
  font-size:     13.5px;
  resize:        none;
  outline:       none;
  line-height:   1.5;
  max-height:    96px;
  overflow-y:    auto;
  transition:    border-color .15s, box-shadow .15s;
  color:         var(--txt);
  background:    var(--bg2);
  font-family:   var(--font);
}
.aca-input:focus { border-color: var(--acp); background: var(--bg); box-shadow: 0 0 0 3px color-mix(in srgb,var(--acp) 12%,transparent); }
.aca-input::placeholder { color: var(--txt3); }
.aca-input:disabled { opacity: .5; cursor: not-allowed; }

.aca-btn-send {
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--acp); border: none; color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s, transform .1s;
}
.aca-btn-send svg { width: 17px; height: 17px; }
.aca-btn-send:hover:not(:disabled)  { background: var(--acp-dk); }
.aca-btn-send:active:not(:disabled) { transform: scale(.91); }
.aca-btn-send:disabled { opacity: .3; cursor: not-allowed; }

.aca-footer { font-size: 10px; color: var(--txt3); text-align: center; margin-top: 6px; }
.aca-footer a { color: var(--txt3); }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 480px) {
  #aca-widget.aca-bottom-right,
  #aca-widget.aca-bottom-left  { right: 10px; left: auto; bottom: 10px; }
  #aca-widget.aca-bottom-left  { left: 10px; right: auto; }
  .aca-panel { width: calc(100vw - 20px); max-height: 520px; }
  .aca-tiles { grid-template-columns: 1fr; }
  .aca-tile-hero, .aca-tile-accent { grid-column: span 1; }
}
