/* ===============================================================
   TOYZGURU CORE AI CHATBOT WIDGET STYLES
   =============================================================== */

/* --- Keyframe Animations --- */
@keyframes tg-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.7), 0 8px 30px rgba(139, 92, 246, 0.35);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(139, 92, 246, 0), 0 8px 30px rgba(139, 92, 246, 0.35);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0), 0 8px 30px rgba(139, 92, 246, 0.35);
  }
}

@keyframes tg-badge-bounce {
  from {
    transform: translateY(0) scale(1);
  }
  to {
    transform: translateY(-4px) scale(1.08);
  }
}

@keyframes tg-msg-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes tg-dot-bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@keyframes tg-glow-line {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* --- Floating Widget Trigger --- */
#tg-bot-trigger {
  position: fixed;
  bottom: 25px;
  right: 25px;
  width: 65px;
  height: 65px;
  border-radius: 50%;
  z-index: 10000;
  cursor: pointer;
  background-color: var(--bg-secondary, #0f1524);
  background-image: url('../favicon.png');
  background-size: 70%;
  background-position: center;
  background-repeat: no-repeat;
  border: 2.5px solid var(--color-brand, #8b5cf6);
  box-shadow: 0 8px 30px rgba(139, 92, 246, 0.35);
  transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  animation: tg-pulse 2s infinite;
}

#tg-bot-trigger:hover {
  transform: scale(1.12) rotate(8deg);
  border-color: #d946ef; /* Cyber Pink */
  box-shadow: 0 0 25px rgba(217, 70, 239, 0.6), 0 8px 30px rgba(139, 92, 246, 0.5);
}

#tg-bot-trigger:active {
  transform: scale(0.95);
}

/* --- Trigger Badge Notification --- */
.tg-bot-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: var(--color-danger, #ef4444);
  color: #ffffff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1.5px solid var(--bg-primary, #080b11);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
  animation: tg-badge-bounce 1s infinite alternate;
  pointer-events: none;
}

/* --- Chat Window Panel --- */
#tg-bot-window {
  position: fixed;
  bottom: 105px;
  right: 25px;
  width: 390px;
  max-width: calc(100vw - 50px);
  height: 570px;
  max-height: calc(100vh - 150px);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  background: rgba(15, 21, 36, 0.82);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1.5px solid var(--glass-border, rgba(255, 255, 255, 0.07));
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  transform-origin: bottom right;
  transition: all 0.4s cubic-bezier(0.075, 0.82, 0.165, 1);
  opacity: 0;
  transform: scale(0) translateY(80px);
  pointer-events: none;
}

#tg-bot-window.active {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: all;
}

/* --- Glowing Header Line --- */
.tg-bot-glow-line {
  height: 2px;
  width: 100%;
  background: linear-gradient(90deg, #8b5cf6, #d946ef, #06b6d4, #8b5cf6);
  background-size: 300% 300%;
  animation: tg-glow-line 4s ease infinite;
}

/* --- Chat Header --- */
.tg-bot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(217, 70, 239, 0.15) 100%);
  border-bottom: 1px solid var(--glass-border, rgba(255, 255, 255, 0.07));
}

.tg-bot-profile-info {
  display: flex;
  align-items: center;
}

.tg-bot-avatar-wrap {
  position: relative;
  margin-right: 0.85rem;
}

.tg-bot-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-tertiary, #172033);
  border: 1.5px solid var(--color-brand, #8b5cf6);
  display: block;
  object-fit: contain;
  padding: 2px;
}

.tg-bot-online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--color-success, #10b981);
  border: 2px solid #0f1524;
  box-shadow: 0 0 8px var(--color-success);
}

.tg-bot-title-area {
  display: flex;
  flex-direction: column;
}

.tg-bot-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary, #f3f4f6);
  line-height: 1.2;
}

.tg-bot-status {
  font-size: 0.72rem;
  color: var(--text-muted, #6b7280);
}

.tg-bot-status.typing {
  color: var(--color-brand, #8b5cf6);
  font-weight: 600;
}

.tg-bot-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tg-bot-action-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.07));
  color: var(--text-secondary, #9ca3af);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast, 0.2s);
}

.tg-bot-action-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--color-danger, #ef4444);
}

/* --- Messages Area --- */
.tg-bot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

