/* ============================================================
   CHAT — Chat IA View Styles
   ============================================================ */


/* --- Chat Header --- */
.chat-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.chat-header__avatar {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}
.chat-header__avatar svg {
  width: 22px;
  height: 22px;
}

.chat-header__info {
  flex: 1;
}
.chat-header__title {
  font-size: var(--font-md);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.chat-header__title .dot-online {
  width: 8px;
  height: 8px;
  background: var(--accent-green);
  border-radius: var(--radius-full);
}
.chat-header__subtitle {
  font-size: var(--font-xs);
  color: var(--text-secondary);
}

.chat-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

#btnChatCart {
  display: none;
}


/* --- Chat Messages Area --- */
.chat-messages {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}


/* --- Chat Bubble --- */
.chat-bubble {
  display: flex;
  gap: var(--space-3);
  max-width: 85%;
  animation: fadeInUp 300ms ease both;
}

/* IA message (left) */
.chat-bubble--ia {
  align-self: flex-start;
}
.chat-bubble--ia .chat-bubble__avatar {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}
.chat-bubble--ia .chat-bubble__avatar svg {
  width: 20px;
  height: 20px;
}
.chat-bubble--ia .chat-bubble__content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 4px;
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-sm);
}

/* User message (right) */
.chat-bubble--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.chat-bubble--user .chat-bubble__content {
  background: var(--primary-light);
  border-radius: var(--radius-lg);
  border-bottom-right-radius: 4px;
  padding: var(--space-3) var(--space-4);
}

.chat-bubble__text {
  font-size: var(--font-base);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
}
.chat-bubble__text strong {
  font-weight: 700;
}

.chat-bubble__time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: var(--space-1);
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-bubble--user .chat-bubble__time {
  justify-content: flex-end;
}
.chat-bubble__time .checks {
  color: var(--accent-blue);
}


/* --- Products in Chat (grid wrap) --- */
.chat-products {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  padding: var(--space-3) 0;
  margin-top: var(--space-2);
  width: 100%;
}

@media (max-width: 600px) {
  .chat-products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.chat-products .product-mini {
  width: 100% !important;
  flex-shrink: 1;
}


/* --- Quick Action Buttons (below IA message) --- */
.chat-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}


/* --- Chat Input Area --- */
.chat-input-area {
  padding: var(--space-3) var(--space-5);
  background: var(--bg-card);
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

.chat-input-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--bg-body);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 6px 6px var(--space-5);
  transition: border-color var(--transition-fast);
}
.chat-input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,63,199,0.08);
}

.chat-input {
  flex: 1;
  background: transparent;
  font-size: var(--font-base);
  color: var(--text-primary);
  padding: var(--space-2) 0;
}
.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-input-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.chat-input-actions button {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  transition: all var(--transition-fast);
}
.chat-input-actions button:hover {
  color: var(--primary);
  background: var(--primary-light);
}
.chat-send-btn {
  background: var(--primary) !important;
  color: white !important;
}
.chat-send-btn:hover {
  background: var(--primary-dark) !important;
}

.chat-disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: var(--space-2) 0 0;
}


/* --- Chat Sidebar (recommended products) --- */
.chat-sidebar-products {
  padding: var(--space-5);
}
.chat-sidebar-products h3 {
  font-size: var(--font-md);
  font-weight: 700;
  margin-bottom: 2px;
}
.chat-sidebar-products p {
  font-size: var(--font-xs);
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
}
.chat-sidebar-products .product-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.chat-sidebar-products .product-card {
  box-shadow: none;
  border: 1px solid var(--border-light);
}
.chat-sidebar-products .product-card__image-wrap {
  padding-top: 65%;
}
.chat-sidebar-products .product-card__actions {
  flex-direction: column;
}

.chat-sidebar-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4);
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}
.chat-sidebar-more:hover {
  text-decoration: underline;
}


/* --- Order Panel (right side in chat view) --- */
.order-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.order-panel__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--border-light);
}
.order-panel__header svg {
  width: 22px;
  height: 22px;
}
.order-panel__header h2 {
  font-size: var(--font-md);
  font-weight: 700;
  flex: 1;
}

.order-panel__items {
  flex: 1;
  padding: var(--space-3) var(--space-5);
  overflow-y: auto;
}

.order-panel__summary {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-light);
}

.order-panel__actions {
  padding: 0 var(--space-5) var(--space-4);
}
.order-panel__actions .btn {
  width: 100%;
}

.order-panel__help {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-light);
}
.order-panel__help h3 {
  font-size: var(--font-sm);
  font-weight: 700;
  margin-bottom: var(--space-1);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.order-panel__help p {
  font-size: var(--font-xs);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}

.order-panel__help-items {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-3);
}
.order-panel__help-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--font-sm);
}
.order-panel__help-item svg {
  width: 18px;
  height: 18px;
  color: var(--primary);
  flex-shrink: 0;
}


/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
  .chat-layout {
    overflow-x: hidden !important;
  }
  .chat-layout__main {
    overflow-x: hidden !important;
  }
  .chat-header {
    padding: var(--space-3) var(--space-4);
    overflow: hidden;
    min-width: 0;
    gap: var(--space-2);
  }
  .chat-messages {
    padding: var(--space-3);
  }
  .chat-input-area {
    padding: var(--space-3) var(--space-4);
  }
  .chat-disclaimer {
    display: none !important;
  }
  .chat-bubble {
    max-width: 92%;
  }

  /* Mobile: show back button in chat header */
  .chat-header__back {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    color: var(--text-primary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background var(--transition-fast);
    flex-shrink: 0;
  }
  .chat-header__back:active {
    background: var(--primary-light);
    color: var(--primary);
  }

  .chat-header__info {
    min-width: 0;
  }
  .chat-header__title {
    font-size: var(--font-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .chat-header__actions {
    gap: var(--space-1);
    flex-shrink: 0;
  }

  /* Hide Ocultar chat button on mobile since we have the back arrow */
  #btnHideChat {
    display: none !important;
  }

  /* Make Escalar button circular and icon-only on mobile */
  #btnEscalate {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-full);
    min-width: 36px;
  }
  #btnEscalate .btn-text {
    display: none !important;
  }
  #btnEscalate svg {
    margin: 0 !important;
  }

  /* Compact three dots menu button */
  .chat-header__actions .btn-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
  }

  #btnChatCart {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    position: relative;
  }
}

@media (min-width: 769px) {
  .chat-header__back {
    display: none;
  }
}

/* ============================================================
   FLOATING CHAT BUTTON (PREMIUM & PULSING)
   ============================================================ */
.floating-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #09cc7a 0%, #05a762 100%);
  color: white;
  border: none;
  box-shadow: 0 4px 16px rgba(9, 204, 122, 0.4);
  cursor: pointer;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.25s, box-shadow 0.25s;
  outline: none;
}

.floating-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(9, 204, 122, 0.6);
}

.floating-chat-btn:active {
  transform: scale(0.95);
}

/* Pulsing effect */
.floating-chat-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  border: 2.5px solid #09cc7a;
  animation: chatPulse 2s infinite;
  box-sizing: border-box;
  z-index: -1;
  opacity: 0.6;
}

@keyframes chatPulse {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

/* Responsive adjustment: position on mobile to avoid overlapping the bottom menu */
@media (max-width: 768px) {
  .floating-chat-btn {
    bottom: 84px; /* Sits nicely above mobileNav (which has bottom: 0) and the mobileCartBar */
    right: 18px;
    width: 50px;
    height: 50px;
    box-shadow: 0 3px 12px rgba(9, 204, 122, 0.4);
  }
}
