/* --- LAYOUT TỔNG --- */
#talk-ai-container {
    width: 100%; max-width: 450px; height: 85vh; max-height: 800px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px; display: flex; flex-direction: column;
    overflow: hidden; position: relative; font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15); border: 1px solid #fff;
}

/* --- HEADER --- */
.talk-ai-header {
    flex-shrink: 0; padding: 15px; display: flex; align-items: center;
    background: #fff; border-bottom: 1px solid #f0f0f0; z-index: 10;
}
.talk-ai-avatar { position: relative; width: 40px; height: 40px; margin-right: 10px; }
.talk-ai-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.talk-ai-status-dot { width: 10px; height: 10px; background: #ccc; border-radius: 50%; position: absolute; bottom: 0; right: 0; border: 2px solid #fff; }
.talk-ai-status-dot.online { background: #2ecc71; }
.talk-ai-status-dot.speaking { background: #e74c3c; animation: pulse 1s infinite; }
.talk-ai-info h3 { margin: 0; font-size: 15px; font-weight: 700; color: #333; line-height: 1.2; }
.talk-ai-status-text { font-size: 11px; color: #888; }

/* --- CREDIT (GLASS) --- */
.talk-ai-credits {
    margin-left: auto; text-decoration: none; display: flex; align-items: center; gap: 5px;
    background: rgba(243, 156, 18, 0.1); border: 1px solid rgba(243, 156, 18, 0.2);
    padding: 4px 10px; border-radius: 15px; font-weight: 700; color: #e67e22; font-size: 12px;
}
.battery-icon { width: 18px; height: 8px; border: 1px solid #e67e22; border-radius: 2px; position: relative; padding: 1px; }
.battery-icon::after { content: ''; position: absolute; right: -3px; top: 1px; width: 2px; height: 4px; background: #e67e22; }
.battery-level { height: 100%; background: #e67e22; width: 100%; }

/* --- VISUALIZER --- */
.talk-ai-visualizer {
    flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; 
    justify-content: center; align-items: center; width: 100%; overflow: hidden; background: #fcfcfc;
}
#talk-ai-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; opacity: 0.5; }
.talk-ai-message-box { z-index: 2; text-align: center; padding: 0 20px; width: 100%; box-sizing: border-box; }
.ai-msg { display: inline-block; background: #fff; padding: 10px 20px; border-radius: 20px; box-shadow: 0 5px 20px rgba(0,0,0,0.05); color: #444; font-size: 14px; }

/* --- CONTROLS BAR (FIXED) --- */
.talk-ai-controls {
    flex-shrink: 0; padding: 15px; padding-bottom: 25px;
    display: flex; justify-content: center; align-items: center;
    background: #fff; border-top: 1px solid #f0f0f0; gap: 10px; z-index: 20;
}

/* NÚT TRÒN (Fix méo & mất hình) */
.icon-btn {
    width: 44px !important; height: 44px !important; 
    min-width: 44px !important; /* Chống méo */
    border-radius: 50% !important;
    background: #f5f6f7 !important; 
    border: 1px solid #e0e0e0 !important;
    padding: 0 !important; margin: 0 !important;
    display: flex !important; align-items: center !important; justify-content: center !important;
    cursor: pointer; outline: none; -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: #e4e6eb !important; transform: scale(1.05); }

/* ÉP ICON SVG HIỆN MÀU ĐEN */
.icon-btn svg {
    width: 22px !important; height: 22px !important;
    display: block !important;
    fill: #555 !important; /* Màu xám đen */
    stroke: none !important;
}

/* NÚT BẮT ĐẦU (MAIN) */
.main-btn {
    flex: 1; height: 48px; border-radius: 24px;
    background: #0866ff; color: #fff; border: none;
    font-size: 15px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    box-shadow: 0 4px 10px rgba(8,102,255,0.3); cursor: pointer;
}
.main-btn:hover { background: #005ce6; }
.main-btn.listening { background: #e74c3c; animation: pulse-red 1.5s infinite; }
.main-btn svg { width: 18px; height: 18px; fill: white !important; }

/* Camera Preview */
.video-preview-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 5; background: #000; display: none; }
#talk-ai-video-preview { width: 100%; height: 100%; object-fit: cover; }
.btn-flip-cam { position: absolute; top: 20px; right: 20px; width: 44px; height: 44px; border-radius: 50%; background: rgba(0,0,0,0.5); color: #fff; border: 2px solid rgba(255,255,255,0.5); display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 100; font-size: 20px; }

/* Mobile */
@media (max-width: 600px) {
    #talk-ai-container { position: fixed !important; top: 0; left: 0; width: 100% !important; height: 100dvh !important; border-radius: 0; }
    .talk-ai-controls { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
    #btn-screen { display: none !important; }
}
@keyframes pulse-red { 0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7); } 70% { box-shadow: 0 0 0 15px rgba(231, 76, 60, 0); } 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); } }