/*
 * File: assets/css/style.css 
 * Version: 45.3.6 (International Standard)
 * Features: Desktop Lock, Mobile Fix, Voice Pro, No-Spin Glow, Rich Media
 * Language: English
 * Author: Talk By HuyNguyen System
 * Updated: 2026-01-14
 */

:root {
  /* Core Color Palette */
  --ios-bg: #000000;
  --ios-blue: #007AFF;
  --ios-green: #34c759;
  --ios-red: #ff3b30;
  
  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  
  /* Dimensions & Effects */
  --tbhn-mic-size: 52px;
  --tbhn-mic-active: #FF3B30;
  --tbhn-glow-color: rgba(0, 122, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   1. MAIN CONTAINER & LAYOUT
   ========================================================================== */

/* Desktop & Tablet: Fixed Height to prevent layout breaking */
.tbhn-embedded-glass {
  width: 100%;
  height: 600px; /* Locked height */
  max-height: 85vh;
  background-color: var(--ios-bg);
  border-radius: 24px;
  position: relative;
  overflow: hidden; /* Critical to stop overflow */
  display: flex;
  flex-direction: column;
  border: 1px solid var(--glass-border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  font-family: var(--font);
}

/* ==========================================================================
   2. CHAT BODY AREA
   ========================================================================== */

.tbn-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  z-index: 10;
  scrollbar-width: none; /* Firefox Hide Scrollbar */
  
  /* Mask effect: Fade out messages at top and bottom edges */
  -webkit-mask-image: linear-gradient(
    to bottom, 
    transparent 0%, 
    black 15%, 
    black 85%, 
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom, 
    transparent 0%, 
    black 15%, 
    black 85%, 
    transparent 100%
  );
}

/* Hide scrollbar for Chrome/Safari */
.tbn-chat-body::-webkit-scrollbar {
  display: none;
}

/* ==========================================================================
   3. MESSAGES & BUBBLES
   ========================================================================== */

.msg {
  display: flex;
  width: 100%;
  margin: 0;
}

.msg.bot {
  justify-content: flex-start;
}

.msg.user {
  justify-content: flex-end;
}

/* Container Wrapper */
.bubble-container {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

.msg.bot .bubble-container {
  align-items: flex-start;
}

.msg.user .bubble-container {
  align-items: flex-end;
}

/* Base Bubble Style */
.bubble {
  padding: 12px 18px;
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
  opacity: 0.95; 
  transition: all 0.3s ease;
  position: relative;
}

/* User Bubble: Blue Glass Effect */
.user-bubble {
  background: rgba(0, 122, 255, 0.85); 
  backdrop-filter: blur(10px); 
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

/* Bot Bubble: Dark Grey Glass Effect */
.glass-bubble {
  background: rgba(45, 45, 45, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: #fff;
  border-radius: 18px 18px 18px 4px;
}

/* ==========================================================================
   4. OVERLAY & 3D ELEMENTS
   ========================================================================== */

.tbhn-overlay-layer {
  position: absolute;
  top: 70px;
  bottom: 80px;
  left: 0;
  right: 0;
  pointer-events: none; /* Allow clicking through to chat body */
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.tbn-3d-group {
  padding: 20px;
  display: flex;
  gap: 20px;
  pointer-events: auto; /* Re-enable clicks for icons */
  filter: drop-shadow(0 0 15px rgba(0,0,0,0.6));
}

.tbn-cubes-area {
  justify-content: flex-start;
}

.tbn-panana-area {
  justify-content: flex-end;
}

/* 3D Rotating Cube (Header Icon Only) */
.header-cube {
  width: 44px;
  height: 44px;
  transform-style: preserve-3d;
  animation: rotCube 12s infinite linear;
}

.cube-face {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.cube-face.front {
  transform: translateZ(22px);
}

.cube-face.back {
  transform: rotateY(180deg) translateZ(22px);
}

@keyframes rotCube {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(360deg); }
}

/* ==========================================================================
   5. FOOTER & INPUT AREA
   ========================================================================== */

.tbhn-footer-simple {
  flex-shrink: 0;
  background: rgba(15, 15, 15, 0.95);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid rgba(255,255,255,0.1);
  z-index: 110;
}

.tbhn-input-wrapper {
  flex: 1;
  height: 46px;
  background: #1c1c1e;
  border-radius: 23px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
}

/* Input Focus Glow Effect */
.tbhn-input-wrapper:focus-within {
  box-shadow: 0 0 15px rgba(0, 122, 255, 0.3);
  border-color: var(--ios-blue);
}

.tbhn-input-field {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 16px;
  font-family: var(--font);
}

.tbhn-input-field::placeholder {
  color: #666;
}

/* ==========================================================================
   6. BUTTONS & ANIMATIONS (NO SPIN - GLOW ONLY)
   ========================================================================== */

/* A. Microphone Button */
.tbhn-action-mic {
  width: var(--tbhn-mic-size);
  height: var(--tbhn-mic-size);
  border-radius: 50%;
  background: var(--ios-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
  position: relative;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}

.tbhn-action-mic svg {
  width: 50%;
  height: 50%;
  fill: #fff;
}

/* Mic Active Press State */
.tbhn-action-mic:active {
  transform: scale(0.95);
  box-shadow: 0 0 20px var(--ios-blue); /* Strong Glow */
}

/* B. Send Button */
.tbhn-action-send {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  fill: var(--ios-blue);
  transition: transform 0.1s ease, filter 0.2s ease;
}

/* Send Button Active Press State */
.tbhn-action-send:active {
  transform: scale(0.9);
  filter: drop-shadow(0 0 8px var(--ios-blue)); /* Glow Effect */
}

/* ==========================================================================
   7. STATES: LOADING & LISTENING
   ========================================================================== */

/* Loading State: PULSING GLOW (No Rotation) */
.is-loading {
  animation: glowPulse 0.8s infinite alternate !important; 
  pointer-events: none;
}

@keyframes glowPulse {
  0% { 
    filter: drop-shadow(0 0 0px var(--ios-blue)); 
    opacity: 0.7; 
  }
  100% { 
    filter: drop-shadow(0 0 12px var(--ios-blue)); 
    opacity: 1; 
    transform: scale(1.05); 
  }
}

/* Listening State (Mic Wave Animation) */
.tbhn-action-mic.is-listening::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--tbhn-mic-active);
  animation: micWave 1.5s infinite;
  z-index: -1;
}

@keyframes micWave {
  0% { 
    transform: scale(1); 
    opacity: 0.8; 
  }
  100% { 
    transform: scale(1.8); 
    opacity: 0; 
  }
}

/* Voice Tooltip */
.tbhn-action-mic.is-listening::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 70px;
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 5px 12px;
  border-radius: 10px;
  font-size: 12px;
  white-space: nowrap;
  animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   8. MOBILE OPTIMIZATION & FIXES
   ========================================================================== */

@media (max-width: 767px) {
  /* A. Full Screen Layout for Mobile */
  .tbhn-embedded-glass {
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    border: none !important;
    
    /* Smaller Mic size on Mobile */
    --tbhn-mic-size: 44px !important;
  }

  /* B. Remove Blur Mask for Better Performance */
  .tbn-chat-body {
    -webkit-mask-image: none !important;
    mask-image: none !important;
    padding-bottom: 10px !important;
  }

  /* C. Compact Footer Layout */
  .tbhn-footer-simple {
    padding-left: 8px !important;
    padding-right: 8px !important;
    padding-bottom: 10px !important; /* Safe area */
    gap: 8px !important;
  }

  /* D. Input Field Flexibility */
  .tbhn-input-wrapper {
    flex: 1 !important;
    width: auto !important;
  }

  /* E. CRITICAL: Force Send Button Visibility */
  .tbhn-action-send {
    min-width: 40px !important;
    width: 40px !important;
    display: flex !important;
    justify-content: center;
    align-items: center;
    margin-left: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 999;
  }
}

/* ==========================================================================
   9. MARKDOWN & RICH TEXT STYLING
   ========================================================================== */

.glass-bubble p {
  margin: 0 0 8px 0;
}

.glass-bubble p:last-child {
  margin-bottom: 0;
}

.glass-bubble strong {
  color: #fff;
  font-weight: 700;
}

.glass-bubble em {
  font-style: italic;
  opacity: 0.9;
}

.glass-bubble ul, 
.glass-bubble ol {
  margin: 6px 0 6px 20px;
  padding: 0;
}

.glass-bubble li {
  margin-bottom: 4px;
}

.glass-bubble a {
  color: #4facfe;
  text-decoration: underline;
  word-break: break-all;
}

/* Inline Code */
.glass-bubble code {
  background: rgba(0,0,0,0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
  color: #e0e0e0;
}

/* Code Block */
.glass-bubble pre {
  background: #1e1e1e;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 10px 0;
  border: 1px solid rgba(255,255,255,0.1);
}

.glass-bubble pre code {
  background: none;
  padding: 0;
  color: #fff;
}

/* ==========================================================================
   10. RICH MEDIA (Images, Audio, Video, Files, Products)
   ========================================================================== */

/* --- A. Images --- */
.tbhn-chat-img {
  max-width: 100%;
  border-radius: 12px;
  margin-top: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  display: block;
}

/* --- B. Product Cards --- */
.tbhn-product-card {
  background: #ffffff;
  color: #333333;
  border-radius: 12px;
  overflow: hidden;
  width: 240px;
  max-width: 100%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  margin-top: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
}

.prod-thumb {
  width: 100%;
  height: 140px;
  background-size: cover;
  background-position: center;
  background-color: #f0f0f0;
}

.prod-info {
  padding: 12px;
}

.prod-info h4 {
  margin: 0 0 6px 0;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.prod-price {
  font-weight: bold;
  color: #e63946;
  margin-bottom: 10px;
  font-size: 15px;
  display: block;
}

.prod-btn {
  display: block;
  text-align: center;
  background: var(--ios-blue);
  color: #fff !important;
  padding: 8px;
  border-radius: 6px;
  text-decoration: none !important;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s;
}

.prod-btn:hover {
  background: #005bb5;
}

/* --- C. Audio Player --- */
.tbhn-audio-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.1);
  padding: 8px;
  border-radius: 12px;
  margin-top: 6px;
  border: 1px solid rgba(255,255,255,0.05);
}

.audio-icon {
  font-size: 24px;
  display: flex;
  align-items: center;
}

.tbhn-audio-card audio {
  height: 32px;
  width: 200px;
  outline: none;
}

/* Webkit Audio Controls Styling */
.tbhn-audio-card audio::-webkit-media-controls-panel {
  background: #f0f0f0;
}

/* --- D. Video Player --- */
.tbhn-video-wrapper {
  margin-top: 8px;
  border-radius: 12px;
  overflow: hidden;
  max-width: 100%;
  border: 1px solid rgba(255,255,255,0.1);
  background: #000;
}

.tbhn-video-wrapper video {
  width: 100%;
  display: block;
  max-height: 240px;
  object-fit: contain;
}

/* --- E. File Attachment Card --- */
.tbhn-file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.95);
  padding: 12px 14px;
  border-radius: 10px;
  text-decoration: none !important;
  margin-top: 6px;
  color: #333 !important;
  border: 1px solid #ddd;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tbhn-file-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.f-icon {
  font-size: 24px;
}

.f-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.f-dl-icon {
  font-size: 18px;
  color: var(--ios-blue);
  font-weight: bold;
}

/* --- F. Quick Replies (Chips) --- */
.tbhn-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  width: 100%;
}

.tbhn-chip-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.tbhn-chip-btn:hover {
  background: rgba(255,255,255,0.2);
  border-color: #fff;
  transform: scale(1.02);
}

/* Hide chips in User messages (sanity check) */
.msg.user .tbhn-chips-wrap {
  display: none;
}

/* ==========================================================================
   11. USER INTERACTIONS (Like, Share, Copy)
   ========================================================================== */

.tbhn-msg-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  margin-left: 4px;
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

/* Show on hover (Desktop) */
.tbhn-msg-actions:hover {
  opacity: 1;
}

.act-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
  width: 28px;
  height: 28px;
}

.act-btn svg {
  fill: #a1a1aa; /* Neutral grey */
  transition: fill 0.2s, transform 0.2s;
  width: 14px;
  height: 14px;
}

/* LIKE Button */
.act-btn.btn-like:hover {
  background: rgba(255, 59, 48, 0.15);
}

.act-btn.btn-like:hover svg {
  fill: #ff2d55;
  transform: scale(1.15);
}

.act-btn.btn-like.is-active svg {
  fill: #ff2d55;
}

/* SHARE Button */
.act-btn.btn-share:hover {
  background: rgba(0, 122, 255, 0.15);
}

.act-btn.btn-share:hover svg {
  fill: #007aff;
}

/* COPY Feedback */
.act-btn.copied {
  background: #34c759;
}

.act-btn.copied svg {
  fill: #fff;
}