/* ==========================================================================
   TNN AI CHATBOT PRO V3.0 - STYLES (CUSTOMIZABLE + 3 WINDOW SIZES)
   ========================================================================== */
:root {
  --tnn-cb-primary: #0284c7;
  --tnn-cb-secondary: #1e40af;
  --tnn-cb-primary-hover: #0369a1;
  --tnn-cb-bg: #ffffff;
  --tnn-cb-text: #1e293b;
  --tnn-cb-text-light: #64748b;
  --tnn-cb-shadow: 0 12px 32px -4px rgba(15, 23, 42, 0.22), 0 8px 14px -6px rgba(15, 23, 42, 0.12);
  --tnn-cb-radius: 18px;
  --tnn-cb-font: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --tnn-cb-font-size: 14.5px;
}

/* Floating Trigger Button */
.tnn-chatbot-toggle {
  position: fixed;
  bottom: 105px;
  right: 24px;
  z-index: 999990;
  height: 54px;
  padding: 0 18px 0 14px;
  border-radius: 30px;
  background: linear-gradient(135deg, var(--tnn-cb-primary) 0%, var(--tnn-cb-secondary) 100%);
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.85);
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(2, 132, 199, 0.45);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--tnn-cb-font);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
}

.tnn-chatbot-toggle svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
  flex-shrink: 0;
}

.tnn-chatbot-toggle img.tnn-toggle-logo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid #ffffff;
  flex-shrink: 0;
}

.tnn-chatbot-toggle.position-left {
  right: auto;
  left: 24px;
  bottom: 105px;
}

.tnn-chatbot-toggle:hover {
  transform: scale(1.06) translateY(-2px);
  box-shadow: 0 12px 28px rgba(2, 132, 199, 0.55);
}

.tnn-chatbot-toggle .badge-pulse {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: #22c55e;
  border: 2px solid #ffffff;
  border-radius: 50%;
  animation: tnn-pulse 2s infinite;
}

@keyframes tnn-pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Chat Window - Normal View (Default: 380x580) */
.tnn-chatbot-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 999992;
  width: 385px;
  height: 580px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 120px);
  background: var(--tnn-cb-bg);
  border-radius: var(--tnn-cb-radius);
  box-shadow: var(--tnn-cb-shadow);
  font-family: var(--tnn-cb-font);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: width 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              height 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.25s ease,
              transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.25s;
}

.tnn-chatbot-window.position-left {
  right: auto;
  left: 24px;
}

.tnn-chatbot-window.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Mode 1: Minimized View (Ấn xuống - Thu gọn thành thanh ngang dưới đáy) */
.tnn-chatbot-window.is-open.is-minimized {
  width: 330px;
  height: 66px !important;
  bottom: 24px;
  border-radius: 34px;
  cursor: pointer;
}

.tnn-chatbot-window.is-minimized .tnn-chatbot-messages,
.tnn-chatbot-window.is-minimized .tnn-chatbot-input-bar {
  display: none !important;
}

.tnn-chatbot-window.is-minimized .tnn-chatbot-header {
  padding: 12px 16px;
  height: 100%;
}

/* Mode 3: Maximized View (Phóng to - Xem bảng giá & lộ trình rộng rãi) */
.tnn-chatbot-window.is-open.is-maximized {
  width: 760px;
  height: 82vh;
  max-height: 780px;
  bottom: 24px;
}

/* Header */
.tnn-chatbot-header {
  background: linear-gradient(135deg, var(--tnn-cb-primary) 0%, var(--tnn-cb-secondary) 100%);
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.tnn-chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
  cursor: pointer;
}

.tnn-chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  flex-shrink: 0;
  overflow: hidden;
}

.tnn-chatbot-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tnn-chatbot-header-text {
  min-width: 0;
}

.tnn-chatbot-header-text h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tnn-chatbot-header-text p {
  margin: 2px 0 0 0;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.88);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tnn-chatbot-header-text p::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Header Action Buttons (Ấn xuống, Xem cơ bản, Phóng to, Đóng) */
.tnn-chatbot-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.tnn-chatbot-ctrl-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
  width: 28px;
  height: 28px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  transition: all 0.2s ease;
}

.tnn-chatbot-ctrl-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

.tnn-chatbot-ctrl-btn.is-active {
  background: #ffffff;
  color: var(--tnn-cb-primary);
  border-color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.tnn-chatbot-ctrl-btn.btn-close:hover {
  background: #ef4444;
  border-color: #ef4444;
  color: #ffffff;
}

/* Body / Message List */
.tnn-chatbot-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
  scroll-behavior: smooth;
}

.tnn-chat-msg {
  display: flex;
  gap: 8px;
  max-width: 86%;
  animation: tnn-msg-in 0.25s ease forwards;
}

.tnn-chatbot-window.is-maximized .tnn-chat-msg {
  max-width: 78%;
}

@keyframes tnn-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.tnn-chat-msg.bot {
  align-self: flex-start;
}

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

.tnn-chat-bubble {
  padding: 11px 15px;
  border-radius: 14px;
  font-size: var(--tnn-cb-font-size);
  line-height: 1.55;
  word-break: break-word;
}

.tnn-chat-msg.bot .tnn-chat-bubble {
  background: #ffffff;
  color: var(--tnn-cb-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  border: 1px solid #e2e8f0;
}

.tnn-chat-msg.user .tnn-chat-bubble {
  background: linear-gradient(135deg, var(--tnn-cb-primary) 0%, var(--tnn-cb-secondary) 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

/* Quick Suggestion Chips */
.tnn-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.tnn-chip-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--tnn-cb-primary);
  font-family: var(--tnn-cb-font);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.tnn-chip-btn:hover {
  background: var(--tnn-cb-primary);
  color: #ffffff;
  border-color: var(--tnn-cb-primary);
  transform: translateY(-1px);
}

/* Typing indicator */
.tnn-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #ffffff;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  border: 1px solid #e2e8f0;
}

.tnn-typing-dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: tnn-typing 1.4s infinite ease-in-out;
}

.tnn-typing-dot:nth-child(1) { animation-delay: 0s; }
.tnn-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.tnn-typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* Input Bar */
.tnn-chatbot-input-bar {
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.tnn-chatbot-input-bar textarea {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 22px;
  padding: 10px 16px;
  font-size: var(--tnn-cb-font-size);
  resize: none;
  max-height: 90px;
  min-height: 42px;
  height: 42px;
  outline: none;
  font-family: var(--tnn-cb-font);
  transition: border-color 0.2s;
}

.tnn-chatbot-input-bar textarea:focus {
  border-color: var(--tnn-cb-primary);
}

.tnn-chatbot-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--tnn-cb-primary) 0%, var(--tnn-cb-secondary) 100%);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.tnn-chatbot-send-btn:hover {
  transform: scale(1.05);
  filter: brightness(1.08);
}

.tnn-chatbot-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Mobile Responsive */
@media (max-width: 600px) {
  .tnn-chatbot-window,
  .tnn-chatbot-window.is-open.is-maximized {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    height: 85vh;
    max-width: 100vw;
    max-height: 92vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  .tnn-chatbot-window.is-open.is-minimized {
    width: calc(100vw - 24px);
    left: 12px;
    right: 12px;
    bottom: 16px;
    border-radius: 34px;
  }
}
