/* ══════════════════════════════════════════════════════════════════════════
   CÁRUTA AI BY DAMERAX — Clean, Mobile-First Conversational Assistant CSS
   ══════════════════════════════════════════════════════════════════════════ */

/* Floating Launcher Button */
.caruta-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #2563eb;
  color: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

.caruta-launcher:hover {
  transform: scale(1.06);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.45);
}

.caruta-launcher:active {
  transform: scale(0.96);
}

.caruta-launcher-icon {
  width: 32px;
  height: 32px;
  fill: currentColor;
}

.caruta-launcher-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: #10b981;
  border: 2.5px solid #ffffff;
  border-radius: 50%;
}

/* Chat Overlay / Window Container */
.caruta-chat-modal {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 450px;
  max-width: calc(100vw - 32px);
  height: 680px;
  max-height: calc(100vh - 110px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.16), 0 0 1px rgba(15, 23, 42, 0.08);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 100000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  animation: carutaSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: width 0.2s ease, height 0.2s ease;
}

.caruta-chat-modal.is-open {
  display: flex;
}

/* Expanded Desktop State */
.caruta-chat-modal.is-expanded {
  width: 580px;
  height: calc(100vh - 80px);
  max-height: calc(100vh - 80px);
  bottom: 40px;
}

@keyframes carutaSlideIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Mobile Screen Fullscreen & Pinned Input Bar Fix */
@media (max-width: 640px) {
  .caruta-desktop-only-btn {
    display: none !important;
  }
  .caruta-chat-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    height: 100% !important;
    height: 100dvh !important;
    height: -webkit-fill-available !important;
    max-height: 100% !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    display: none;
    flex-direction: column !important;
    z-index: 9999999 !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
  }
  .caruta-chat-modal.is-open {
    display: flex !important;
  }
  .caruta-header {
    flex-shrink: 0 !important;
    padding-top: max(12px, env(safe-area-inset-top, 12px)) !important;
  }
  .caruta-messages-container {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
  }
  .caruta-input-area {
    flex-shrink: 0 !important;
    padding: 10px 14px !important;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px)) !important;
    background: #ffffff !important;
    position: relative !important;
    z-index: 999 !important;
    border-top: 1px solid #e2e8f0 !important;
    box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.06) !important;
  }
}

/* Header */
.caruta-header {
  padding: 14px 18px;
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.caruta-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.caruta-avatar-wrapper {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #eff6ff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #dbeafe;
}

.caruta-avatar-svg {
  width: 26px;
  height: 26px;
  color: #2563eb;
}

.caruta-header-titles {
  display: flex;
  flex-direction: column;
}

.caruta-header-brand {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}

.caruta-header-brand span {
  color: #2563eb;
}

.caruta-header-byline {
  font-size: 0.72rem;
  color: #64748b;
  line-height: 1.2;
}

.caruta-header-tagline {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 1px;
}

.caruta-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.caruta-online-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: #10b981;
  font-weight: 500;
}

.caruta-online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
}

.caruta-icon-btn {
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.caruta-icon-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

/* Chat Messages Stream */
.caruta-messages-container {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Custom minimal scrollbar */
.caruta-messages-container::-webkit-scrollbar {
  width: 5px;
}
.caruta-messages-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

/* Message Rows */
.caruta-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 92%;
  animation: carutaFadeIn 0.2s ease;
}

@keyframes carutaFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.caruta-msg-row.caruta-bot-row {
  align-self: flex-start;
}

.caruta-msg-row.caruta-user-row {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.caruta-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 4px;
}

.caruta-msg-avatar svg {
  width: 18px;
  height: 18px;
  color: #2563eb;
}

.caruta-msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}

.caruta-bot-bubble {
  background: #ffffff;
  color: #1e293b;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  border: 1px solid #f1f5f9;
}

.caruta-user-bubble {
  background: #2563eb;
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.caruta-msg-meta {
  font-size: 0.68rem;
  color: #94a3b8;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.caruta-user-row .caruta-msg-meta {
  justify-content: flex-end;
}

.caruta-checkmarks {
  color: #2563eb;
  font-size: 0.72rem;
  font-weight: bold;
}

/* Compact Product Cards Inline Stream */
.caruta-products-carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 8px 4px 12px 4px;
  margin-top: 6px;
  width: 100%;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.caruta-products-carousel::-webkit-scrollbar {
  height: 4px;
}
.caruta-products-carousel::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 4px;
}

.caruta-product-card {
  flex: 0 0 170px;
  max-width: 170px;
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.caruta-product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.06);
}

.caruta-card-img-wrap {
  width: 100%;
  aspect-ratio: 1 / 0.85;
  background: #f1f5f9;
  position: relative;
  overflow: hidden;
}

.caruta-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.caruta-card-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.caruta-card-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
  min-height: 32px;
}

.caruta-card-tags {
  font-size: 0.7rem;
  color: #64748b;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.caruta-card-price {
  font-size: 0.95rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 8px;
}

.caruta-card-btn {
  display: block;
  width: 100%;
  text-align: center;
  background: #eff6ff;
  color: #2563eb;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 7px 0;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  border: none;
  cursor: pointer;
  margin-top: auto;
}

.caruta-card-btn:hover {
  background: #2563eb;
  color: #ffffff;
}

/* Typing Indicator */
.caruta-typing-row {
  display: none;
  align-items: flex-end;
  gap: 8px;
  align-self: flex-start;
}

.caruta-typing-bubble {
  background: #ffffff;
  border: 1px solid #f1f5f9;
  padding: 10px 14px;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.caruta-typing-dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: carutaBounce 1.2s infinite ease-in-out;
}
.caruta-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.caruta-typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* Input Bar */
.caruta-input-area {
  padding: 12px 16px;
  background: #ffffff;
  border-top: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.caruta-input-box {
  flex: 1;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 0.92rem;
  color: #0f172a;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.caruta-input-box:focus {
  border-color: #2563eb;
  background: #ffffff;
}

.caruta-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #2563eb;
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
  outline: none;
}

.caruta-send-btn:hover {
  background: #1d4ed8;
  transform: scale(1.05);
}

.caruta-send-btn:active {
  transform: scale(0.95);
}

.caruta-send-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}
