/* Carpediem AI chat widget — positioned beside the existing back-to-top control. */
#carpediem-chat-widget {
  position: fixed;
  right: 88px;
  bottom: 24px;
  z-index: 99998;
  font-family: inherit;
}

#carpediem-chat-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 19px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #07569f 0%, #003b73 100%);
  box-shadow: 0 12px 30px rgba(2, 43, 78, .28);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
}

#carpediem-chat-toggle:hover,
#carpediem-chat-toggle:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(2, 43, 78, .34);
}

#carpediem-chat-toggle .carpediem-chat-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 31px;
  height: 31px;
  border-radius: 50%;
  color: #0b4e8d;
  background: #fff;
  font-size: 14px;
}

#carpediem-chat-panel {
  position: absolute;
  right: -64px;
  bottom: 68px;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 32px));
  height: min(590px, calc(100vh - 115px));
  overflow: hidden;
  border: 1px solid rgba(7, 86, 159, .16);
  border-radius: 19px;
  background: #fff;
  box-shadow: 0 28px 70px rgba(0, 29, 54, .28);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(28px) scale(.98);
  transform-origin: bottom right;
  transition: opacity .22s ease, transform .22s ease, visibility .22s ease;
}

#carpediem-chat-widget.is-open #carpediem-chat-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0) scale(1);
}

#carpediem-chat-widget.is-open #carpediem-chat-toggle {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.carpediem-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  min-height: 78px;
  padding: 15px 17px;
  color: #fff;
  background: linear-gradient(135deg, #07569f 0%, #022d56 100%);
}

.carpediem-chat-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.carpediem-chat-brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  color: #07569f;
  background: #fff;
  font-size: 17px;
}

.carpediem-chat-title {
  margin: 0 0 2px;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}

.carpediem-chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255,255,255,.82);
  font-size: 11px;
  font-weight: 600;
}

.carpediem-chat-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #50d890;
  box-shadow: 0 0 0 3px rgba(80,216,144,.18);
}

.carpediem-chat-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(255,255,255,.10);
  cursor: pointer;
  transition: background .2s ease;
}

.carpediem-chat-close:hover { background: rgba(255,255,255,.20); }

.carpediem-chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 11px;
  overflow-y: auto;
  padding: 17px;
  background:
    radial-gradient(circle at top right, rgba(7,86,159,.05), transparent 34%),
    #f7f9fc;
  scroll-behavior: smooth;
}

.carpediem-chat-message {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.carpediem-chat-message--bot {
  align-self: flex-start;
  color: #26384d;
  border: 1px solid #e5ebf2;
  border-bottom-left-radius: 4px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(15, 49, 79, .05);
}

.carpediem-chat-message--user {
  align-self: flex-end;
  color: #fff;
  border-bottom-right-radius: 4px;
  background: #07569f;
}

.carpediem-chat-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-self: flex-start;
  max-width: 100%;
}

.carpediem-chat-quick-action {
  padding: 8px 11px;
  border: 1px solid rgba(7,86,159,.22);
  border-radius: 999px;
  color: #07569f;
  background: #fff;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
}

.carpediem-chat-quick-action:hover {
  color: #fff;
  background: #07569f;
}

.carpediem-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 55px;
}

.carpediem-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #91a1b2;
  animation: carpediem-chat-dot 1.25s infinite ease-in-out;
}

.carpediem-chat-typing span:nth-child(2) { animation-delay: .15s; }
.carpediem-chat-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes carpediem-chat-dot {
  0%, 70%, 100% { transform: translateY(0); opacity: .55; }
  35% { transform: translateY(-5px); opacity: 1; }
}

.carpediem-chat-input-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: end;
  gap: 9px;
  padding: 12px;
  border-top: 1px solid #e6ebf1;
  background: #fff;
}

.carpediem-chat-input {
  width: 100%;
  min-height: 44px;
  max-height: 105px;
  resize: none;
  padding: 11px 14px;
  border: 1px solid #ccd6e1;
  border-radius: 13px;
  color: #26384d;
  background: #fff;
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  outline: none;
}

.carpediem-chat-input:focus {
  border-color: #07569f;
  box-shadow: 0 0 0 3px rgba(7,86,159,.10);
}

.carpediem-chat-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: #07569f;
  cursor: pointer;
  transition: transform .2s ease, opacity .2s ease;
}

.carpediem-chat-send:hover { transform: scale(1.04); }
.carpediem-chat-send:disabled { opacity: .55; cursor: wait; }

.carpediem-chat-powered {
  padding: 0 14px 10px;
  color: #8a99a8;
  background: #fff;
  font-size: 10px;
  text-align: center;
}

@media (max-width: 575px) {
  #carpediem-chat-widget {
    right: 78px;
    bottom: 18px;
  }

  #carpediem-chat-toggle {
    width: 50px;
    min-height: 50px;
    padding: 0;
  }

  #carpediem-chat-toggle .carpediem-chat-toggle-label { display: none; }
  #carpediem-chat-toggle .carpediem-chat-toggle-icon { width: 34px; height: 34px; }

  #carpediem-chat-panel {
    position: fixed;
    right: 10px;
    bottom: 78px;
    width: calc(100vw - 20px);
    height: min(620px, calc(100vh - 92px));
    border-radius: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #carpediem-chat-panel,
  #carpediem-chat-toggle,
  .carpediem-chat-typing span {
    transition: none;
    animation: none;
  }
}
