/* ─────────────────────────────
   Reset i fonts
   ───────────────────────────── */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: Helvetica, sans-serif;
}

body {
  background: #fff;
}

/* ─────────────────────────────
   Logo extra (opcional)
   ───────────────────────────── */
a.link-text.chat-logo {
  padding: 4px 24px;
  background-image: url(../teltok/Group_4.png);
  background-position: left top;
  background-size: 100% auto;
  background-repeat: no-repeat;
  color: transparent;
  text-decoration: none;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  transition: ease-in-out 0.25s;
}

/* ─────────────────────────────
   Botó principal (bombolla)
   ───────────────────────────── */
.chatbot-toggler {
  position: fixed;
  bottom: 30px;
  right: 35px;
  outline: none;
  border: none;
  height: 50px;
  width: 50px;
  display: flex;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #2189b0;
  transition: all 0.2s ease;
  z-index: 10000;
}

.chatbot-toggler svg {
  color: #fff;
  position: absolute;
}

body.show-chatbot .chatbot-toggler {
  transform: rotate(90deg);
}

.chatbot-toggler svg:last-child,
body.show-chatbot .chatbot-toggler svg:first-child {
  opacity: 0;
}
body.show-chatbot .chatbot-toggler svg:last-child {
  opacity: 1;
}

.chatbot-toggler:hover {
  transform: scale(1.05);
}

/* ─────────────────────────────
   Caixa del chatbot
   ───────────────────────────── */
.chatbot {
  line-height: 1.2;
  position: fixed;
  right: 35px;
  bottom: 90px;
  width: 400px;
  background: #fff;
  border-radius: 15px;
  overflow: hidden;
  height: 500px;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.5);
  transform-origin: bottom right;
  box-shadow: 0 0 128px 0 rgba(0,0,0,0.1),
              0 32px 64px -48px rgba(0,0,0,0.5);
  transition: all 0.1s ease;
  z-index: 9999;
}

body.show-chatbot .chatbot {
  visibility: visible;
  pointer-events: auto;
  transform: scale(1);
}

/* ─────────────────────────────
   Header
   ───────────────────────────── */
.chatbot header {
  padding: 16px 0;
  position: relative;
  text-align: center;
  color: #fff;
  background: #2189b0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.chatbot header h2 {
  font-size: 1.4rem;
  font-weight: bold;
  color: #fff;
}

.chatbot header .close-btn {
  position: absolute;
  right: 15px;
  top: 50%;
  cursor: pointer;
  transform: translateY(-50%);
  font-size: 1.4rem;
}

.chatbot header .history-toggle {
  position: absolute;
  right: 45px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.2s ease;
}
.chatbot header .history-toggle:hover {
  transform: translateY(-50%) rotate(180deg);
}

/* ─────────────────────────────
   Historial de converses
   ───────────────────────────── */
.chatbot .chat-history {
  max-height: 200px;
  overflow-y: auto;
  border-top: 1px solid #ddd;
  background: #fafafa;
  font-size: 0.85rem;
  display: none; /* ocult per defecte */
}

.chatbot .chat-history.show {
  display: block;
}

.chatbot .chat-history ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.chatbot .chat-history li {
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: background 0.2s ease;
}
.chatbot .chat-history li:hover {
  background: #e6f3f9;
}
.chatbot .chat-history li.active {
  background: #2189b0;
  font-weight: bold;
  color: #ffff
}

.chatbot .chat-history button#newConvoBtn {
  width: 100%;
  padding: 10px;
  border: none;
  background: #2189b0;
  color: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s ease;
}
.chatbot .chat-history button#newConvoBtn:hover {
  background: #186a89;
}

/* ─────────────────────────────
   Caixa de missatges
   ───────────────────────────── */
.chatbot .chatbox {
  overflow-y: auto;
  height: 430px;
  padding: 30px 20px 140px; /* bottom ampliat per input+disclaimer */
}

.chatbot :where(.chatbox, textarea)::-webkit-scrollbar {
  width: 6px;
}
.chatbot :where(.chatbox, textarea)::-webkit-scrollbar-track {
  background: #fff;
  border-radius: 25px;
}
.chatbot :where(.chatbox, textarea)::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 25px;
}

.chatbox .chat {
  display: flex;
  list-style: none;
}
.chatbox .outgoing {
  margin: 20px 0;
  justify-content: flex-end;
}
.chatbox .incoming span {
  width: 32px;
  height: 32px;
  color: #fff;
  text-align: center;
  line-height: 32px;
  align-self: flex-end;
  background: #2189b0;
  border-radius: 4px;
  margin: 0 10px 7px 0;
}
.chatbox .chat p {
  white-space: pre-wrap;
  padding: 12px 16px;
  border-radius: 10px 10px 0 10px;
  max-width: 75%;
  color: #fff;
  font-size: 0.90rem;
  background: #2189b0;
  font-weight: bold;
}
.chatbox .incoming p {
  border-radius: 10px 10px 10px 0;
  background: #707070;
}
.chatbox .chat p.error {
  color: #721c24;
  background: #f8d7da;
}
.chatbox .chat p.progress {
  color: #2189b0;
  background: #e9f6fb;
  border: 1px solid #cbe4ef;
  font-style: italic;
  font-weight: 600;
}

