/*!
  © 2025 Nicolas Payen / HEA World project.
  Proprietary and confidential — unauthorized use prohibited.
*/
/* 📦 HEA Chat Stylesheet – hea-world.com/hea_chat_engine/styles/hea_chat_styles.css 
 stored as /public/hea_chat_engine/styles/hea_chat_styles.css 
 */
/* Container */
/* Base chatbox frame, neutral */
.chatbox {
  display:flex;
  flex-direction:column;
  font-family:'Inter',sans-serif;
  border-radius:16px;
  overflow:hidden;
  background:#fff;
  box-shadow:0 12px 24px rgba(0,0,0,.2);
  border:1px solid #eee;
}

/* === POPUP ONLY (chatbox fills the iframe) === */
[data-mode="popup"] html,
[data-mode="popup"] body { 
  min-height: 640px; /* previously shrunk; restore comfortable height */
  height: 100%; 
}

@media (max-width: 768px) {
  [data-mode="popup"] html,
  [data-mode="popup"] body {
    min-height: 560px;
  }
}

[data-mode="popup"] #hea-chat-container {
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
}

[data-mode="popup"] .chatbox {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  min-height: 0;
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(0,0,0,.2);
  border: 1px solid #eee;
}

/* === EMBED + FULLPAGE share “fill available space” === */
html, body { height:100%; }

[data-mode="embed"] main,
[data-mode="fullpage"] main { display:flex; flex:1 1 auto; padding:0; align-items:stretch; }

[data-mode="embed"] #hea-chat-container,
[data-mode="fullpage"] #hea-chat-container { display:flex; flex:1 1 auto; min-height:0; }

[data-mode="embed"] .chatbox,
[data-mode="fullpage"] .chatbox {
  flex:1 1 auto;
  width:100%;
  max-width:none;
  height:auto;
  min-height:0;
  max-height:none;
  border-radius:0;
  box-shadow:none;
  border:0;
}

/* messages area flexes properly */
[data-mode="embed"] .chat-messages,
[data-mode="fullpage"] .chat-messages { flex:1 1 auto; min-height:0; overflow-y:auto; }

/* input sticks to bottom */
[data-mode="embed"] .chat-input-area,
[data-mode="fullpage"] .chat-input-area {
  position:sticky; bottom:0; background:#fff; border-top:1px solid #eee;
}

/* remove content caps in EMBED + FULLPAGE */
[data-mode="embed"] #hea-chat-container .chat-message,
[data-mode="embed"] #hea-chat-container .user-message,
[data-mode="embed"] #hea-chat-container .bot-message,
[data-mode="embed"] #hea-chat-container .cta-wrapper {
  max-width: 100% !important;
}

/* Keep caps only for POPUP readability */
/* Cap message/CTA width in inline/fullpage too (not just popup) */
:root { --chat-max-message-width: 560px; }

[data-mode="popup"] #hea-chat-container .chat-message,
[data-mode="popup"] #hea-chat-container .user-message,
[data-mode="popup"] #hea-chat-container .bot-message,
[data-mode="popup"] #hea-chat-container .cta-wrapper {
  max-width: min(var(--chat-max-message-width), 92%);
}

/* Inline marketing page: hide chat header */
body[data-mode="inline"] #hea-chat-container .chat-header {
  display: none !important;
}

[data-mode="popup"] #hea-chat-container .cta-video{
  max-width: min(var(--chat-max-message-width), 92%);
}

/* Optional: keep nice rounded top even without header */
body[data-mode="inline"] #hea-chat-container .chatbox {
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.chromeless #hea-chat-container .chat-header { display:none!important; }

/* apply caps to messages & CTAs when chat is inline/fullpage */
body[data-mode="inline"] #hea-chat-container .chat-message,
body[data-mode="inline"] #hea-chat-container .user-message,
body[data-mode="inline"] #hea-chat-container .bot-message,
body[data-mode="inline"] #hea-chat-container .cta-wrapper,
body[data-mode="fullpage"] #hea-chat-container .chat-message,
body[data-mode="fullpage"] #hea-chat-container .user-message,
body[data-mode="fullpage"] #hea-chat-container .bot-message,
body[data-mode="fullpage"] #hea-chat-container .cta-wrapper {
  max-width: min(var(--chat-max-message-width), 100%) !important;
  align-self: flex-start;
}

