/**
 * @file
 * LayosCamp AI Chatbot widget styles.
 *
 * Brand colors:
 *   Primary green: #8BA841
 *   Light green:   #A4C256
 *   Dark green:    #6B8A2F
 *   Background:    #F0F4E8
 *   Dark text:     #2D5016
 *   Font:          'Inter', sans-serif
 *
 * Position: bottom-LEFT (right side is reserved for the "Inscribete" CTA).
 * z-index: 8999 (below popup at 9000 but above normal content).
 */

/* ---------------------------------------------------------------------------
   Chat bubble (floating button)
   --------------------------------------------------------------------------- */

.lc-chat-bubble {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 8999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #8BA841;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
}

.lc-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  background: #A4C256;
}

.lc-chat-bubble:active {
  transform: scale(0.96);
}

.lc-chat-bubble--hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.5);
}

/* ---------------------------------------------------------------------------
   Chat panel
   --------------------------------------------------------------------------- */

.lc-chat-panel {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 8999;
  width: 360px;
  height: 520px;
  max-height: calc(100vh - 40px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.lc-chat-panel--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---------------------------------------------------------------------------
   Header
   --------------------------------------------------------------------------- */

.lc-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #8BA841;
  color: #fff;
  flex-shrink: 0;
}

.lc-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lc-chat-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lc-chat-header-avatar svg {
  stroke: #fff;
}

.lc-chat-header strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

.lc-chat-header-status {
  display: block;
  font-size: 12px;
  opacity: 0.85;
}

.lc-chat-close {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.lc-chat-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ---------------------------------------------------------------------------
   Messages area
   --------------------------------------------------------------------------- */

.lc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  background: #F0F4E8;
  scroll-behavior: smooth;
}

.lc-chat-msg {
  display: flex;
  align-items: flex-end;
  margin-bottom: 10px;
  gap: 8px;
}

.lc-chat-msg--user {
  justify-content: flex-end;
}

.lc-chat-msg--bot {
  justify-content: flex-start;
}

.lc-chat-msg--error {
  justify-content: center;
}

/* Avatar for bot messages */
.lc-chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Message bubbles */
.lc-chat-msg-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 16px;
  word-break: break-word;
}

.lc-chat-msg-bubble--user {
  background: #8BA841;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.lc-chat-msg-bubble--bot {
  background: #fff;
  color: #2D5016;
  border: 1px solid #dde6cc;
  border-bottom-left-radius: 4px;
}

.lc-chat-msg-bubble--bot p {
  margin: 0 0 6px 0;
}

.lc-chat-msg-bubble--bot p:last-child {
  margin-bottom: 0;
}

.lc-chat-msg-bubble--bot ul,
.lc-chat-msg-bubble--bot ol {
  margin: 4px 0;
  padding-left: 20px;
}

.lc-chat-msg-bubble--bot li {
  margin-bottom: 2px;
}

.lc-chat-msg-bubble--bot a {
  color: #6B8A2F;
  text-decoration: underline;
}

.lc-chat-msg-bubble--bot a:hover {
  color: #8BA841;
}

.lc-chat-msg-bubble--bot strong {
  font-weight: 600;
}

/* Quick action buttons in bot messages */
.lc-chat-quick-btn {
  display: block;
  width: 100%;
  margin: 4px 0;
  padding: 10px 16px;
  background: #fff;
  color: #2D5016;
  border: 1.5px solid #8BA841;
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.lc-chat-quick-btn:hover {
  background: #F0F4E8;
  border-color: #6B8A2F;
}

.lc-chat-quick-btn:active {
  background: #8BA841;
  color: #fff;
}

.lc-chat-quick-btn--selected {
  background: #8BA841 !important;
  color: #fff !important;
  border-color: #6B8A2F !important;
}

.lc-chat-quick-btn--used {
  opacity: 0.5;
  pointer-events: none;
}

/* Links in chat messages */
.lc-chat-link {
  color: #8BA841;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.lc-chat-link:hover {
  color: #6B8A2F;
}

.lc-chat-msg-bubble--bot .lc-chat-link {
  color: #2D5016;
}

.lc-chat-msg-bubble--error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  font-size: 13px;
  border-radius: 10px;
  text-align: center;
  max-width: 90%;
}

