/* ========================================
   LOUISE Chatbot Widget
   ======================================== */

#louise-chat-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  font-family: var(--font-base);
}

/* Toggle button */
#chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(112deg, #ce003d 0%, #edb553 100%);
  box-shadow: 0 4px 20px rgba(206, 0, 61, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  margin-left: auto;
}

#chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(206, 0, 61, 0.45);
}

/* Chat panel */
#chat-panel {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 370px;
  height: 520px;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Glassmorphism matching site's hero-card style */
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.82) 0%,
    rgba(255, 230, 220, 0.65) 100%
  );
  border-top: 1px solid rgba(255, 255, 255, 0.7);
  border-left: 1px solid rgba(255, 255, 255, 0.45);
  border-right: 1px solid rgba(237, 181, 83, 0.13);
  border-bottom: 1px solid rgba(206, 0, 61, 0.09);
  box-shadow:
    0 16px 56px rgba(206, 0, 61, 0.12),
    0 4px 14px rgba(237, 181, 83, 0.08),
    0 2px 4px rgba(0, 0, 0, 0.05);
}

#chat-panel[hidden] {
  display: none;
}

/* Header */
#chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  background: linear-gradient(112deg, #ce003d 0%, #edb553 100%);
  color: #fff;
  border-radius: 24px 24px 0 0;
}

#chat-header span {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

#chat-restart,
#chat-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

#chat-restart {
  font-size: 1.1rem;
}

#chat-restart:hover,
#chat-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

/* Messages area */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(206, 0, 61, 0.2) transparent;
}

#chat-messages::-webkit-scrollbar {
  width: 4px;
}

#chat-messages::-webkit-scrollbar-thumb {
  background: rgba(206, 0, 61, 0.2);
  border-radius: 2px;
}

/* Bot avatar */
.chat-bot-row {
  display: grid;
  grid-template-columns: 44px 1fr;
  grid-template-rows: auto auto;
}

.chat-bot-col {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

.chat-bot-avatar-wrap {
  grid-column: 1;
  grid-row: 2;
  padding-top: 0.25rem;
}

.chat-bot-avatar {
  display: block;
  width: 36px;
  height: 36px;
}

/* Individual messages */
.chat-msg {
  max-width: 88%;
  padding: 0.6rem 0.9rem;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(112deg, #ce003d 0%, #edb553 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.75);
  color: var(--color-text);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.chat-msg.bot p { margin: 0 0 0.4em; }
.chat-msg.bot p:last-child { margin-bottom: 0; }
.chat-msg.bot ul, .chat-msg.bot ol { margin: 0.3em 0 0.3em 1.2em; padding: 0; }
.chat-msg.bot li { margin-bottom: 0.2em; }
.chat-msg.bot strong { color: #ce003d; }

.chat-msg.error {
  align-self: flex-start;
  background: rgba(206, 0, 61, 0.08);
  color: #ce003d;
  border: 1px solid rgba(206, 0, 61, 0.2);
  font-size: 0.82rem;
}

/* Attachments */
.chat-attachments {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.chat-attachment-link {
  font-size: 0.78rem;
  color: #ce003d;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  opacity: 0.85;
  transition: opacity 0.15s;
}

.chat-attachment-link:hover { opacity: 1; text-decoration: underline; }

/* Feedback buttons */
.chat-feedback {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.chat-feedback button {
  background: none;
  border: 1px solid rgba(206, 0, 61, 0.2);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.15rem 0.45rem;
  color: var(--color-text-secondary);
  transition: background 0.15s, color 0.15s;
}

.chat-feedback button:hover,
.chat-feedback button.active {
  background: rgba(206, 0, 61, 0.08);
  color: #ce003d;
  border-color: rgba(206, 0, 61, 0.4);
}

/* Typing indicator */
.chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 0.6rem 0.9rem;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.chat-typing span {
  width: 6px;
  height: 6px;
  background: #ce003d;
  border-radius: 50%;
  animation: chatBounce 1.2s infinite ease-in-out;
}

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

@keyframes chatBounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input area */
#chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(206, 0, 61, 0.08);
  background: rgba(255, 255, 255, 0.5);
}

#chat-input {
  flex: 1;
  resize: none;
  border: 1px solid rgba(206, 0, 61, 0.18);
  border-radius: 12px;
  padding: 0.55rem 0.8rem;
  font-family: var(--font-base);
  font-size: 0.875rem;
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.8);
  outline: none;
  line-height: 1.4;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.15s;
}

#chat-input:focus {
  border-color: #ce003d;
  background: rgba(255, 255, 255, 0.95);
}

#chat-input::placeholder { color: var(--color-text-secondary); }

#chat-send {
  flex-shrink: 0;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  background: linear-gradient(112deg, #ce003d 0%, #edb553 100%);
  color: #fff;
  font-family: var(--font-base);
  font-size: 0.875rem;
  font-weight: 600;
  transition: opacity 0.15s, transform 0.15s;
}

#chat-send:hover { opacity: 0.9; transform: scale(1.03); }
#chat-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Cookie consent overlay */
#chat-cookie-overlay {
  position: absolute;
  inset: 0;
  background: rgba(19, 36, 64, 0.45);
  backdrop-filter: blur(4px);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 1rem;
}

#chat-cookie-card {
  background: #fff;
  border-radius: 16px;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: var(--color-text);
  line-height: 1.5;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.cookie-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1rem;
}

.cookie-title strong {
  font-weight: 700;
  color: var(--color-text);
}

.cookie-body {
  margin: 0;
  color: var(--color-text);
}

.cookie-info-box {
  background: rgba(206, 0, 61, 0.05);
  border: 1px solid rgba(206, 0, 61, 0.12);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  display: flex;
  gap: 0.4rem;
  color: var(--color-text);
  font-size: 0.8rem;
  line-height: 1.45;
}

.cookie-info-icon { flex-shrink: 0; margin-top: 1px; }

.cookie-check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--color-text);
}

.cookie-check-row input[type="checkbox"] {
  margin-top: 2px;
  accent-color: #ce003d;
  flex-shrink: 0;
}

.cookie-check-row.disabled {
  opacity: 0.6;
  cursor: default;
}

.cookie-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.cookie-actions button {
  flex: 1;
  padding: 0.55rem 0;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font-base);
  font-size: 0.85rem;
  font-weight: 600;
  transition: opacity 0.15s;
}

#cookie-accept {
  background: linear-gradient(112deg, #ce003d 0%, #edb553 100%);
  color: #fff;
}

#cookie-decline {
  background: transparent;
  color: var(--color-text);
  border: 1px solid rgba(19, 36, 64, 0.2) !important;
}

.cookie-actions button:hover { opacity: 0.85; }

/* Mobile */
@media (max-width: 480px) {
  #louise-chat-widget {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
  }

  #chat-panel {
    width: 100%;
    right: 0;
    left: 0;
    height: 70vh;
  }
}