/* ─────────────────────────────
   Enllaços dins missatges
   ───────────────────────────── */
.email-link { color: #2ecc71; text-decoration: none; }
.email-link:hover { text-decoration: underline; }

.phone-link { color: #2ecc71; text-decoration: none; }
.phone-link:hover { text-decoration: underline; }

.web-link { color: #2ecc71; text-decoration: none; }
.web-link:hover { text-decoration: underline; }

/* ─────────────────────────────
   Input
   ───────────────────────────── */
.chatbot .chat-input {
  display: flex;
  gap: 5px;
  position: absolute;
  bottom: 0;
  width: 100%;
  background: #fff;
  padding: 3px 20px;
  border-top: 1px solid #ddd;
}

.chat-input textarea {
  height: 55px;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  max-height: 180px;
  padding: 15px 15px 15px 0;
  font-size: 0.90rem;
  color: #5b5d5f;
  font-weight: bold;
}

.chat-input span {
  align-self: flex-end;
  color: #2189b0;
  cursor: pointer;
  height: 55px;
  display: none;
  align-items: center;
  font-size: 1.80rem;
}
.chat-input textarea:valid ~ span {
  visibility: visible;
}

/* ─────────────────────────────
   Disclaimer
   ───────────────────────────── */
.chatbot .chat-disclaimer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 58px; /* just sobre la barra d'entrada */
  font-size: 0.72rem;
  color: #666;
  padding: 6px 10px;
  text-align: center;
  border-top: 1px solid #eee;
  background: #fafafa;
}

/* ─────────────────────────────
   Banner de privacitat
   ───────────────────────────── */
.chatbot .chat-privacy {
  position: absolute;
  top: 350px;
  left: 0;
  width: 100%;
  height: 30%;
  background: rgba(255,255,255,0.95);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  text-align: center;
  z-index: 10001;
}
.chatbot .chat-privacy p {
  font-size: 0.9rem;
  margin-bottom: 12px;
  color: #333;
}
.chatbot .chat-privacy a {
  color: #2189b0;
  font-weight: bold;
  text-decoration: underline;
}
.chatbot .chat-privacy .accept-privacy {
  background: #2189b0;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.9rem;
}
.chatbot .chat-privacy .accept-privacy:hover {
  background: #186a89;
}

/* ─────────────────────────────
   Bombolla única per contingut bloc (taules, etc.)
   ───────────────────────────── */
.chatbox .incoming .bubble {
  white-space: normal;
  padding: 12px 16px;
  border-radius: 10px 10px 10px 0;
  max-width: 100%;
  color: #fff;
  font-size: 0.75rem;
  background: #707070;
  font-weight: bold;
  overflow: auto;
}

.chatbox .incoming .bubble table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
  margin: 0;
}
.chatbox .incoming .bubble th,
.chatbox .incoming .bubble td {
  border: 1px solid rgba(255,255,255,0.25);
  padding: 6px 8px;
  text-align: left;
  color: #fff;
}
.chatbox .incoming .bubble th {
  background: #2189b0;
  color: #fff;
  font-weight: bold;
}
.chatbox .incoming .bubble tr:nth-child(even) {
  background: rgba(255,255,255,0.06);
}

/* Enllaços dins taula */
.chatbox .incoming .bubble td a.file-link {
  color: #0d6efd;
  text-decoration: none;
}
.chatbox .incoming .bubble td a.file-link:hover {
  text-decoration: underline;
  color: #2189b0;
}

/* ─────────────────────────────
   Responsive
   ───────────────────────────── */
@media (max-width: 490px) {
  .chatbot-toggler {
    right: 20px;
    bottom: 20px;
  }
  .chatbot {
    right: 0;
    height: 80%;
    width: 90%;
  }
  .chatbot .chatbox {
    height: 90%;
    padding: 25px 15px 140px;
  }
  .chatbot .chat-input {
    padding: 5px 15px;
  }
  .chatbot header .close-btn {
    display: block;
  }
  /* ─────────────────────────────
   Responsive
   ───────────────────────────── */
@media (max-width: 490px) {
  .chatbot-toggler {
    right: 20px;
    bottom: 20px;
  }
  .chatbot {
    right: 0;
    height: 80%;
    width: 90%;
  }
  .chatbot .chatbox {
    height: 90%;
    padding: 25px 15px 140px;
  }
  .chatbot .chat-input {
    padding: 5px 15px;
  }
  .chatbot header .close-btn {
    display: block;
  }
  .chatbot .chat-privacy {
  top: 400px;
  }

}
