/* CSS per al xat Laia: integrat dins contingut, sense scroll extern, ajustat a alçada de pantalla disponible, amb suport Markdown */

/* ---------------- RESET FUNCIONAL ---------------- */
/* Només reseteja per al layout, no per a elements de text com pre, code, blockquote, lists */
#laia-chatbot-fullscreen,
#laia-chatbot-container,
#laia-box,
#laia-form {
  box-sizing: border-box;
}

/* ---------------- CONTENIDOR PRINCIPAL ---------------- */
#laia-chatbot-fullscreen {
  width: 100%;
  /*padding: 1rem;*/
  background: transparent;
}

#laia-chatbot-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: calc(100vh - 200px); /* ajustar segons header WP */
  max-width: none;
  margin: 0 auto;
  background-color: #ffffff;
  border: 1px solid #ddd;
  border-radius: 10px;
  overflow: hidden;
  font-family: 'Segoe UI', sans-serif;
}


/* ---------------- ENCAPÇALAMENT ---------------- */
/*
#laia-chatbot-container h2 {
  text-align: center;
  padding: 1rem;
  background-color: #0073aa;
  color: #ffffff;
  font-size: 1.5rem;
  border-bottom: 1px solid #ccc;
}
  */


/* ---------------- ÀREA DE MISSATGES ---------------- */
#laia-box {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background-color: #f9f9f9;
}

/* Scrollbar estilitzat */
#laia-box::-webkit-scrollbar {
  width: 6px;
}
#laia-box::-webkit-scrollbar-thumb {
  background-color: #ccc;
  border-radius: 3px;
}
#laia-box::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------------- WRAPPER DE MISSATGES (flex‐column) ---------------- */
#laia-missatges {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;  /* reduït d’0.75rem a 0.5rem per menys espai entre bombolles */
}

/* ---------------- MISSATGES (bombolles ajustables) ---------------- */
#laia-missatges .usuari,
#laia-missatges .laia {
  display: block;            /* perquè cada missatge comenci en nova línia */
  width: -moz-fit-content;   /* per a Firefox */
  width: fit-content;        /* per a Chrome, Edge, Safari */
  max-width: 75%;            /* no superarà el 75% de l’ample del contenidor pare */
  padding: 0.5rem 1rem;      /* reduït el padding vertical d’0.75rem a 0.5rem */
  border-radius: 20px;
  font-size: 1rem;
  line-height: 1.4;
  position: relative;
  word-break: break-word;
  white-space: pre-wrap;     /* respecta salts de línia */
}

/* Eliminem marges interns de paràgrafs dins les bombolles de Laia */
#laia-missatges .laia p {
  margin: 0.25rem 0;         /* opcional: una mica de marge entre línies internes */
}

/* ---------------- ESTILS ESPECÍFICS ---------------- */
/* Missatges d'usuari (dreta) */
#laia-missatges .usuari {
  align-self: flex-end;
  background-color: #d0e8ff;
  /*text-align: right;*/
  margin-left: auto;
}
#laia-missatges .usuari::after {
  content: '';
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 8px 0 8px 8px;
  border-style: solid;
  border-color: transparent transparent transparent #d0e8ff;
}

/* Missatges de Laia (esquerra) */
#laia-missatges .laia {
  align-self: flex-start;
  background-color: #e0f5d7;
  text-align: left;
  margin-right: auto;
}
#laia-missatges .laia::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 8px 8px 8px 0;
  border-style: solid;
  border-color: transparent #e0f5d7 transparent transparent;
}



/* ---------------- SUPORT MARKDOWN ---------------- */
/* Reestablim marges/paddings per a elements Markdown dins el xat */
#laia-missatges pre {
  background-color: #f5f5f5;
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1rem 0;
  font-family: monospace;
  font-size: 0.9rem;
}
#laia-missatges code {
  background-color: #eee;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: monospace;
}
#laia-missatges blockquote {
  border-left: 4px solid #ccc;
  padding-left: 1rem;
  color: #555;
  margin: 1rem 0;
}
#laia-missatges ul,
#laia-missatges ol {
  margin: 0.5rem 1rem;
  padding-left: 1.5rem;
}
#laia-missatges li {
  margin-bottom: 0.25rem;
}

/* ---------------- FORMULARI D'ENTRADA ---------------- */
#laia-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid #ccc;
  background-color: #ffffff;
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
}
#laia-input {
  flex: 1;
  padding: 0.6rem 1rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 20px;
  outline: none;
  transition: border-color 0.3s;
}
#laia-input:focus { border-color: #0073aa; }
#laia-form button {
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  background-color: #12B9C7;
  color: #ffffff;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  transition: background-color 0.3s;
}
#laia-form button:hover { background-color: #005d8c; }
#laia-form button:disabled { background-color: #aaa; cursor: default; }

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 768px) {
  #laia-chatbot-container { max-width: 100%; border: none; border-radius: 0; height: calc(100vh - 200px); }
  #laia-input, #laia-form button { font-size: 0.9rem; }
}


/* 🔒 Ocultació per defecte */
.ocult {
  display: none !important;
}

#laia-boto-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: #12B9C7;
  color: white;
  font-size: 24px;
  padding: 12px;
  border-radius: 50%;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  cursor: pointer;
  z-index: 9999;
  transition: background-color 0.3s ease;
}

#laia-boto-toggle:hover {
  background-color: #0056b3;
}


#laia-chatbot-fullscreen.popup {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 400px;
  max-height: 600px;
  background-color: white;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  z-index: 99998;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 🎨 HEADER DEL XAT: Color uniforme i estil modern */
#laia-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  background-color: #12B9C7; /* color uniforme */
  color: #ffffff;
  border-bottom: 1px solid #004c70;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* El títol ocupa només el text, però el fons el dona el container */
#laia-header h2 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
  color: inherit; /* usa el color del pare */
  background: none; /* evita cap fons blanc per defecte */
}

/* Selector de modes (text / veu) */
#laia-mode-selector {
  display: flex;
  gap: 0.5rem;
}

#laia-mode-selector button {
  background-color: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  padding: 0.45rem 0.65rem;
  font-size: 1.2rem;
  color: #ffffff;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

#laia-mode-selector button:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

#laia-mode-selector button.actiu {
  background-color: #109daa;
  color: white;
}


/* 🎤 Interfície de veu */
#laia-voice-interface {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-top: 1px solid #ccc;
  background-color: #f4f4f4;
}

#laia-cercle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: #12B9C7;
  opacity: 0.3;
  transition: transform 0.3s ease;
}

#laia-boto-veu {
  background-color: #12B9C7;
  color: white;
  border: none;
  border-radius: 50px;
  padding: 0.6rem 1.5rem;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

#laia-boto-veu:hover {
  background-color: #109daa;
}

/* 🎨 Estils per animar el cercle */
#laia-cercle.actiu {
  animation: pulse 1s infinite;
  opacity: 0.6;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}



/* -----------------------------VIDEO----------------------------
/* ==== LAIA: estil vídeo amb overlay ==== */
/*
.laia-video-card {
  padding: 0.5rem;
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}

.laia-video-title {
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.laia-video-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
}

.laia-video-frame {
  display: block;
  width: 100%;
  border-radius: 12px;
}

.laia-video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none; 
}

.laia-video-btn {
  pointer-events: auto;
  width: 64px;
  height: 64px;
  border-radius: 9999px;
  border: none;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 28px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease, background .2s ease;
}

.laia-video-btn:hover { transform: scale(1.06); background: rgba(0,0,0,0.7); }
.laia-video-btn.hidden { opacity: 0; visibility: hidden; }
*/