/* =========================================================
   CHAKA LIVE MODE // V5 EXPRESSIVE FACE HUD (Dark Immersive)
   ========================================================= */
:root {
    --live-bg: #0a0a0c;
    --live-surface: rgba(28, 28, 30, 0.6);
    --live-border: rgba(255, 255, 255, 0.08);
    --live-text: #ffffff;
    --live-text-dim: #8e8e93;
    --live-brand: #ff4500;
    --live-brand-glow: rgba(255, 69, 0, 0.4);
    --live-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

/* --- OVERLAY SHELL --- */
#live-mode-overlay {
    position: fixed;
    inset: 0;
    background-color: var(--live-bg);
    display: flex;
    flex-direction: column;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", sans-serif;
    color: var(--live-text);
    opacity: 0;
    pointer-events: none;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

#live-mode-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Subtle ambient glow */
#live-mode-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 40%, rgba(255, 69, 0, 0.02) 0%, transparent 60%);
    pointer-events: none;
    z-index: 1;
}

/* --- MAIN STAGE --- */
.live-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 5;
    width: 100%;
}

/* --- VISUALIZER (Face Canvas) --- */
.live-visualizer-container {
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-bottom: 2vh;
}

#live-visualizer {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    cursor: pointer;
    filter: drop-shadow(0 0 30px rgba(0, 212, 255, 0.15));
}

/* --- TEXT FEEDBACK AREA --- */
.live-feedback-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    max-width: 600px;
    height: 160px;
    padding: 0 20px;
    z-index: 10;
}

/* Status Label (LISTENING, SPEAKING, THINKING) */
#live-status-text {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--live-text-dim);
    margin-bottom: 15px;
    text-transform: uppercase;
    animation: live-pulseText 2s infinite ease-in-out;
    transition: color 0.3s ease;
}

@keyframes live-pulseText {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* --- TRANSCRIPT LOG --- */
#live-chat-log {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
    mask-image: linear-gradient(to top, black 60%, transparent 100%);
    -webkit-mask-image: linear-gradient(to top, black 60%, transparent 100%);
}

.live-msg {
    text-align: center;
    font-size: 18px;
    line-height: 1.4;
    padding: 4px 16px;
    opacity: 0;
    transform: translateY(10px);
    animation: live-msgFadeIn 0.4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.live-msg.ai {
    color: var(--live-text);
    font-weight: 400;
}

.live-msg.user {
    color: var(--live-text-dim);
    font-weight: 500;
    font-style: italic;
}

.live-msg.system {
    color: var(--live-brand);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 1px;
}

@keyframes live-msgFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- BOTTOM CONTROLS --- */
.live-controls-bar {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
    padding-bottom: 40px;
    z-index: 20;
}

/* Common Button Base */
.live-action-btn {
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid var(--live-border);
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    box-shadow: var(--live-shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background: var(--live-surface);
    color: var(--live-text);
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

/* Secondary Buttons (Menu + Exit) */
.live-action-btn.secondary {
    width: 56px;
    height: 56px;
}

.live-action-btn.secondary svg {
    width: 22px;
    height: 22px;
}

.live-action-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

/* Primary Mic Button */
.live-action-btn.primary-mic {
    width: 80px;
    height: 80px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.live-action-btn.primary-mic svg {
    width: 34px;
    height: 34px;
}

.live-action-btn.primary-mic.active {
    background: var(--live-brand);
    color: #fff;
    border-color: var(--live-brand);
    box-shadow: 0 0 25px var(--live-brand-glow), 0 0 0 0 rgba(255, 69, 0, 0.5);
    animation: live-micRipple 2s infinite cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes live-micRipple {
    0% { box-shadow: 0 0 20px var(--live-brand-glow), 0 0 0 0 rgba(255, 69, 0, 0.4); }
    70% { box-shadow: 0 0 30px var(--live-brand-glow), 0 0 0 20px rgba(255, 69, 0, 0); }
    100% { box-shadow: 0 0 20px var(--live-brand-glow), 0 0 0 0 rgba(255, 69, 0, 0); }
}

/* --- SLIDE-UP MENU PANEL --- */
.live-menu-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(20, 20, 22, 0.95);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-top: 1px solid var(--live-border);
    border-radius: 24px 24px 0 0;
    padding: 24px 24px 40px;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    pointer-events: none;
}

.live-menu-panel.open {
    transform: translateY(0);
    pointer-events: all;
}

.live-menu-panel .menu-handle {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    margin: 0 auto 24px;
}

.live-menu-panel .menu-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--live-text-dim);
    text-transform: uppercase;
    margin-bottom: 16px;
}

.live-menu-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border-radius: 14px;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--live-text);
    width: 100%;
    text-align: left;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    transition: background 0.2s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.live-menu-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.live-menu-item svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    opacity: 0.7;
}

.live-menu-item .menu-item-label {
    flex: 1;
}

.live-menu-item .menu-item-value {
    font-size: 13px;
    color: var(--live-text-dim);
}

.live-menu-divider {
    height: 1px;
    background: var(--live-border);
    margin: 8px 0;
}

/* Voice select inside menu */
.live-menu-item select {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--live-border);
    border-radius: 8px;
    color: var(--live-text);
    padding: 6px 10px;
    font-family: inherit;
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

