/* =========================================================================
   TIBE.FOOD CHATBOT WIDGET
   ========================================================================= */

.tibe-chat-toggle {
  position: fixed;
  right: 22px;
  bottom: 154px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, #FF8533 100%);
  color: #FFFFFF;
  border: 2.5px solid #FFFFFF;
  box-shadow: 0 8px 24px var(--primary-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  cursor: pointer;
  font-size: 1.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tibe-chat-toggle:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 28px var(--primary-glow);
}

.tibe-chat-toggle:active {
  transform: scale(0.95);
}

.tibe-chat-toggle .tibe-chat-close-icon {
  display: none;
}

.tibe-chat-toggle.open .tibe-chat-bubble-icon {
  display: none;
}

.tibe-chat-toggle.open .tibe-chat-close-icon {
  display: block;
}

.tibe-chat-ping {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #E53935;
  border: 2px solid #FFFFFF;
  animation: tibePulse 1.8s ease-in-out infinite;
}

@keyframes tibePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.7; }
}

.tibe-chat-window {
  position: fixed;
  right: 22px;
  bottom: 222px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 500px;
  max-height: calc(100vh - 260px);
  background: #FFFFFF;
  border-radius: var(--radius-card);
  box-shadow: 0 20px 50px rgba(61, 28, 6, 0.28);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 1199;
  border: 1px solid var(--border-light, #F0E4D8);
  font-family: var(--font-body);
}

.tibe-chat-window.open {
  display: flex;
  animation: tibeSlideUp 0.25s ease;
}

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

.tibe-chat-header {
  background: linear-gradient(135deg, var(--primary) 0%, #FF8533 100%);
  color: #FFFFFF;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

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

.tibe-chat-header-text {
  flex: 1;
  min-width: 0;
}

.tibe-chat-header-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.98rem;
  line-height: 1.2;
}

.tibe-chat-header-status {
  font-size: 0.74rem;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 5px;
}

.tibe-chat-header-status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7CFC7C;
  display: inline-block;
}

.tibe-chat-header-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #FFFFFF;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}

.tibe-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #FFF9F2;
}

.tibe-msg-row {
  display: flex;
  gap: 8px;
  max-width: 100%;
}

.tibe-msg-row.bot {
  justify-content: flex-start;
}

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

.tibe-msg-bubble {
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 0.85rem;
  line-height: 1.5;
  max-width: 82%;
  white-space: pre-wrap;
}

.tibe-msg-row.bot .tibe-msg-bubble {
  background: #FFFFFF;
  color: var(--text-dark);
  border: 1px solid #F0E4D8;
  border-bottom-left-radius: 4px;
}

.tibe-msg-row.user .tibe-msg-bubble {
  background: var(--primary);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
}

.tibe-msg-bubble strong {
  color: inherit;
}

.tibe-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 2px 4px;
}

.tibe-chip {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid #FFD8A8;
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.tibe-chip:hover {
  background: #FFE4C2;
}

.tibe-chat-cta-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #F0E4D8;
  background: #FFFFFF;
  flex-shrink: 0;
}

.tibe-cta-btn {
  flex: 1;
  border: none;
  border-radius: var(--radius-pill);
  padding: 9px 8px;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.tibe-cta-btn.primary {
  background: var(--primary);
  color: #FFFFFF;
}

.tibe-cta-btn.secondary {
  background: #E8F5E9;
  color: #1B5E20;
}

.tibe-chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #F0E4D8;
  background: #FFFFFF;
  flex-shrink: 0;
}

.tibe-chat-input {
  flex: 1;
  border: 1.5px solid #F0E4D8;
  border-radius: var(--radius-pill);
  padding: 9px 14px;
  font-size: 0.85rem;
  font-family: var(--font-body);
  outline: none;
  min-width: 0;
}

.tibe-chat-input:focus {
  border-color: var(--primary);
}

.tibe-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}

.tibe-typing {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
}

.tibe-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.5;
  animation: tibeTypingBounce 1s infinite ease-in-out;
}

.tibe-typing span:nth-child(2) { animation-delay: 0.15s; }
.tibe-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes tibeTypingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 480px) {
  .tibe-chat-toggle {
    right: 14px;
    bottom: 134px;
    width: 48px;
    height: 48px;
    font-size: 1.3rem;
  }

  .tibe-chat-window {
    right: 10px;
    left: 10px;
    bottom: 190px;
    width: auto;
    max-width: none;
    height: auto;
    max-height: calc(100vh - 220px);
  }
}
