
.bbz-aiw-wrap{--bbzPrimary:#18a6d6;--bbzAccent:#0e7fa6;max-width:1100px;margin:20px auto;border:1px solid rgba(0,0,0,.08);border-radius:16px;overflow:hidden;background:#fff;box-shadow:0 10px 30px rgba(0,0,0,.06)}
.bbz-aiw-header{padding:16px 18px;background:linear-gradient(90deg,var(--bbzPrimary),var(--bbzAccent));color:#fff}
.bbz-aiw-title{font-size:20px;font-weight:700}
.bbz-aiw-sub{font-size:13px;opacity:.9;margin-top:3px}
.bbz-aiw-tabs{display:flex;gap:8px;padding:10px;background:#f6fbfd;border-bottom:1px solid rgba(0,0,0,.06)}
.bbz-aiw-tab{border:1px solid rgba(0,0,0,.10);background:#fff;border-radius:999px;padding:8px 14px;font-weight:600;cursor:pointer}
.bbz-aiw-tab.is-active{background:var(--bbzPrimary);border-color:var(--bbzPrimary);color:#fff}
.bbz-aiw-body{display:grid;grid-template-columns:340px 1fr;min-height:560px;max-height:80vh}
.bbz-aiw-chat{min-height:0}
.bbz-aiw-thread{min-height:0}
@media(max-width:900px){.bbz-aiw-body{grid-template-columns:1fr}.bbz-aiw-sidebar{border-right:none;border-bottom:1px solid rgba(0,0,0,.06)}}
.bbz-aiw-sidebar{border-right:1px solid rgba(0,0,0,.06);background:#fff}
.bbz-aiw-search{padding:12px;border-bottom:1px solid rgba(0,0,0,.06)}
.bbz-aiw-search-input{width:100%;padding:10px 12px;border:1px solid rgba(0,0,0,.12);border-radius:12px;outline:none}
.bbz-aiw-list{max-height:470px;overflow:auto}
.bbz-aiw-item{width:100%;text-align:left;padding:12px 14px;border:0;background:#fff;border-bottom:1px solid rgba(0,0,0,.05);cursor:pointer}
.bbz-aiw-item:hover{background:#f6fbfd}
.bbz-aiw-item.is-active{background:rgba(24,166,214,.12)}
.bbz-aiw-item-name{font-weight:700}
.bbz-aiw-item-sub{font-size:12px;opacity:.7;margin-top:2px}
.bbz-aiw-empty{padding:16px;color:#666}
.is-hidden{display:none}
.bbz-aiw-chat{display:flex;flex-direction:column;background:#f2f7f9}
.bbz-aiw-chat-header{padding:14px 16px;border-bottom:1px solid rgba(0,0,0,.06);background:#fff}
.bbz-aiw-chat-name{font-weight:800}
.bbz-aiw-chat-meta{font-size:12px;opacity:.65;margin-top:2px}
.bbz-aiw-thread{padding:14px 16px;overflow:auto;flex:1}
.bbz-aiw-thread-empty{padding:18px;background:#fff;border-radius:14px;opacity:.7}
.bbz-aiw-bubble{max-width:84%;margin:10px 0 10px auto;background:#dff7e8;border-radius:16px 16px 6px 16px;padding:10px 12px;position:relative}
.bbz-aiw-bubble-title{font-weight:800;margin-bottom:4px}
.bbz-aiw-bubble-meta{font-size:11px;opacity:.65;margin-top:6px;display:flex;justify-content:space-between;gap:10px}
.bbz-aiw-del{border:0;background:transparent;color:#c0392b;cursor:pointer;font-weight:800}
.bbz-aiw-composer{padding:12px;border-top:1px solid rgba(0,0,0,.06);background:#fff}
.bbz-aiw-row{display:flex;gap:10px;margin-bottom:10px}
.bbz-aiw-input,.bbz-aiw-select,.bbz-aiw-textarea{width:100%;border:1px solid rgba(0,0,0,.12);border-radius:12px;padding:10px 12px;outline:none}
.bbz-aiw-select{max-width:160px}
.bbz-aiw-textarea{min-height:90px;resize:vertical}
.bbz-aiw-row-actions{justify-content:space-between;align-items:center}
.bbz-aiw-btn{background:var(--bbzPrimary);border:1px solid var(--bbzPrimary);color:#fff;border-radius:12px;padding:10px 16px;font-weight:800;cursor:pointer}
.bbz-aiw-btn-ghost{background:#fff;color:var(--bbzPrimary)}
.bbz-aiw-hint{font-size:12px;opacity:.65;margin-top:4px}
/* Mobile WhatsApp-like single chat view */
.bbz-aiw-back{display:none;border:0;background:transparent;color:var(--bbzPrimary);font-size:18px;font-weight:900;cursor:pointer;padding:6px 10px;border-radius:10px}
.bbz-aiw-chat-headtext{display:flex;flex-direction:column}
@media(max-width:900px){
  .bbz-aiw-wrap{height:calc(100dvh - var(--bbz-aiw-safe-top) - var(--bbz-aiw-safe-bottom));height:calc(100vh - var(--bbz-aiw-safe-top) - var(--bbz-aiw-safe-bottom));max-height:none}
  .bbz-aiw-body{grid-template-columns:1fr;position:relative;height:100%;max-height:none;min-height:0}
  .bbz-aiw-sidebar{display:block}
  .bbz-aiw-chat{display:none}
  .bbz-aiw-wrap.is-chat-open .bbz-aiw-sidebar{display:none}
  .bbz-aiw-wrap.is-chat-open .bbz-aiw-chat{display:flex}
  .bbz-aiw-back{display:inline-flex;align-items:center;justify-content:center;margin-right:8px}
  .bbz-aiw-chat-header{display:flex;align-items:flex-start;gap:8px}
}

.bbz-aiw-notice{margin:12px 16px;padding:10px 12px;border-radius:12px;font-weight:700}
.bbz-aiw-notice.is-ok{background:rgba(34,197,94,.12)}
.bbz-aiw-notice.is-err{background:rgba(239,68,68,.12)}
/* Receiver message sender line */
.bbz-sender-line{display:flex;align-items:center;gap:10px;margin-bottom:8px}
.bbz-sender-avatar{width:34px;height:34px;border-radius:50%}
.bbz-sender-name{font-weight:800}

/* ===== v2.0.3 Mobile layout fixes ===== */
.bbz-aiw-wrap{position:relative;max-width:100%;}
/* Avoid being hidden behind theme header/footer. You can adjust with CSS vars if needed. */
:root{--bbz-aiw-safe-top: 90px; --bbz-aiw-safe-bottom: calc(120px + env(safe-area-inset-bottom)); --bbz-aiw-bottom-menu: 96px;}
@media (min-width: 768px){:root{--bbz-aiw-safe-top: 60px; --bbz-aiw-safe-bottom: 40px;}}

/* Keep tabs + search always visible */
.bbz-aiw-head{position:sticky;top:0;z-index:50;background:var(--bbzPrimary,#0aa0d6);}
.bbz-aiw-tabs{position:sticky;top:0;z-index:60;background:rgba(255,255,255,.95);backdrop-filter:saturate(120%) blur(6px);}

/* Make the component flow with page, not full-screen fixed. Provide internal scroll areas. */
.bbz-aiw-body{display:flex;gap:0;min-height:520px;max-height:calc(100vh - var(--bbz-aiw-safe-top) - var(--bbz-aiw-safe-bottom));overflow:hidden;border-radius:18px;}
.bbz-aiw-pane{flex:1;min-width:0;overflow:hidden;display:flex;flex-direction:column;}
.bbz-aiw-list-wrap{overflow:auto;-webkit-overflow-scrolling:touch;padding-bottom:18px;}
.bbz-aiw-thread-wrap{flex:1;overflow:auto;-webkit-overflow-scrolling:touch;padding-bottom:18px;scroll-behavior:smooth;}

/* Composer stays visible and does not get covered by theme footer */
.bbz-aiw-composer{position:sticky;bottom:0;z-index:40;background:rgba(255,255,255,.96);backdrop-filter:saturate(120%) blur(6px);padding-bottom: max(16px, env(safe-area-inset-bottom));}

/* ===== Composer compact (WhatsApp-like) ===== */
.bbz-aiw-options{margin:0 0 8px;}
.bbz-aiw-options-summary{font-weight:800;cursor:pointer;list-style:none;}
.bbz-aiw-options-summary::-webkit-details-marker{display:none;}
.bbz-aiw-compose-row{display:flex;gap:10px;padding:10px 0 6px;}
.bbz-aiw-compose-row input{flex:1;min-width:0;border:1px solid rgba(0,0,0,.12);border-radius:12px;padding:10px 12px;outline:none;}
.bbz-aiw-compose-row select{width:140px;max-width:140px;border:1px solid rgba(0,0,0,.12);border-radius:12px;padding:10px 12px;outline:none;background:#fff;}

.bbz-aiw-inputbar{position:relative;display:flex;align-items:flex-end;gap:8px;}
.bbz-aiw-inputbar textarea{width:100%;border:1px solid rgba(0,0,0,.12);border-radius:14px;padding:12px 54px 12px 12px;outline:none;min-height:56px;max-height:140px;resize:vertical;}
.bbz-aiw-refresh{flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;border-radius:999px;border:1px solid rgba(0,0,0,.12);text-decoration:none;background:#fff;color:var(--bbzPrimary);font-weight:900;}
#bbz-aiw-send{position:absolute;right:8px;bottom:8px;width:44px;height:44px;border-radius:999px;border:1px solid var(--bbzPrimary);background:var(--bbzPrimary);color:#fff;font-weight:900;cursor:pointer;}
.bbz-aiw-help{margin-top:8px;font-size:12px;opacity:.65;}

/* Mobile: lift composer above the site's fixed bottom menu (WhatsApp-style) */
@media (max-width: 900px){
  .bbz-aiw-wrap.is-chat-open .bbz-aiw-composer{
    position:fixed;
    left:50%;
    transform:translateX(-50%);
    width:min(1100px, 100%);
    bottom:calc(var(--bbz-aiw-bottom-menu) + env(safe-area-inset-bottom));
    border-top:1px solid rgba(0,0,0,.06);
    border-radius:16px 16px 0 0;
  }
  .bbz-aiw-wrap.is-chat-open .bbz-aiw-thread-wrap{
    padding-bottom:calc(var(--bbz-aiw-bottom-menu) + 140px);
  }

  /* WhatsApp-like: in chat view, hide global tabs to save vertical space */
  .bbz-aiw-wrap.is-chat-open .bbz-aiw-tabs{display:none;}

  /* Sticky receiver header */
  .bbz-aiw-wrap.is-chat-open .bbz-aiw-chat-header{position:sticky;top:0;z-index:70;}

  /* Keep composer compact on mobile */
  .bbz-aiw-options{margin:0 0 6px;}
  .bbz-aiw-help{display:none;}
}

/* Ensure search input is not hidden */
.bbz-aiw-search{position:sticky;top:0;z-index:55;background:rgba(255,255,255,.96);padding:10px 12px;border-bottom:1px solid rgba(0,0,0,.06);}

/* Better spacing so site footer doesn't overlap last bubbles */
.bbz-aiw-thread-wrap::after{content:"";display:block;height:var(--bbz-aiw-safe-bottom);}
.bbz-aiw-list-wrap::after{content:"";display:block;height:40px;}

/* Reduce huge padding from theme */
.bbz-aiw-wrap *{box-sizing:border-box;}