/* Scrollbars customization for messages list */
.tg-bot-messages::-webkit-scrollbar {
  width: 5px;
}

.tg-bot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.tg-bot-messages::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary, #172033);
  border-radius: 3px;
}

.tg-bot-messages::-webkit-scrollbar-thumb:hover {
  background: var(--color-brand, #8b5cf6);
}

/* --- Message Bubbles --- */
.tg-bot-msg {
  max-width: 82%;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  font-size: 0.85rem;
  line-height: 1.55;
  word-wrap: break-word;
  animation: tg-msg-in 0.32s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

.tg-bot-msg.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.07));
  border-top-left-radius: 2px;
  color: var(--text-primary, #f3f4f6);
}

.tg-bot-msg.user {
  align-self: flex-end;
  background: var(--color-brand-gradient, linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%));
  border-top-right-radius: 2px;
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.15);
}

.tg-bot-msg p {
  margin: 0 0 0.5rem;
}

.tg-bot-msg p:last-child {
  margin-bottom: 0;
}

.tg-bot-msg strong {
  color: #ffffff;
}

.tg-bot-msg.user strong {
  color: inherit;
  font-weight: 700;
}

/* Timestamp inside bubbles */
.tg-bot-time {
  font-size: 0.68rem;
  opacity: 0.5;
  margin-top: 0.35rem;
  display: block;
  text-align: right;
}

.tg-bot-msg.bot .tg-bot-time {
  color: var(--text-muted, #6b7280);
}

.tg-bot-msg.user .tg-bot-time {
  color: #ffffff;
}

/* --- Embedded Bot Elements (cards, lists) --- */
.tg-bot-product-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.07));
  border-radius: 10px;
  padding: 0.75rem;
  margin-top: 0.6rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.tg-bot-product-thumb {
  width: 55px;
  height: 55px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.05);
  background: var(--bg-tertiary, #172033);
}

.tg-bot-product-info {
  flex: 1;
  min-width: 0;
}

.tg-bot-product-name {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-primary, #f3f4f6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.15rem;
}

.tg-bot-product-prices {
  font-size: 0.78rem;
  font-weight: 700;
}

.tg-bot-product-prices .current {
  color: var(--color-watches, #fbbf24);
}

.tg-bot-product-prices .original {
  text-decoration: line-through;
  color: var(--text-muted, #6b7280);
  margin-left: 0.4rem;
  font-size: 0.72rem;
  font-weight: 500;
}

.tg-bot-msg-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.65rem;
  flex-wrap: wrap;
}

.tg-bot-msg-btn {
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  transition: all var(--transition-fast, 0.2s);
}

.tg-bot-msg-btn.primary {
  background: var(--color-brand-gradient, linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%));
  color: #ffffff;
  border: none;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.25);
}

.tg-bot-msg-btn.primary:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.45);
}

.tg-bot-msg-btn.secondary {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.07));
  color: var(--text-primary, #f3f4f6);
}

.tg-bot-msg-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255,255,255,0.15);
}

/* --- Inline Lead Ticket Form --- */
.tg-bot-ticket-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.6rem;
  width: 100%;
}

.tg-bot-form-input {
  background: rgba(8, 11, 17, 0.5);
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.07));
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
  color: var(--text-primary, #f3f4f6);
  font-size: 0.78rem;
  outline: none;
  transition: border-color var(--transition-fast, 0.2s);
}

.tg-bot-form-input:focus {
  border-color: var(--color-brand, #8b5cf6);
}

.tg-bot-form-textarea {
  resize: vertical;
  min-height: 50px;
}

.tg-bot-form-submit {
  background: var(--color-brand-gradient, linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%));
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.5rem;
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--transition-fast, 0.2s);
}

.tg-bot-form-submit:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

/* --- Suggestion / Quick Reply Chips --- */
.tg-bot-quick-replies-wrap {
  border-top: 1px solid var(--glass-border, rgba(255, 255, 255, 0.07));
  background: rgba(15, 21, 36, 0.5);
  padding: 0.65rem 0.85rem;
}

.tg-bot-quick-replies {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.tg-bot-quick-replies::-webkit-scrollbar {
  height: 3px;
}

.tg-bot-quick-replies::-webkit-scrollbar-track {
  background: transparent;
}

.tg-bot-quick-replies::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary, #172033);
  border-radius: 2px;
}