/* ---------------------------------------------------------------------------
   Typing indicator
   --------------------------------------------------------------------------- */

.lc-chat-typing-bubble {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
}

.lc-chat-typing-text {
  font-size: 13px;
  color: #6B8A2F;
  font-style: italic;
}

.lc-chat-typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.lc-chat-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8BA841;
  animation: lc-typing-bounce 1.2s infinite ease-in-out;
}

.lc-chat-typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.lc-chat-typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes lc-typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* ---------------------------------------------------------------------------
   Input bar
   --------------------------------------------------------------------------- */

.lc-chat-input-bar {
  display: flex;
  align-items: flex-end;
  padding: 10px 12px;
  gap: 8px;
  background: #fff;
  border-top: 1px solid #e5ecd4;
  flex-shrink: 0;
}

.lc-chat-input {
  flex: 1;
  border: 1px solid #cdd8b3;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 16px;  /* MUST be 16px to prevent iOS Safari auto-zoom */
  font-family: inherit;
  line-height: 1.4;
  resize: none;
  outline: none;
  max-height: 80px;
  overflow-y: auto;
  transition: border-color 0.15s ease;
  background: #fafdf5;
  color: #2D5016;
  -webkit-text-size-adjust: 100%;
}

.lc-chat-input::placeholder {
  color: #99a87a;
}

.lc-chat-input:focus {
  border-color: #8BA841;
  box-shadow: 0 0 0 2px rgba(139, 168, 65, 0.15);
}

.lc-chat-send {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  border: none;
  background: #8BA841;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s ease, transform 0.15s ease;
}

.lc-chat-send:hover {
  background: #6B8A2F;
  transform: scale(1.05);
}

.lc-chat-send:active {
  transform: scale(0.95);
}

/* ---------------------------------------------------------------------------
   Admin toolbar offset — Drupal admin toolbar pushes content down
   --------------------------------------------------------------------------- */

body.toolbar-horizontal .lc-chat-bubble,
body.toolbar-horizontal .lc-chat-panel {
  /* Don't show chatbot when admin toolbar is active */
}

/* ---------------------------------------------------------------------------
   Responsive — full-width on mobile
   --------------------------------------------------------------------------- */

@media (max-width: 480px) {
  .lc-chat-panel {
    position: fixed;
    width: 100%;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: 60%;
    max-height: 60%;
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
  }

  /* Messages area scrolls */
  .lc-chat-panel .lc-chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  /* Input bar always at bottom of panel */
  .lc-chat-panel .lc-chat-input-bar {
    flex-shrink: 0;
    padding: 8px 12px;
  }

  /* When keyboard is open (class added by JS) */
  .lc-chat-panel.lc-keyboard-open {
    position: fixed;
    bottom: 0;
    height: 45%;
    max-height: 45%;
  }

  .lc-chat-bubble {
    bottom: 16px;
    left: 16px;
    width: 52px;
    height: 52px;
  }

  /* Camp detail: move bubble above the sticky date selector */
  .page-node-type-detalle-de-campamento .lc-chat-bubble {
    bottom: 140px;
  }

  .lc-chat-msg-bubble {
    max-width: 85%;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .lc-chat-panel {
    width: 320px;
    height: 480px;
  }

  /* Camp detail: move bubble above the sticky date selector */
  .page-node-type-detalle-de-campamento .lc-chat-bubble {
    bottom: 140px;
  }
}

/* ---------------------------------------------------------------------------
   Scrollbar styling
   --------------------------------------------------------------------------- */

.lc-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.lc-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.lc-chat-messages::-webkit-scrollbar-thumb {
  background: #c5d4a0;
  border-radius: 3px;
}

.lc-chat-messages::-webkit-scrollbar-thumb:hover {
  background: #8BA841;
}

/* ---------------------------------------------------------------------------
   Print — hide chatbot
   --------------------------------------------------------------------------- */

@media print {
  .lc-chat-bubble,
  .lc-chat-panel {
    display: none !important;
  }
}