/* make sure the CTA card itself doesn’t stretch past the cap */
#hea-chat-container .cta-wrapper .cta-card {
  width: min(var(--chat-max-message-width), 100%);
}

/* belt & suspenders on media sizing */
#hea-chat-container .cta-wrapper .cta-card-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;        /* reserve space to prevent CLS */
  object-fit: cover;
  max-height: clamp(180px, 32vh, 380px);
}

.chat-header {
  display: flex;
  flex: 0 0 auto;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: linear-gradient(90deg, var(--brand1, #ff5f6d), var(--brand2, #ffc371));
  color: white;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;            /* ← allow it to grow */
  min-width: 0;       /* ← allow children to shrink inside */
}

.chat-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Optional: hide scrollbar from dropdown initially */
.hea-dropdown.hidden {
  display: none;
}

.chat-title {
  font-weight: 600;
  color:white;
  font-size: 1rem;
  white-space: normal;         /* ← allow wrapping */
  overflow-wrap: break-word;   /* ← wrap long words */
  word-break: break-word;      /* ← just in case */
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 0.75rem;
  background: white;
  border: 2px solid white;
}

.chat-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem 1rem;
  background: white;
}

.chat-messages {
  display: flex;  
  flex-direction: column;
  flex: 1 1 auto;
  overflow-y: auto;
  margin: 0;
  padding: 1rem;
  border-top: 1px solid #eee;
  border-bottom: 1px solid #eee;
  background: #fafafa;
  font-size: 0.95rem;
  line-height: 1.4;
}

.chat-input-area {
  display: flex;
  flex: 0 0 auto;
  gap: 0.5rem;
  padding: 0.75rem;
  background: white;
  border-top: 1px solid #eee;
}

/* Input area */
.chat-input {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  background: white;
}

#user-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 0.95rem;
  resize: vertical;
  height: 40px;
}

#send-button {
  padding: 0.5rem 1rem;
  margin-bottom: 0.5rem;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  align-self: flex-end;
  height: 40px;
  background: var(--btn-bg, #f18f01);
  border: 1px solid var(--btn-border, #d7263d);
  color: white;
}

#send-button:hover {
  opacity: 0.9;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.user-message, .bot-message {
  margin: 0.3rem 0;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  max-width: 90%;
  white-space: pre-wrap;
}

.user-message {
  background: var(--user-bubble, #e6f7ff);
  color: #000;
  align-self: flex-end;
}

.bot-message {
  background: var(--agent-bubble, #f5f5f5);
  align-self: flex-start;
}

.user-message.bot.thinking em {
  color: #999;
  font-style: italic;
}

/* Popup Controls */
#maximize-chat,
#minimize-chat,
#close-chat {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1.2rem;
  padding-left: 6px;
}

.hea-chat-menu {
  position: relative;
}

.hea-dropdown {
  position: absolute;
  top: 2.2rem;
  right: 0;
  min-width: 160px;
  background: white;
  border: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  padding: 0.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.hea-dropdown a {
  text-decoration: none;
  color: #333;
  font-size: 0.85rem;
  padding: 2px 0;
}

.hea-dropdown .hea-powered {
  font-size: 0.75rem;
  color: #666;
}

.hea-dropdown label.hea-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.hea-dropdown.hidden {
  display: none;
}

/* Hidden utility class */
.hidden {
  display: none !important;
}

/* CTAs section */
.cta-container {
  margin-top: 8px;
  margin: 0.5rem 0 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.cta-card-img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.cta-card {
  margin: 1rem 0;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: transform 0.2s;
}

.cta-card:hover {
  transform: scale(1.02);
}

.cta-button {
  background-color: #f85f73;
  border: none;
  color: white;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.cta-button:hover {
  background-color: #e24a5c;
}

/* ---- CTA sizing & layout ---- */
#hea-chat-container .chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start; /* keep bubbles/CTAs from stretching full-width */
}

/* CTA card: block-level, rounded, overflow clipped */
#hea-chat-container .cta-wrapper .cta-card {
  display: block;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 6px 18px rgba(0,0,0,.06);
  border: 1px solid #eee;
}

/* Image: responsive, with reserved aspect-ratio to avoid CLS */
#hea-chat-container .cta-wrapper .cta-card-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;       /* reserve space; adjust if needed */
  object-fit: cover;          /* crop wide images nicely */
  max-height: clamp(180px, 32vh, 380px); /* desktop/iPad cap */
}

/* Text content under the image */
#hea-chat-container .cta-wrapper .cta-card-content {
  padding: 12px 14px;
  font-size: 0.95rem;
  line-height: 1.35;
}

/* If chat is in transparent/dark, soften card bg automatically */
body.dark #hea-chat-container .cta-wrapper .cta-card {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
  backdrop-filter: blur(6px);
}