/* --- KEYBOARD INPUT OVERLAY --- */
.live-keyboard-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    background: rgba(20, 20, 22, 0.95);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-top: 1px solid var(--live-border);
    border-radius: 24px 24px 0 0;
    padding: 20px 20px 40px;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    pointer-events: none;
}

.live-keyboard-overlay.open {
    transform: translateY(0);
    pointer-events: all;
}

.live-keyboard-input-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.live-keyboard-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--live-border);
    border-radius: 14px;
    padding: 14px 18px;
    color: var(--live-text);
    font-family: inherit;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s ease;
}

.live-keyboard-input:focus {
    border-color: var(--live-brand);
}

.live-keyboard-input::placeholder {
    color: var(--live-text-dim);
}

.live-keyboard-send-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: var(--live-brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.live-keyboard-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px var(--live-brand-glow);
}

.live-keyboard-send-btn svg {
    width: 22px;
    height: 22px;
}

/* --- MENU BACKDROP --- */
.live-menu-backdrop {
    position: absolute;
    inset: 0;
    z-index: 80;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.live-menu-backdrop.show {
    opacity: 1;
    pointer-events: all;
}

/* --- PERSONA BADGE --- */
.live-persona-badge {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--live-text-dim);
    text-transform: uppercase;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

/* --- RESPONSIVE --- */
@media (max-width: 480px) {
    .live-visualizer-container {
        max-width: 320px;
    }
    
    .live-feedback-area {
        height: 130px;
        padding: 0 16px;
    }
    
    .live-msg {
        font-size: 16px;
    }
    
    .live-controls-bar {
        gap: 24px;
        padding-bottom: 30px;
    }
    
    .live-action-btn.primary-mic {
        width: 70px;
        height: 70px;
    }
    
    .live-action-btn.secondary {
        width: 48px;
        height: 48px;
    }
}

/* =========================================================
   LIVE AGENT STATUS CARD (Floating glassmorphic HUD)
   ========================================================= */
#live-agent-status-card {
    position: fixed;
    top: 60px;
    right: 16px;
    z-index: 20000;
    width: 280px;
    background: rgba(18, 18, 22, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 20px;
    color: var(--live-text);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04);
    opacity: 0;
    transform: translateY(-16px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.25, 1, 0.5, 1), transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

#live-agent-status-card.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Subtle animated border glow while running */
#live-agent-status-card.running::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 21px;
    background: conic-gradient(from var(--agent-glow-angle, 0deg), transparent 60%, var(--live-brand) 80%, transparent 100%);
    z-index: -1;
    animation: agentBorderSpin 3s linear infinite;
    opacity: 0.5;
}

@property --agent-glow-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

@keyframes agentBorderSpin {
    to { --agent-glow-angle: 360deg; }
}

/* Card Header */
.agent-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.agent-card-ring {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.agent-card-ring svg {
    width: 44px;
    height: 44px;
    transform: rotate(-90deg);
}

.agent-card-ring .ring-track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.06);
    stroke-width: 3;
}

.agent-card-ring .ring-progress {
    fill: none;
    stroke: var(--live-brand);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 113;
    stroke-dashoffset: 113;
    transition: stroke-dashoffset 0.6s cubic-bezier(0.25, 1, 0.5, 1);
    filter: drop-shadow(0 0 4px var(--live-brand-glow));
}

.agent-card-ring .ring-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.agent-card-info {
    flex: 1;
    min-width: 0;
}

.agent-card-name {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--live-brand);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-card-target {
    font-size: 12px;
    color: var(--live-text-dim);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Status Text */
.agent-card-status {
    font-size: 12px;
    color: var(--live-text);
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    margin-bottom: 12px;
    min-height: 38px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.agent-card-status .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--live-brand);
    flex-shrink: 0;
    animation: statusPulse 1.5s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 0.4; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

.agent-card-status-text {
    flex: 1;
    line-height: 1.4;
}

/* Footer: Timer + Step Count */
.agent-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--live-text-dim);
    letter-spacing: 0.5px;
}

.agent-card-timer {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.agent-card-steps {
    font-weight: 500;
}

/* Completion states */
#live-agent-status-card.completed .agent-card-name { color: #34d399; }
#live-agent-status-card.completed .ring-progress { stroke: #34d399; filter: drop-shadow(0 0 4px rgba(52, 211, 153, 0.4)); }
#live-agent-status-card.completed .status-dot { background: #34d399; animation: none; opacity: 1; }
#live-agent-status-card.completed::before { display: none; }

#live-agent-status-card.failed .agent-card-name { color: #f87171; }
#live-agent-status-card.failed .ring-progress { stroke: #f87171; filter: drop-shadow(0 0 4px rgba(248, 113, 113, 0.4)); }
#live-agent-status-card.failed .status-dot { background: #f87171; animation: none; opacity: 1; }
#live-agent-status-card.failed::before { display: none; }

/* Auto-dismiss fade */
#live-agent-status-card.dismissing {
    opacity: 0;
    transform: translateX(100%) scale(0.9);
}

/* Mobile adjustments */
@media (max-width: 480px) {
    #live-agent-status-card {
        top: 48px;
        right: 8px;
        left: 8px;
        width: auto;
    }
}