.tg-bot-chip {
  background: rgba(139, 92, 246, 0.06);
  border: 1px solid rgba(139, 92, 246, 0.2);
  color: var(--text-secondary, #9ca3af);
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast, 0.2s);
}

.tg-bot-chip:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--color-brand, #8b5cf6);
  color: var(--text-primary, #f3f4f6);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.15);
}

/* --- Input Area --- */
.tg-bot-input-panel {
  display: flex;
  align-items: center;
  padding: 0.85rem 1rem;
  background: var(--bg-secondary, #0f1524);
  border-top: 1px solid var(--glass-border, rgba(255, 255, 255, 0.07));
}

.tg-bot-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.07));
  border-radius: 25px;
  padding: 0.65rem 1.1rem;
  color: var(--text-primary, #f3f4f6);
  font-size: 0.82rem;
  outline: none;
  transition: all var(--transition-fast, 0.2s);
  margin-right: 0.75rem;
}

.tg-bot-input:focus {
  border-color: var(--color-brand, #8b5cf6);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.1);
}

.tg-bot-send-btn {
  background: var(--color-brand-gradient, linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%));
  color: #ffffff;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(139, 92, 246, 0.3);
  transition: all var(--transition-fast, 0.2s);
}

.tg-bot-send-btn:hover {
  transform: scale(1.08) translateY(-1px);
  box-shadow: 0 6px 15px rgba(139, 92, 246, 0.45);
}

.tg-bot-send-btn:active {
  transform: scale(0.95);
}

.tg-bot-send-btn svg {
  width: 16px;
  height: 16px;
  stroke: #ffffff;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Typing Indicator Bubble --- */
.tg-bot-typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.1rem;
}

.tg-bot-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--text-secondary, #9ca3af);
  border-radius: 50%;
  animation: tg-dot-bounce 1.4s infinite ease-in-out;
}

.tg-bot-typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.tg-bot-typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
  #tg-bot-trigger {
    bottom: 20px;
    right: 20px;
    width: 55px;
    height: 55px;
  }

  #tg-bot-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
    z-index: 11000; /* overlay above header/modals if needed */
  }

  #tg-bot-window.active {
    transform: scale(1) translateY(0);
  }

  #tg-bot-window {
    transform: scale(0) translateY(100%);
    transform-origin: bottom center;
  }
}

/* ===============================================================
   ADMIN BOT TICKETS PANEL STYLES
   (Appended to bot.css to keep bot-related styles separate)
   =============================================================== */

/* Sidebar badge for unread open tickets count */
.admin-nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-danger, #ef4444);
  color: #fff;
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 0.35rem;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
  animation: tg-badge-bounce 1s infinite alternate;
  vertical-align: middle;
}

/* Ticket card container */
.admin-ticket-card {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.07));
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.admin-ticket-card:hover {
  border-color: rgba(139, 92, 246, 0.25);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.08);
}

.admin-ticket-card.open {
  border-left: 3px solid #f59e0b;
}

.admin-ticket-card.resolved {
  border-left: 3px solid #10b981;
  opacity: 0.8;
}

/* Card header row */
.admin-ticket-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--glass-border, rgba(255, 255, 255, 0.07));
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Avatar initial circle */
.admin-ticket-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Status pill badge */
.admin-ticket-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

/* Card body (description + reply) */
.admin-ticket-card-body {
  padding: 1rem 1.25rem;
}

/* Admin reply preview block */
.admin-ticket-reply-preview {
  margin-top: 0.85rem;
  padding: 0.75rem;
  background: rgba(139, 92, 246, 0.06);
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: 8px;
}

/* Card footer with date and actions */
.admin-ticket-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--glass-border, rgba(255, 255, 255, 0.07));
  background: rgba(0, 0, 0, 0.1);
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Action buttons on each ticket card */
.admin-ticket-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.admin-ticket-btn.reply {
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: #a78bfa;
}

.admin-ticket-btn.reply:hover {
  background: rgba(139, 92, 246, 0.2);
  color: #fff;
}

.admin-ticket-btn.resolve {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
}

.admin-ticket-btn.resolve:hover {
  background: rgba(16, 185, 129, 0.2);
  color: #fff;
}

.admin-ticket-btn.delete {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.admin-ticket-btn.delete:hover {
  background: rgba(239, 68, 68, 0.18);
  color: #fff;
}
