/* Film-World AI assistant - floating chat widget */
.fw-chat-fab{
  position:fixed;right:1.15rem;bottom:5.75rem;z-index:9998;   /* sits above the corner signature */
  width:3.5rem;height:3.5rem;border-radius:50%;border:0;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  background:linear-gradient(135deg,#e50914,#b20710);color:#fff;
  box-shadow:0 12px 34px -10px rgba(229,9,20,.7);
  transition:transform .16s ease,box-shadow .16s ease;
}
.fw-chat-fab:hover{transform:translateY(-2px) scale(1.04)}
.fw-chat-fab svg{width:1.6rem;height:1.6rem}
.fw-chat-fab[hidden]{display:none}

.fw-chat-panel{
  position:fixed;right:1.15rem;bottom:1.15rem;z-index:9999;
  width:min(410px,calc(100vw - 2rem));
  height:min(760px,calc(100vh - 2.4rem));
  display:flex;flex-direction:column;overflow:hidden;
  background:#14141b;color:#f4f4f5;border:1px solid rgba(255,255,255,.12);
  border-radius:1rem;box-shadow:0 30px 70px -20px rgba(0,0,0,.7);
  transform:translateY(12px) scale(.98);opacity:0;pointer-events:none;
  transition:transform .18s ease,opacity .18s ease;
}
@supports (height:100dvh){
  .fw-chat-panel{height:min(760px,calc(100dvh - 2.4rem))}
}
.fw-chat-panel.is-open{transform:none;opacity:1;pointer-events:auto}

.fw-chat-head{display:flex;align-items:center;gap:.5rem;padding:.75rem .8rem .75rem 1rem;background:rgba(229,9,20,.12);border-bottom:1px solid rgba(255,255,255,.1)}
.fw-chat-head strong{font-size:.95rem;flex:1;min-width:0}
.fw-chat-head .fw-chat-sub{font-size:.7rem;opacity:.62;display:block;font-weight:400;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.fw-chat-head-actions{display:flex;align-items:center;gap:.15rem;flex:0 0 auto}
.fw-chat-ico{background:none;border:0;color:inherit;cursor:pointer;opacity:.72;padding:.35rem;border-radius:.5rem;display:inline-flex;transition:opacity .15s,background .15s}
.fw-chat-ico:hover{opacity:1;background:rgba(255,255,255,.12)}

/* history overlay */
.fw-chat-history{position:absolute;inset:0;top:0;z-index:3;display:none;flex-direction:column;background:inherit;border-radius:1rem;overflow:hidden}
.fw-chat-panel.show-history .fw-chat-history{display:flex}
.fw-chat-hist-head{display:flex;align-items:center;gap:.5rem;padding:.85rem 1rem;background:rgba(229,9,20,.12);border-bottom:1px solid rgba(255,255,255,.1)}
.fw-chat-hist-head strong{font-size:.95rem}
.fw-chat-hist-back{background:none;border:0;color:inherit;cursor:pointer;font-size:.9rem;font-weight:600;opacity:.85;padding:.1rem .3rem}
.fw-chat-hist-back:hover{opacity:1}
.fw-chat-hist-list{flex:1;overflow-y:auto;padding:.5rem}
.fw-chat-hist-empty{opacity:.6;font-size:.85rem;text-align:center;padding:2rem 1rem}
.fw-chat-hist-row{display:flex;align-items:stretch;gap:.25rem;border-radius:.6rem;margin-bottom:.25rem}
.fw-chat-hist-row:hover{background:rgba(255,255,255,.05)}
.fw-chat-hist-row.is-active{background:rgba(229,9,20,.14)}
.fw-chat-hist-open{flex:1;min-width:0;background:none;border:0;color:inherit;text-align:left;cursor:pointer;padding:.55rem .65rem;display:flex;flex-direction:column;gap:.15rem}
.fw-chat-hist-title{font-size:.86rem;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.fw-chat-hist-meta{font-size:.7rem;opacity:.55}
.fw-chat-hist-del{background:none;border:0;color:inherit;opacity:.4;cursor:pointer;font-size:1.1rem;line-height:1;padding:0 .55rem;border-radius:.5rem}
.fw-chat-hist-del:hover{opacity:1;background:rgba(229,9,20,.25);color:#fff}

.fw-chat-log{flex:1;overflow-y:auto;padding:1rem;display:flex;flex-direction:column;gap:.7rem}
.fw-chat-msg{max-width:88%;padding:.6rem .8rem;border-radius:.85rem;font-size:.9rem;line-height:1.45;white-space:pre-wrap;word-wrap:break-word}
.fw-chat-msg.user{align-self:flex-end;background:#e50914;color:#fff;border-bottom-right-radius:.25rem}
.fw-chat-msg.bot{align-self:flex-start;background:rgba(255,255,255,.07);border:1px solid rgba(255,255,255,.09);border-bottom-left-radius:.25rem}
.fw-chat-msg.bot strong{color:#fff}
.fw-chat-msg.bot ul{margin:.3rem 0 .1rem;padding-left:1.1rem}
.fw-chat-msg.error{align-self:flex-start;background:rgba(229,9,20,.14);border:1px solid rgba(229,9,20,.4)}
.fw-chat-typing{align-self:flex-start;opacity:.6;font-size:.85rem;padding:.3rem .2rem}

/* result list - poster thumbnail + title + Watch cta, whole row is a link */
.fw-chat-results{align-self:stretch;display:flex;flex-direction:column;gap:.4rem;margin:.1rem 0}
.fw-chat-result{
  display:flex;align-items:center;gap:.6rem;text-decoration:none;color:inherit;
  background:rgba(255,255,255,.05);border:1px solid rgba(255,255,255,.1);
  border-radius:.7rem;padding:.4rem .5rem;transition:background .15s,border-color .15s}
.fw-chat-result:hover{background:rgba(229,9,20,.16);border-color:rgba(229,9,20,.45)}
.fw-chat-thumb{flex:0 0 auto;width:44px;height:62px;border-radius:.4rem;object-fit:cover;
  background:rgba(255,255,255,.08);display:block}
.fw-chat-thumb-ph{display:flex;align-items:center;justify-content:center;
  font-size:.82rem;font-weight:800;letter-spacing:.02em;
  background:linear-gradient(135deg,rgba(229,9,20,.35),rgba(255,255,255,.06));color:#fff}
.fw-chat-result-body{flex:1;min-width:0;display:flex;flex-direction:column;gap:.15rem}
.fw-chat-result-title{font-size:.86rem;font-weight:700;line-height:1.25;
  overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
.fw-chat-result-meta{font-size:.7rem;opacity:.6}
.fw-chat-result-cta{flex:0 0 auto;display:inline-flex;align-items:center;gap:.25rem;
  font-size:.74rem;font-weight:800;color:#fff;background:#e50914;
  padding:.34rem .6rem;border-radius:.5rem;white-space:nowrap}
.fw-chat-result:hover .fw-chat-result-cta{background:#ff2a34}

.fw-chat-form{display:flex;gap:.5rem;padding:.75rem;border-top:1px solid rgba(255,255,255,.1);background:rgba(255,255,255,.02)}
.fw-chat-form input{flex:1;background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.12);border-radius:.65rem;color:#f4f4f5;padding:.55rem .7rem;font-size:.9rem;outline:none}
.fw-chat-form input:focus{border-color:rgba(229,9,20,.6)}
.fw-chat-form button{background:#e50914;border:0;color:#fff;border-radius:.65rem;width:2.6rem;flex:0 0 2.6rem;display:inline-flex;align-items:center;justify-content:center;cursor:pointer}
.fw-chat-form button:hover:not(:disabled){background:#c40810}
.fw-chat-form button:disabled{opacity:.45;cursor:not-allowed}

@media (prefers-color-scheme:light){
  :root:not([data-theme="dark"]) .fw-chat-panel{background:#fff;color:#171717;border-color:rgba(32,24,18,.14)}
  :root:not([data-theme="dark"]) .fw-chat-msg.bot{background:rgba(32,24,18,.05);border-color:rgba(32,24,18,.1)}
  :root:not([data-theme="dark"]) .fw-chat-form input{background:rgba(32,24,18,.04);border-color:rgba(32,24,18,.16);color:#171717}
}
:root[data-theme="light"] .fw-chat-panel{background:#fff;color:#171717;border-color:rgba(32,24,18,.14)}
:root[data-theme="light"] .fw-chat-msg.bot{background:rgba(32,24,18,.05);border-color:rgba(32,24,18,.1)}
:root[data-theme="light"] .fw-chat-form input{background:rgba(32,24,18,.04);border-color:rgba(32,24,18,.16);color:#171717}
:root[data-theme="light"] .fw-chat-ico:hover,:root[data-theme="light"] .fw-chat-hist-row:hover{background:rgba(32,24,18,.07)}
:root[data-theme="light"] .fw-chat-result{background:rgba(32,24,18,.04);border-color:rgba(32,24,18,.12)}
:root[data-theme="light"] .fw-chat-result:hover{background:rgba(229,9,20,.1);border-color:rgba(229,9,20,.4)}
:root[data-theme="light"] .fw-chat-result-title{color:#171717}
@media (prefers-color-scheme:light){
  :root:not([data-theme="dark"]) .fw-chat-result{background:rgba(32,24,18,.04);border-color:rgba(32,24,18,.12)}
  :root:not([data-theme="dark"]) .fw-chat-result:hover{background:rgba(229,9,20,.1);border-color:rgba(229,9,20,.4)}
  :root:not([data-theme="dark"]) .fw-chat-result-title{color:#171717}
}
@media (prefers-color-scheme:light){
  :root:not([data-theme="dark"]) .fw-chat-ico:hover,:root:not([data-theme="dark"]) .fw-chat-hist-row:hover{background:rgba(32,24,18,.07)}
}

body.native-app-runtime .fw-chat-fab,body.mobile-app-shell .fw-chat-fab{right:1rem;bottom:8.5rem}

/* ── Mobile app shell: panel lives fully above the bottom nav ── */
@media (max-width:900px),(hover:none) and (pointer:coarse){
  body.mobile-app-shell .fw-chat-panel,
  html.mobile-app-shell .fw-chat-panel{
    z-index:2147483001; /* above the bottom nav + catalog switch */
    left:.6rem;right:.6rem;top:.6rem;
    bottom:calc(var(--mobile-bottom-nav-h,84px) + var(--mobile-bottom-nav-gap,14px) + env(safe-area-inset-bottom,0px) + .7rem);
    width:auto;height:auto;
    border-radius:1.1rem;
  }
  body.mobile-app-shell .fw-chat-head{padding:.7rem .6rem .7rem .9rem}
  body.mobile-app-shell .fw-chat-head strong{font-size:.9rem}
  body.mobile-app-shell .fw-chat-form{padding:.6rem}
  body.mobile-app-shell .fw-chat-form input{font-size:16px} /* prevents iOS zoom-on-focus */

  /* Hide the floating catalog pill while the chat is open */
  body.mobile-app-shell.fw-chat-open .mobile-catalog-switch{
    opacity:0;
    pointer-events:none;
    transform:translate3d(-50%,-160%,0);
  }

  /* Keep the chat FAB clear of the bottom nav */
  body.mobile-app-shell .fw-chat-fab{
    right:.9rem;
    bottom:calc(var(--mobile-bottom-nav-h,84px) + var(--mobile-bottom-nav-gap,14px) + env(safe-area-inset-bottom,0px) + .9rem);
  }
}

/* Clear the mobile bottom nav + signature. */
@media (max-width:760px){
  .fw-chat-fab{right:.9rem;width:3.1rem;height:3.1rem}
  .fw-chat-fab svg{width:1.4rem;height:1.4rem}
  .fw-chat-panel{
    left:.5rem;right:.5rem;top:.5rem;
    bottom:calc(4.75rem + env(safe-area-inset-bottom, 0px)); /* clear the mobile bottom nav */
    width:auto;height:auto;
  }
  .fw-chat-head{padding:.7rem .6rem .7rem .9rem}
  .fw-chat-head strong{font-size:.9rem}
}
