/* assets/widget.css */
/* Any element that uses the `hidden` attribute AND has an author CSS rule
   setting its own `display` value loses the browser's native hiding
   behavior -- the UA stylesheet's `[hidden]{display:none}` is an
   attribute selector (low specificity), so an ID rule like
   `#aichat-panel{display:flex}` below wins and the element stays
   visually shown even while `element.hidden` is `true`. This one
   `!important` rule restores `hidden` as the final word regardless of
   what any other rule in this file sets. */
[hidden] { display: none !important; }

/* Brand color: set per project via the `aichat_brand_color` filter (see
   README.md), which inlines a `:root{--aichat-brand:...}` rule ahead of
   this stylesheet. The var()'s own fallback below means the widget still
   renders with a sane default blue if no project override exists yet. */
#aichat-widget { position: fixed; bottom: 20px; right: 20px; z-index: 99999; font-family: sans-serif; }

/* Avatar: a project supplies its own image via the `aichat_avatar_url`
   filter; until then, #aichat-avatar-fallback (a plain monogram circle,
   see includes/widget-markup.php) stands in so nothing ever shows a
   broken image. object-fit:cover + border-radius:50% on a supplied
   <img> crops it to a clean circle regardless of its own aspect ratio. */
#aichat-bubble { position: relative; width: 56px; height: 56px; border-radius: 50%; border: none; background: var(--aichat-brand, #2563eb); cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.2); padding: 0; overflow: visible; display: flex; align-items: center; justify-content: center; }
#aichat-bubble img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.aichat-avatar-fallback { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; border-radius: 50%; background: rgba(255,255,255,.2); color: #fff; font-weight: 700; text-transform: uppercase; }
#aichat-header-avatar.aichat-avatar-fallback { width: 28px; height: 28px; font-size: 13px; background: rgba(255,255,255,.25); flex-shrink: 0; }

/* Launcher reads as active/online, not a static icon -- a small pulsing
   green dot, same pattern as an "online now" indicator elsewhere on the
   web. Purely decorative; always-on (see class-persona.php's docblock --
   the AI itself never goes offline, so this never needs to reflect real
   agent availability). */
#aichat-bubble-badge { position: absolute; top: -2px; right: -2px; width: 14px; height: 14px; border-radius: 50%; background: #2ecc71; border: 2px solid #fff; box-shadow: 0 0 0 0 rgba(46,204,113,.6); animation: aichat-badge-pulse 2s infinite; }
@keyframes aichat-badge-pulse { 0% { box-shadow: 0 0 0 0 rgba(46,204,113,.6); } 70% { box-shadow: 0 0 0 8px rgba(46,204,113,0); } 100% { box-shadow: 0 0 0 0 rgba(46,204,113,0); } }

/* Teaser: a passive invite-to-chat bubble next to the launcher, separate
   from the full panel -- auto-pops a few seconds after page load (see
   widget.js), dismissible, never fights with the in-panel greeting. */
#aichat-teaser { position: fixed; bottom: 90px; right: 20px; max-width: 220px; background: #fff; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.2); padding: 12px 28px 12px 14px; font-size: 13px; line-height: 1.4; color: #333; cursor: pointer; }
#aichat-teaser p { margin: 0; }
#aichat-teaser-close { position: absolute; top: 4px; right: 6px; border: none; background: none; font-size: 16px; line-height: 1; color: #999; cursor: pointer; padding: 2px; }

#aichat-panel { position: fixed; bottom: 90px; right: 20px; width: 380px; max-width: calc(100vw - 40px); height: 600px; max-height: calc(100vh - 110px); background: #fff; border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,.25); display: flex; flex-direction: column; overflow: hidden; }
#aichat-header { background: var(--aichat-brand, #2563eb); color: #fff; padding: 12px; display: flex; justify-content: space-between; align-items: center; }
#aichat-header-identity { display: flex; align-items: center; gap: 8px; font-weight: 600; }
#aichat-header-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: #fff; }
#aichat-close { background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; }
#aichat-messages { flex: 1; overflow-y: auto; padding: 12px; }

/* Message text is always plain black ink, regardless of brand color --
   readability over on-brand tinting for the actual words. */
.aichat-msg { margin-bottom: 8px; padding: 8px 10px; border-radius: 6px; max-width: 85%; word-wrap: break-word; color: #111; }
.aichat-msg-visitor { background: #eee; margin-left: auto; }
.aichat-msg-ai, .aichat-msg-agent, .aichat-msg-system { background: color-mix(in srgb, var(--aichat-brand, #2563eb) 12%, white); }
.aichat-heading { font-weight: 700; color: var(--aichat-brand, #2563eb); margin: 8px 0 3px; }
.aichat-heading:first-child { margin-top: 0; }
.aichat-list { margin: 0 0 6px; padding-left: 18px; }
.aichat-list li { margin-bottom: 2px; }
.aichat-line { margin-bottom: 4px; }
.aichat-line:last-child, .aichat-list:last-child { margin-bottom: 0; }
.aichat-typing { display: flex; align-items: center; gap: 4px; padding: 10px 12px; }
.aichat-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--aichat-brand, #2563eb); opacity: .4; animation: aichat-typing-bounce 1s infinite ease-in-out; }
.aichat-typing span:nth-child(2) { animation-delay: .15s; }
.aichat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes aichat-typing-bounce { 0%, 60%, 100% { opacity: .4; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.aichat-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.aichat-suggestion { border: 1px solid var(--aichat-brand, #2563eb); background: #fff; color: #111; padding: 6px 10px; border-radius: 14px; font-size: 12px; cursor: pointer; text-align: left; }
.aichat-suggestion:hover { background: color-mix(in srgb, var(--aichat-brand, #2563eb) 12%, white); }
#aichat-form { display: flex; border-top: 1px solid #eee; }
#aichat-input { flex: 1; border: none; padding: 10px; }
#aichat-form button { border: none; background: var(--aichat-brand, #2563eb); color: #fff; padding: 0 14px; cursor: pointer; }
#aichat-lead-prompt { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-top: 1px solid #eee; background: #fafafa; font-size: 13px; }
#aichat-lead-open { border: none; background: var(--aichat-brand, #2563eb); color: #fff; padding: 6px 10px; border-radius: 4px; cursor: pointer; font-size: 13px; white-space: nowrap; }

/* The lead form replaces the transcript view entirely (via
   updateLeadFormVisibility() in widget.js) instead of sharing space with
   it inside the panel's fixed height, and flex:1 lets it use that same
   full area rather than only its own natural content height. */
#aichat-lead-form { flex: 1; padding: 12px; border-top: 1px solid #eee; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
#aichat-lead-form-header { display: flex; align-items: center; justify-content: space-between; font-weight: 700; margin-bottom: 4px; }
#aichat-lead-close { border: none; background: none; font-size: 20px; line-height: 1; cursor: pointer; color: #666; }
#aichat-lead-form input, #aichat-lead-form textarea { padding: 8px; border: 1px solid #ccc; border-radius: 4px; }
#aichat-lead-form button[type="submit"] { border: none; background: var(--aichat-brand, #2563eb); color: #fff; padding: 10px; border-radius: 4px; cursor: pointer; font-size: 14px; }
