/* ─────────────────────────────
   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;
  aspect-ratio: 1 / 1;
}

.chatbot-toggler svg {
  color: #fff;
  position: absolute;
  width: 24px;
  height: 24px;
}

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;
  height: 500px;

  display: flex;
  flex-direction: column;

  background: #fff;
  border-radius: 15px;
  overflow: visible;

  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.7rem;
}

.chatbot header .history-toggle {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.25s ease;
}

.chatbot.history-open .history-toggle {
  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;
}

.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;
}

#teltok-inline-root .chatbot .chat-history {
  border-top-left-radius: 15px;
  border-bottom-left-radius: 15px;
  border-top-right-radius: 15px;
  border-bottom-right-radius: 15px;
}


/* ─────────────────────────────
   Caixa de missatges
   ───────────────────────────── */

.chatbot .chatbox {
  flex: 1;
  overflow-y: auto;
  padding: 30px 20px 140px;
}

.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;
  width: 100%;
  background: #fff;
  padding: 8px 20px;
  border-top: 1px solid #ddd;
  flex-shrink: 0;
}


.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 {
  font-size: 0.72rem;
  color: #666;
  padding: 6px 10px;
  text-align: center;
  border-top: 1px solid #eee;
  background: #fafafa;
  flex-shrink: 0;
}


/* ─────────────────────────────
   Banner de privacitat
   ───────────────────────────── */
.chatbot .chat-privacy {
  position: absolute;
  top: 340px;
  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);
}

.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;
}

#teltok-inline-root .chatbot header h2 {
  color: #fff;
  font-size: 1.8rem;
  line-height: 1.8;
  margin: 0;
  padding: 0;
}

#teltok-inline-root .chatbox {
  margin: 0;
}

#teltok-inline-root .chatbot header {
  background-repeat: no-repeat;
  background-position: center;
  background-size: 40px auto;
  padding: 5px;
}

#teltok-inline-root {
  position: relative;
}

#teltok-inline-root .chatbot .chat-history {
  position: absolute;
  top: 0;
  right: 100%;
  bottom: 0;

  width: 280px;
  max-height: none;

  background: #ffffff;
  border: 1px solid #e5e5e5;
  border-right: none;

  box-shadow: -6px 0 18px rgba(0,0,0,0.08);

  transform: translateX(20px);
  opacity: 0;
  pointer-events: none;

  transition: transform 0.25s ease, opacity 0.25s ease;

  display: flex;
  flex-direction: column;

  z-index: 5;
}

#teltok-inline-root .chatbot .chat-history.show {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

#teltok-inline-root .chatbot .chat-history ul {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 0;
}

#teltok-inline-root .chatbot .chat-history li {
  padding: 12px 14px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s ease;
}

#teltok-inline-root .chatbot .chat-history li:hover {
  background: #f2f6f9;
}

#teltok-inline-root .chatbot .chat-history li.active {
  background: #2189b0;
  color: #fff;
  font-weight: bold;
}

#teltok-inline-root .chatbot .chat-history button#newConvoBtn {
  border-top: 1px solid #ddd;
  border-radius: 0;
  margin: 0;
}

@media (max-width: 490px) {
  #teltok-inline-root .chatbot .chat-history {
    width: 85vw;
  }
}

#teltok-inline-root .chatbot header {
  border-top-left-radius: 15px;
  border-top-right-radius: 15px;
}

#teltok-inline-root .chatbot .chat-input {
  border-bottom-left-radius: 15px;
  border-bottom-right-radius: 15px;
}

#teltok-inline-root .chatbot header,
#teltok-inline-root .chatbot .chat-input {
  overflow: hidden;
}

#teltok-inline-root .chatbot .chatbox {
  overflow-y: auto;
}

#teltok-inline-root .chatbot {
  border-bottom-left-radius: 15px;
  border-bottom-right-radius: 15px;
}

#teltok-inline-root .chatbot .chat-input,
#teltok-inline-root .chatbot .chat-disclaimer {
  border-bottom-left-radius: 15px;
  border-bottom-right-radius: 15px;
}

#teltok-inline-root .chatbot .chat-disclaimer {
  overflow: hidden;
}

#teltok-inline-root .chatbot .chat-history {
  display: flex;
  flex-direction: column;
}

#teltok-inline-root .chatbot .chat-history button#newConvoBtn {
  order: -1;
  border-top: none;
  border-bottom: 1px solid #ddd;

  padding: 12px 14px;
  font-size: 0.85rem;
  font-weight: bold;

  background: #2189b0;
  color: #fff;
}

#teltok-inline-root .chatbot .chat-history button#newConvoBtn:hover {
  background: #186a89;
}

#teltok-inline-root .chatbot .chat-history ul {
  flex: 1;
  overflow-y: auto;
}

.chatbot.history-open .history-toggle {
  transform: translateY(-50%) rotate(180deg);
}

.chatbot header .history-toggle {
  position: absolute !important;
  left: 15px !important;
  right: auto !important;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.25s ease;
}

.chatbot.history-open .history-toggle {
  transform: translateY(-50%) rotate(180deg);
}

.chatbot header .new-convo-toggle {
  position: absolute !important;
  right: 39px !important;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.chatbot header .new-convo-toggle svg {
  display: block;
}

.chatbot header .new-convo-toggle:hover {
  opacity: 1;
}

@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;
  }
}


/* ===== Dynamic Visual Styles ===== */
* {
  font-family: Helvetica, sans-serif;
}

.chatbot-toggler {
  bottom: 30px;
  right: 30px;
  left: auto;
  height: 50px;
  width: 50px;
  background: #2189b0;
}

.chatbot-toggler:hover {
  background: #186a89;
}


.chatbot {
  right: 30px;
  left: auto;
  bottom: 90px;
  width: 400px;
  height: 500px;
  border-radius: 15px;
  transform-origin: bottom right;
  background: #ffffff;
}

.chatbot header {
  background: #2189b0;
}


.chatbot .chatbox {
  background: #ffffff;
}

.chatbox .incoming span {
  background: #2189b0;
}

.chatbox .chat p {
  background: #2189b0;
  color: #ffffff;
}

.chatbox .incoming p {
  background: #707070;
  color: #ffffff;
}

.chat-input span {
  color: #2189b0;
}

.chatbot .chat-history li.active {
  background: #2189b0;
}

.chatbot .chat-history button#newConvoBtn {
  background: #2189b0;
}

.chatbot .chat-history button#newConvoBtn:hover {
  background: #186a89;
}

.chatbot .chat-privacy .accept-privacy {
  background: #2189b0;
}

.chatbot .chat-privacy .accept-privacy:hover {
  background: #186a89;
}

@media (max-width: 490px) {
  .chatbot {
    width: calc(100% - 20px);
    right: 10px;
    left: auto;
    height: calc(100% - 110px);
    max-height: 550px;
  }
}


/* ===== Custom CSS per client ===== */
.chatbot header .new-convo-toggle {
    top: 52%;
}

.wa-cta-button {
    background: #2189b0 !important;
}

.chatbot-toggler {
    width: 50px;
    height: 50px;
    padding: 0;
    margin: 0;
    line-height: 1;
    min-width: 50px;
    min-height: 50px;
    box-sizing: border-box;
}
