/* Redzone AI Chat. Loaded only on listings that have chat. Colours and sizes follow the Delta theme:
   red #FF3838, page #f7f8fb, cards with a 1px ring and 3px corners, navy #0b253b from the footer. */

/* ---- desktop layout on a listing with chat: wider sidebar, chat stays in view while the page scrolls ----
   The theme floats .item (65%) and .side (35%). Here the two become a grid, and the sidebar's own boxes are
   placed straight into the right column (display: contents on .side): the chat in the first row, which takes
   all the spare height and so gives the chat room to travel (sticky), and the theme's other sidebar boxes
   (location, owner tools, banners) in the rows under it, at the foot of the column. The chat therefore never
   slides over them, which it did while the whole sidebar was one tall box (fixed in 0.1.5). */
@media (min-width: 768px) {
  /* This file loads before the theme's own stylesheet, so a rule here loses to a theme rule of the same
     weight. The theme sets "#listing .item { width: 65% }"; ".inside" is added below to outweigh it. */
  #listing.inside { display: grid; grid-template-columns: minmax(0, 58fr) minmax(0, 42fr); grid-template-rows: 1fr; grid-auto-rows: auto; column-gap: 20px; align-items: start; }
  #listing.inside > .item { grid-column: 1; grid-row: 1 / span 12; float: none; width: auto; max-width: none; min-width: 0; margin-left: 0; margin-right: 0; }
  #listing.inside > .side { display: contents; }
  #listing.inside > .side > * { grid-column: 2; float: none; min-width: 0; }
  #listing.inside > .side > .rzai-box { grid-row: 1; align-self: start; }
}