/* Responsive */
/* Mobile-first styles */
@media (max-width: 768px) {

  #chat-popup {
    width: 100vw;
    height: 90vh;
    bottom: 0;
    right: 0;
    border-radius: 0;
    max-height: unset;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 560px; /* or whatever your normal minimum is */
  }

  .chatbox {
    height: 100%;
    flex-direction: column;
  }

  .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 70px; /* for space below messages */
  }

  .chat-input {
    position: fixed;
    bottom: 0;
    width: 100%;
  }
}

/* ===== CTAs (cards, images, videos) ===== */

/* Global sizing vars (tweak here only) */
:root{
  --chat-max-message-width: 560px;   /* max width of any bubble/card */
  --cta-img-max-h-mobile: 180px;     /* mobile image cap */
  --cta-img-max-h-desktop: 220px;    /* desktop/tablet image cap */
  --cta-video-max-h: 260px;          /* video frame cap */
}

/* Keep bubbles/CTAs from stretching full-width */
#hea-chat-container .chat-messages{
  display:flex;
  flex-direction:column;
  gap:12px;
  align-items:flex-start;
}

/* CTA card container */
#hea-chat-container .cta-wrapper .cta-card{
  display:block;
  width:100%;
  border-radius:12px;
  overflow:hidden;
  background:#fff;
  border:1px solid #eee;
  box-shadow:0 6px 18px rgba(0,0,0,.06);
  transition:transform .2s;
  cursor:pointer;
}
#hea-chat-container .cta-wrapper .cta-card:hover{ transform:scale(1.02); }

/* CTA image (single source of truth) */
#hea-chat-container .cta-wrapper .cta-card-img{
  display:block;
  width:100%;
  height:auto;
  aspect-ratio:16/9;                 /* reserve space to avoid CLS */
  object-fit:cover;                   /* crop nicely */
  max-height:var(--cta-img-max-h-mobile);
  border-radius:0;                    /* already clipped by card */
}
@media (min-width:640px){
  #hea-chat-container .cta-wrapper .cta-card-img{
    max-height:var(--cta-img-max-h-desktop);
  }
}

/* CTA text under media */
#hea-chat-container .cta-wrapper .cta-card-content{
  padding:12px 14px;
  font-size:.95rem;
  line-height:1.35;
}

/* CTA button (non-media) */
.cta-button{
  background:#f85f73;
  border:none;
  color:#fff;
  padding:10px 18px;
  border-radius:8px;
  font-size:14px;
  cursor:pointer;
  transition:opacity .2s ease;
}
.cta-button:hover{ opacity:.9; }

/* ===== Video CTA (responsive) ===== */
#hea-chat-container .cta-video{
  width:100%;
  margin:1rem 0;
  border-radius:12px;
  overflow:hidden;
  background:#fff;
  border:1px solid #eee;
  box-shadow:0 6px 18px rgba(0,0,0,.06);
}
#hea-chat-container .cta-video-frame{
  position:relative;
  width:100%;
  aspect-ratio:16/9;
  max-height:var(--cta-video-max-h);
}
#hea-chat-container .cta-video-frame iframe{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  border:0;
  display:block;
}
#hea-chat-container .cta-video-caption{
  padding:8px 12px;
  font-weight:600;
  font-size:.95rem;
}
#hea-chat-container .cta-video small.muted{
  display:block;
  padding:0 12px 12px;
  font-size:.8rem;
  color:#777;
}

/* Dark/transparent modes */
body.dark #hea-chat-container .cta-wrapper .cta-card,
body.dark #hea-chat-container .cta-video{
  background:rgba(255,255,255,.06);
  border-color:rgba(255,255,255,.12);
  backdrop-filter:blur(6px);
}