/* ---- panel ---- */
#listing .side .rzai-box { padding: 0; overflow: hidden; border-top: 3px solid #FF3838; position: sticky; top: 12px; z-index: 2; }
.rzai-panel { display: flex; flex-direction: column; background: #fff; height: min(620px, calc(100vh - 40px)); min-height: 380px; position: relative; font-size: 14px; line-height: 1.45; color: #333; text-align: left; }
.rzai-panel *, .rzai-bar *, .rzai-teaser * { box-sizing: border-box; }
.rzai-panel [hidden], .rzai-bar[hidden] { display: none !important; }

.rzai-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 11px 12px 11px 14px; border-bottom: 1px solid rgba(0,0,0,.2); box-shadow: 0 1px 5px rgba(0,0,0,.15); position: relative; z-index: 3; background: #fff; }
.rzai-ava { position: relative; flex: none; width: 40px; height: 40px; border-radius: 50%; background: #e0e2e9; box-shadow: 0 0 0 1px rgba(0,0,0,.15); display: block; }
.rzai-ava img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; border-radius: 50%; }
/* "active now" dot on the avatar; gone while the chat is unavailable (.rzai-off is set by chat.js) */
.rzai-ava::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: #00c944; box-shadow: 0 0 0 2px #fff; }
.rzai-off .rzai-ava::after, .rzai-off-all .rzai-ava::after { display: none; }
.rzai-id { flex: 1; min-width: 0; }
.rzai-name { display: flex; align-items: center; gap: 7px; font-size: 16px; line-height: 19px; font-weight: 700; color: #111; }
.rzai-name > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rzai-tag { flex: none; font-size: 10px; line-height: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; background: #0b253b; color: #fff; border-radius: 2px; padding: 2px 5px; }
.rzai-sub { font-size: 12px; line-height: 16px; color: #777; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rzai-icon { flex: none; width: 34px; height: 34px; display: grid; place-items: center; background: none; border: 0; border-radius: 50%; color: #555; cursor: pointer; padding: 0; float: none; }
.rzai-icon:hover { background: #f0f2f7; color: #111; }
.rzai-back { display: none; }
.rzai-menu-wrap { position: relative; flex: none; }
.rzai-menu { position: absolute; right: 0; top: 38px; z-index: 5; min-width: 190px; background: #fff; border-radius: 4px; box-shadow: 0 0 0 1px rgba(0,0,0,.15), 0 8px 24px rgba(0,0,0,.18); padding: 4px; }
.rzai-menu button { display: block; width: 100%; float: none; background: none; border: 0; border-radius: 3px; padding: 8px 10px; font-size: 14px; line-height: 18px; color: #111; text-align: left; cursor: pointer; }
.rzai-menu button:hover:not(:disabled) { background: #f0f2f7; }
.rzai-menu button:disabled { color: #999; cursor: default; }
.rzai-menu button.rzai-danger:not(:disabled) { color: #b3261e; }

.rzai-ask { flex: none; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; background: #fff7e0; border-bottom: 1px solid #ecd9a0; padding: 9px 14px; font-size: 13px; line-height: 18px; color: #4d3a00; }
.rzai-ask .rzai-acts { display: flex; gap: 6px; }

.rzai-body { flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 14px; background: #f7f8fb; display: flex; flex-direction: column; gap: 9px; overscroll-behavior: contain; }
.rzai-disc { align-self: center; text-align: center; font-size: 11px; line-height: 15px; color: #666; }
.rzai-disc span { display: block; }
.rzai-disc a { color: #555; text-decoration: underline; }
.rzai-row { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rzai-row.rzai-ai { align-items: flex-start; }
.rzai-row.rzai-me { align-items: flex-end; }
.rzai-msg { max-width: 86%; padding: 9px 12px; border-radius: 13px; font-size: 14px; line-height: 20px; white-space: pre-wrap; overflow-wrap: anywhere; }
.rzai-ai .rzai-msg { background: #fff; color: #222; box-shadow: 0 0 0 1px rgba(0,0,0,.15); border-bottom-left-radius: 3px; }
.rzai-me .rzai-msg { background: #ffe4e4; color: #3d0c0c; border-bottom-right-radius: 3px; }
.rzai-at { font-size: 11px; line-height: 14px; color: #999; padding: 0 4px; }
.rzai-sys { align-self: stretch; display: flex; align-items: center; gap: 10px; font-size: 11px; line-height: 14px; color: #777; margin: 4px 0; }
.rzai-sys::before, .rzai-sys::after { content: ""; flex: 1; height: 1px; background: #dfe2ea; }
.rzai-typing { display: inline-flex; gap: 4px; align-items: center; padding: 13px 14px; }
.rzai-typing i { width: 6px; height: 6px; border-radius: 50%; background: #9aa0aa; animation: rzai-blink 1.2s infinite both; }
.rzai-typing i:nth-child(2) { animation-delay: .2s; }
.rzai-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes rzai-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }
.rzai-err { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; background: #fdecea; color: #5f1410; border-radius: 4px; padding: 9px 11px; font-size: 13px; line-height: 18px; }
.rzai-err > div { flex: 1 1 180px; min-width: 0; }
.rzai-flash { align-self: center; background: #e9f6ee; color: #17753a; border-radius: 12px; padding: 3px 10px; font-size: 12px; }
.rzai-note { flex: none; border-top: 1px solid #e3e5ea; padding: 14px; font-size: 13px; line-height: 19px; color: #555; background: #fff; }
.rzai-skel { height: 38px; border-radius: 13px; background: #e4e7ee; width: 62%; }
.rzai-skel.rzai-r { align-self: flex-end; width: 44%; background: #f8dede; }
.rzai-wait { margin: 0 0 4px; display: flex; gap: 8px; align-items: center; justify-content: center; font-size: 12px; color: #777; }

.rzai-foot { flex: none; border-top: 1px solid #e3e5ea; background: #fff; padding: 10px 12px 9px; }
.rzai-form { display: flex; gap: 8px; margin: 0; }
.rzai-form .rzai-input { flex: 1; min-width: 0; float: none; width: auto; height: 40px; border: 1px solid #ddd; border-radius: 3px; padding: 9px 12px; font-family: inherit; font-size: 14px; line-height: 20px; color: #111; background: #fff; box-shadow: none; margin: 0; }
.rzai-form .rzai-input:hover { border-color: #999; }
.rzai-form .rzai-input:focus { border-color: #FF3838; outline: none; }
.rzai-send { flex: none; float: none; width: 44px; height: 40px; border: 0; border-radius: 3px; background: #FF3838; color: #fff; display: grid; place-items: center; cursor: pointer; padding: 0; }
.rzai-send:hover:not(:disabled) { background: #e62a2a; }
.rzai-send:disabled { opacity: .45; cursor: default; }
.rzai-meta { margin-top: 7px; font-size: 11.5px; line-height: 15px; color: #777; }
.rzai-allow.rzai-last { color: #9a5b00; font-weight: 600; }
.rzai-spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: rzai-spin .8s linear infinite; }
.rzai-spin.rzai-dk { border-color: rgba(0,0,0,.15); border-top-color: #666; }
@keyframes rzai-spin { to { transform: rotate(360deg); } }

/* ---- buttons ---- */
.rzai-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; float: none; background: #FF3838; color: #fff; border: 1px solid rgba(0,0,0,.05); border-radius: 3px; padding: 8px 12px; font-size: 14px; line-height: 18px; font-weight: 600; text-align: center; text-decoration: none; cursor: pointer; }
.rzai-btn:hover { background: #e62a2a; color: #fff; text-decoration: none; }
.rzai-btn.rzai-ghost { background: #fff; color: #111; border: 1px solid rgba(0,0,0,.3); }
.rzai-btn.rzai-ghost:hover { background: #f7f8fb; color: #111; }
.rzai-btn.rzai-sm { padding: 5px 10px; font-size: 13px; }
.rzai-btn.rzai-wide { width: 100%; }

/* ---- gates: register prompt and daily limit ---- */
.rzai-gate { flex: none; max-height: 66%; overflow-y: auto; border-top: 1px solid #e3e5ea; background: #fff; padding: 14px 14px 12px; }
.rzai-gate h3 { font-family: 'Lora', Georgia, serif; font-size: 19px; line-height: 24px; font-weight: 700; color: #111; margin: 0 0 6px; }
.rzai-gate p { font-size: 13px; line-height: 19px; color: #444; margin: 0 0 12px; }
.rzai-gate .rzai-acts { display: flex; gap: 8px; }
.rzai-gate .rzai-acts .rzai-btn { flex: 1; }
.rzai-small { font-size: 11.5px; line-height: 16px; color: #777; margin-top: 8px; }
.rzai-soon { border: 1px dashed #c5cad6; border-radius: 4px; padding: 10px; margin: 0 0 10px; background: #f7f8fb; }
.rzai-soon-h { font-size: 13px; font-weight: 600; color: #111; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.rzai-soon-h em { font-style: normal; font-weight: 400; color: #777; }
.rzai-soon-tag { font-size: 10px; line-height: 12px; letter-spacing: .05em; text-transform: uppercase; font-weight: 600; background: #e0e2e9; color: #444; border-radius: 2px; padding: 2px 5px; }
.rzai-pkgs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.rzai-pkg { display: flex; flex-direction: column; align-items: center; float: none; background: #fff; border: 1px solid #ddd; border-radius: 3px; padding: 7px 4px; color: #333; line-height: 16px; cursor: pointer; }
.rzai-pkg b { font-size: 16px; line-height: 20px; color: #111; }
.rzai-pkg span { font-size: 11px; color: #777; }
.rzai-pkg i { font-style: normal; font-size: 12.5px; font-weight: 500; margin-top: 3px; }
.rzai-pkg.rzai-on { border-color: #0b253b; box-shadow: inset 0 0 0 1px #0b253b; }
.rzai-pkg:disabled { cursor: default; }
.rzai-done { background: #e9f6ee; color: #17753a; border-radius: 3px; padding: 9px 11px; font-size: 13px; line-height: 18px; }

/* ---- listing page additions ---- */
#listing .main-data::before { content: "AI"; position: absolute; left: 10px; top: 10px; z-index: 4; padding: 3px 7px; font-size: 12px; line-height: 14px; font-weight: 500; color: #fff; background: #0b253b; border-radius: 2px; box-shadow: 0 1px 3px rgba(0,0,0,.15); pointer-events: none; }
.rzai-about { clear: both; float: left; width: 100%; margin: 6px 0 14px; padding-top: 18px; border-top: 1px solid #ddd; }
/* The theme floats every heading inside a listing at full width (#listing .item h2) and restyles headings in
   #plugin-hook. A grid next to a full-width float is squeezed into the zero width beside it, so the heading
   is taken out of the float here and the list is told to start under it at full width. */
.rzai-about h2, #listing .item #plugin-hook .rzai-about h2 { float: none; clear: none; width: auto; padding: 0; font-size: 18px; line-height: 22px; font-weight: 700; color: #111; margin: 0 0 10px; text-align: left; }
.rzai-attrs { clear: both; width: 100%; box-sizing: border-box; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 24px; margin: 0 0 12px; padding: 0; }
.rzai-attrs div { display: flex; gap: 8px; font-size: 14px; line-height: 20px; min-width: 0; }
.rzai-attrs .rzai-wide { grid-column: 1 / -1; }
.rzai-attrs dt { color: #777; flex: 0 0 84px; font-weight: 400; }
.rzai-attrs dd { margin: 0; color: #111; font-weight: 500; min-width: 0; }
.rzai-fine { clear: both; margin: 0; font-size: 12px; line-height: 17px; color: #666; }
.rzai-facts { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; clear: both; float: left; width: 100%; }
.rzai-facts span { font-size: 13px; line-height: 18px; font-weight: 500; color: #111; background: #f0f2f7; border-radius: 3px; padding: 3px 9px; }

/* ---- phone entry points (hidden on desktop) ---- */
.rzai-bar, .rzai-teaser { display: none; }
.rzai-float { display: none; }

/* The panel as a full-screen overlay: phones always, and any width when the theme's sidebar line is missing. */
html.rzai-open, html.rzai-open body { overflow: hidden; }
.rzai-bar[data-always="1"] { display: flex; }
html.rzai-open .rzai-float { display: block; position: fixed; inset: 0; z-index: 990; background: #fff; }
html.rzai-open .rzai-float .rzai-panel { height: 100%; }
html.rzai-open .rzai-float .rzai-back { display: grid; }

.rzai-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 90; align-items: center; gap: 10px; background: #fff; border-top: 1px solid rgba(0,0,0,.15); box-shadow: 0 -2px 10px rgba(0,0,0,.1); padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)); font-size: 12px; line-height: 16px; color: #777; text-align: left; }
.rzai-bar .rzai-ava { width: 34px; height: 34px; }
.rzai-bar-t { flex: 1; min-width: 0; }
.rzai-bar-t b { font-size: 14px; color: #111; margin-right: 6px; }
.rzai-bar-s { display: block; }
html.rzai-open .rzai-bar { display: none !important; }

@media (max-width: 767px) {
  #listing .side .rzai-box { position: static; border-top: 0; margin: 0; box-shadow: none; display: none; }
  html.rzai-open #listing .side .rzai-box { display: block; position: fixed; inset: 0; z-index: 990; background: #fff; }
  html.rzai-open .rzai-panel { height: 100%; min-height: 0; }
  html.rzai-open .rzai-back { display: grid; }
  .rzai-form .rzai-input { font-size: 16px; }   /* stops phone browsers from zooming the page on focus */
  .rzai-bar { display: flex; }
  .rzai-teaser { display: flex; flex-direction: column; gap: 10px; clear: both; float: left; width: 100%; background: #fff; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0,0,0,.15); border-top: 3px solid #FF3838; padding: 12px; margin: 0 0 14px; }
  .rzai-teaser-head { display: flex; gap: 10px; align-items: center; }
  .rzai-teaser .rzai-msg { max-width: 100%; align-self: flex-start; background: #f7f8fb; color: #222; box-shadow: none; border-radius: 13px; border-bottom-left-radius: 3px; }
  .rzai-attrs { grid-template-columns: minmax(0, 1fr); }
  body.rzai-has-bar { padding-bottom: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  .rzai-typing i, .rzai-spin { animation: none; }
}
