/* ============================================================
   Voice Module Styles - BGFIBank Chatbot
   Redesign complet - Mode Audio Intégral + UI moderne
   Palette : #0B3D91 (primaire), #D4A843 (or), #dc2626 (rec)
   ============================================================ */

/* ---- CSS Variables ---- */
:root {
    --voice-primary: #0B3D91;
    --voice-primary-light: #1A5BC4;
    --voice-primary-dark: #082D6E;
    --voice-gold: #D4A843;
    --voice-gold-bg: #FFFBEB;
    --voice-gold-border: #F6D98B;
    --voice-red: #dc2626;
    --voice-red-light: #ef4444;
}

/* ================================================================
   1. VOICE STATUS BAR (between chat-body and footer)
   ================================================================ */
.voice-status-bar {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    border-top: 1px solid rgba(11, 61, 145, 0.08);
    background: linear-gradient(135deg, #f8fafc, #f0f4ff);
    min-height: 38px !important;
    flex-shrink: 0;
    z-index: 5;
    visibility: visible !important;
    opacity: 1 !important;
}

.voice-status-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.voice-status-left label {
    cursor: pointer;
}

.voice-status-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ================================================================
   2. VOICE BADGES
   ================================================================ */
.voice-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.voice-badge i {
    font-size: 10px;
}

/* VOCAL PRO : gold / amber */
.voice-badge-pro {
    background: var(--voice-gold-bg);
    color: var(--voice-gold);
    border: 1px solid var(--voice-gold-border);
    box-shadow: 0 1px 4px rgba(212, 168, 67, 0.15);
}

/* Guest counter badge - clickable */
.voice-badge-guest {
    background: #f0f4ff;
    color: var(--voice-primary);
    border: 1px solid rgba(11, 61, 145, 0.15);
    cursor: pointer;
    transition: all 0.2s ease;
}

.voice-badge-guest:hover {
    background: #e0e8ff;
    border-color: rgba(11, 61, 145, 0.3);
    transform: scale(1.05);
}

/* Guest blocked badge — red/urgent */
.voice-badge-blocked {
    background: #fef2f2;
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.2);
}

.voice-badge-blocked:hover {
    background: #fee2e2;
    border-color: rgba(220, 38, 38, 0.35);
}

/* ================================================================
   3. AUTO-READ TOGGLE BUTTON (small pill button, always blue-themed)
   ================================================================ */
.auto-read-btn {
    height: 30px;
    min-width: 30px;
    padding: 0 10px;
    border-radius: 15px;
    border: 1.5px solid rgba(11, 61, 145, 0.2);
    background: linear-gradient(135deg, #e8f0fe 0%, #dbeafe 100%);
    color: var(--voice-primary);
    font-size: 13px;
    cursor: pointer;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 5px;
    visibility: visible !important;
    opacity: 1 !important;
    transition: background 0.3s cubic-bezier(.4,0,.2,1),
                border-color 0.3s cubic-bezier(.4,0,.2,1),
                box-shadow 0.3s cubic-bezier(.4,0,.2,1),
                color 0.3s cubic-bezier(.4,0,.2,1),
                transform 0.3s cubic-bezier(.4,0,.2,1);
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 1px 3px rgba(11, 61, 145, 0.08);
}

.auto-read-btn:hover {
    background: linear-gradient(135deg, #dbeafe 0%, #c7d9f7 100%);
    border-color: rgba(11, 61, 145, 0.35);
    box-shadow: 0 2px 8px rgba(11, 61, 145, 0.15);
    transform: translateY(-1px);
}

.auto-read-btn:active {
    transform: translateY(0) scale(0.97);
    box-shadow: 0 1px 2px rgba(11, 61, 145, 0.1);
}

/* Active state: auto-read ON — solid blue with glow */
.auto-read-btn.active {
    background: linear-gradient(135deg, var(--voice-primary) 0%, var(--voice-primary-light) 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 10px rgba(11, 61, 145, 0.35), 0 0 0 3px rgba(11, 61, 145, 0.08);
}

.auto-read-btn.active:hover {
    box-shadow: 0 4px 16px rgba(11, 61, 145, 0.45), 0 0 0 3px rgba(11, 61, 145, 0.12);
    transform: translateY(-1px);
}

.auto-read-btn.active i {
    animation: speakerPulse 2s ease-in-out infinite;
}

/* Disabled state */
.auto-read-btn:disabled {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 0.35 !important;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none;
    animation: none;
    background: #f1f5f9;
    color: #94a3b8;
    border-color: #e2e8f0;
}

.auto-read-btn:disabled i {
    animation: none;
}

/* Label inside button */
.auto-read-btn .auto-read-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

@keyframes speakerPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.15); }
}

/* ================================================================
   4. SPEED CONTROL
   ================================================================ */
.voice-speed-control {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: #e2e8f0;
    border-radius: 8px;
    padding: 2px;
    margin-left: 6px;
}

.speed-btn {
    padding: 3px 8px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.3;
}

.speed-btn:hover {
    color: var(--voice-primary);
    background: rgba(11, 61, 145, 0.08);
}

.speed-btn.active {
    background: #fff;
    color: var(--voice-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* ================================================================
   5. SOUND WAVE INDICATOR (playing TTS)
   ================================================================ */
.sound-wave {
    display: none;
    align-items: flex-end;
    gap: 2px;
    height: 18px;
    margin-right: 8px;
}

.sound-wave.playing {
    display: inline-flex;
}

.wave-bar {
    width: 3px;
    border-radius: 2px;
    background: linear-gradient(180deg, var(--voice-primary), var(--voice-primary-light));
    animation: waveAnim 0.8s ease-in-out infinite;
}

.wave-bar:nth-child(1) { height: 6px;  animation-delay: 0s; }
.wave-bar:nth-child(2) { height: 12px; animation-delay: 0.15s; }
.wave-bar:nth-child(3) { height: 8px;  animation-delay: 0.3s; }
.wave-bar:nth-child(4) { height: 14px; animation-delay: 0.45s; }

@keyframes waveAnim {
    0%, 100% { transform: scaleY(0.4); }
    50%      { transform: scaleY(1); }
}

/* ================================================================
   6. AUDIO LIVE BUTTON (in status bar, authenticated only)
   ================================================================ */
.audio-live-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border: none;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--voice-primary), var(--voice-primary-light));
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(11, 61, 145, 0.3);
    white-space: nowrap;
    margin-left: 6px;
    visibility: visible !important;
    opacity: 1 !important;
}

.audio-live-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(11, 61, 145, 0.4);
}

.audio-live-btn:active {
    transform: translateY(0);
}

.audio-live-btn i {
    font-size: 11px;
}

/* ================================================================
   7. MICROPHONE BUTTON (LEFT of textarea, square rounded)
   ================================================================ */
.voice-mic-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 12px;
    border: 1.5px solid rgba(11, 61, 145, 0.15);
    background: linear-gradient(135deg, #F0F4FF 0%, #E0E8FF 100%);
    color: var(--voice-primary);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(11, 61, 145, 0.08);
    order: -1; /* Force LEFT of textarea */
}

.voice-mic-btn:hover {
    background: linear-gradient(135deg, #E0E8FF 0%, #D0DCFF 100%);
    border-color: rgba(11, 61, 145, 0.25);
    box-shadow: 0 2px 8px rgba(11, 61, 145, 0.15);
    transform: scale(1.05);
}

.voice-mic-btn:active {
    transform: scale(0.95);
}

/* Recording state : red pulse */
.voice-mic-btn.recording {
    background: linear-gradient(135deg, var(--voice-red) 0%, var(--voice-red-light) 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5);
    animation: voice-pulse 1.5s ease-in-out infinite;
}

/* Disabled (guest limit reached) */
.voice-mic-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none;
    animation: none;
    background: #f1f5f9;
    color: #94a3b8;
    border-color: #e2e8f0;
}

@keyframes voice-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
    70%  { box-shadow: 0 0 0 12px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* ================================================================
   8. SEND BUTTON OVERRIDE (square rounded)
   ================================================================ */
.chat-footer .send-btn {
    border-radius: 12px !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px;
}

/* ================================================================
   9. RECORDING STATE (replaces textarea content)
   ================================================================ */
.textarea-wrapper.recording {
    border-color: var(--voice-primary);
    background: #f8faff;
}

.textarea-wrapper.recording #message-to-send {
    display: none;
}

.textarea-wrapper.recording .char-counter {
    display: none;
}

.recording-overlay {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    min-height: 46px;
    box-sizing: border-box;
}

.recording-overlay .rec-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--voice-red);
    animation: rec-blink 1s ease-in-out infinite;
    flex-shrink: 0;
}

.recording-overlay .rec-visualizer {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 24px;
    flex-shrink: 0;
}

.recording-overlay .viz-bar {
    width: 3px;
    height: 4px;
    min-height: 4px;
    border-radius: 2px;
    background: var(--voice-primary);
    transition: height 0.08s ease-out;
}

.recording-overlay .rec-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--voice-primary);
    white-space: nowrap;
}

.recording-overlay .rec-timer {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    font-weight: 600;
    color: var(--voice-red);
    flex-shrink: 0;
}

@keyframes rec-blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.3; }
}

/* Transcribed text : blue color */
#message-to-send.voice-transcribed {
    color: var(--voice-primary) !important;
    font-weight: 500;
}

/* ================================================================
   10. TTS LISTEN BUTTON (under bot bubbles)
   ================================================================ */
.tts-listen-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    margin-top: 6px;
    margin-bottom: 2px;
    border: 1px solid rgba(11, 61, 145, 0.15);
    background: rgba(255, 255, 255, 0.85);
    color: var(--voice-primary);
    font-size: 12px;
    font-weight: 500;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.tts-listen-btn:hover {
    background: rgba(11, 61, 145, 0.08);
    border-color: rgba(11, 61, 145, 0.25);
}

.tts-listen-btn.loading {
    opacity: 0.6;
    cursor: wait;
}

.tts-listen-btn.playing {
    background: linear-gradient(135deg, var(--voice-primary), var(--voice-primary-light));
    color: #fff;
    border-color: transparent;
}

.tts-listen-btn.playing:hover {
    background: linear-gradient(135deg, #093176, #154DA8);
}

.tts-listen-btn i {
    font-size: 11px;
}

.tts-listen-btn.disabled,
.tts-listen-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #f1f5f9;
    color: #94a3b8;
    border-color: #e2e8f0;
}

.tts-listen-btn.disabled:hover,
.tts-listen-btn:disabled:hover {
    background: #f1f5f9;
    border-color: #e2e8f0;
}

/* ================================================================
   11. VOICE MESSAGE BADGE (inside user bubbles)
   ================================================================ */
.voice-message-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    margin-top: 6px;
    background: rgba(11, 61, 145, 0.06);
    color: var(--voice-primary);
    font-size: 11px;
    font-weight: 500;
    border-radius: 8px;
    opacity: 0.75;
}

/* ================================================================
   12. GUEST VOICE BANNER (under header)
   ================================================================ */
.guest-voice-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #fef9c3, #fef3c7);
    border-bottom: 1px solid #fcd34d;
    font-size: 13px;
    animation: voiceFadeIn 0.3s ease-out;
    flex-shrink: 0;
}

.guest-voice-banner.gvb-urgent {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    border-bottom-color: #f87171;
}

.guest-voice-banner.gvb-urgent .gvb-text {
    color: #991b1b;
}

.gvb-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.gvb-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.gvb-text {
    color: #92400e;
    font-weight: 500;
    line-height: 1.3;
}

.gvb-link {
    color: var(--voice-primary);
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 6px;
    background: rgba(11, 61, 145, 0.08);
    transition: all 0.2s;
    flex-shrink: 0;
}

.gvb-link:hover {
    background: rgba(11, 61, 145, 0.15);
}

.gvb-link i {
    font-size: 11px;
}

.gvb-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.gvb-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
}

.gvb-btn i {
    font-size: 11px;
}

.gvb-btn-primary {
    background: linear-gradient(135deg, var(--voice-primary), var(--voice-primary-light));
    color: #fff;
    box-shadow: 0 1px 4px rgba(11, 61, 145, 0.3);
}

.gvb-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(11, 61, 145, 0.4);
}

.gvb-btn-secondary {
    background: #fff;
    color: var(--voice-primary);
    border: 1px solid rgba(11, 61, 145, 0.3);
}

.gvb-btn-secondary:hover {
    background: rgba(11, 61, 145, 0.05);
}

/* ================================================================
   13. GUEST LIMIT BANNER (in chat-body)
   ================================================================ */
.guest-limit-banner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    margin: 12px;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 1px solid #f59e0b;
    border-radius: 12px;
    text-align: center;
    animation: voiceFadeIn 0.3s ease-out;
}

.guest-limit-banner .guest-limit-icon {
    font-size: 28px;
}

.guest-limit-banner .guest-limit-text {
    font-size: 14px;
    color: #92400e;
    line-height: 1.5;
    font-weight: 500;
}

.guest-limit-banner .guest-limit-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.guest-limit-banner .guest-limit-btn {
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.guest-limit-banner .guest-limit-btn.primary {
    background: linear-gradient(135deg, var(--voice-primary), var(--voice-primary-light));
    color: #fff;
    border: none;
    box-shadow: 0 2px 8px rgba(11, 61, 145, 0.3);
}

.guest-limit-banner .guest-limit-btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(11, 61, 145, 0.4);
}

.guest-limit-banner .guest-limit-btn.secondary {
    background: #fff;
    color: var(--voice-primary);
    border: 1px solid var(--voice-primary);
}

.guest-limit-banner .guest-limit-btn.secondary:hover {
    background: rgba(11, 61, 145, 0.05);
}

/* ================================================================
   14. VOICE TOAST NOTIFICATION
   ================================================================ */
.voice-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(11, 61, 145, 0.92);
    color: #fff;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

.voice-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.voice-toast i {
    font-size: 15px;
}

/* Rich toast (badge click - voice limit info) */
.voice-toast.voice-toast-rich {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    white-space: normal;
    max-width: 320px;
    text-align: left;
    padding: 12px 16px;
    pointer-events: auto;
}

.rich-toast-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.rich-toast-header i {
    font-size: 14px;
    opacity: 0.9;
}

.rich-toast-body {
    font-size: 12px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
}

.rich-toast-cta {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    padding: 5px 14px;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.rich-toast-cta:hover {
    background: rgba(255, 255, 255, 0.3);
}

.rich-toast-cta i {
    font-size: 11px;
}

/* ================================================================
   15. AUDIO INTEGRAL OVERLAY (full-screen voice assistant)
   ================================================================ */
.audio-integral-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, #040E23 0%, #0B3D91 45%, #061B3F 100%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, transform 0.5s ease;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    /* Safe area for iPhone notch */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

.audio-integral-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
}

/* Background animated orbs */
.ai-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(40px);
    -webkit-filter: blur(40px);
    opacity: 0.15;
    pointer-events: none;
    will-change: transform;
}

.ai-orb-1 {
    width: 300px;
    height: 300px;
    background: var(--voice-primary-light);
    top: -50px;
    left: -80px;
    animation: aiOrbFloat 8s ease-in-out infinite;
}

.ai-orb-2 {
    width: 250px;
    height: 250px;
    background: var(--voice-gold);
    bottom: -60px;
    right: -60px;
    animation: aiOrbFloat 10s ease-in-out infinite reverse;
}

.ai-orb-3 {
    width: 200px;
    height: 200px;
    background: var(--voice-primary);
    top: 40%;
    right: -40px;
    animation: aiOrbFloat 12s ease-in-out infinite 2s;
    opacity: 0.1;
}

@keyframes aiOrbFloat {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(30px, -30px); }
}

/* Header */
.ai-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 20px;
    padding-top: calc(20px + env(safe-area-inset-top));
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 2;
}

.ai-header-logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.ai-header-info {
    flex: 1;
}

.ai-header-info h3 {
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}

.ai-header-info p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    margin: 0;
}

/* Exit button — circle in header top-right */
.ai-exit-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.8);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.ai-exit-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
    transform: scale(1.05);
}

.ai-exit-btn:active {
    transform: scale(0.95);
}

/* Center circle */
.ai-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    z-index: 2;
}

.ai-circle {
    position: relative;
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.ai-circle-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(11, 61, 145, 0.6) 0%, rgba(11, 61, 145, 0.2) 70%, transparent 100%);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

/* Pulse rings */
.ai-pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    transform: translate(-50%, -50%);
    animation: aiPulse 3s ease-out infinite;
    pointer-events: none;
}

.ai-pulse-ring-2 {
    animation-delay: 1s;
}

.ai-pulse-ring-3 {
    animation-delay: 2s;
}

@keyframes aiPulse {
    0%   { width: 100%; height: 100%; opacity: 0.6; }
    100% { width: 180%; height: 180%; opacity: 0; }
}

/* Star image - centered, large and luminous */
.ai-star {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 130px;
    height: 130px;
    object-fit: contain;
    z-index: 1;
    filter: brightness(1.8) drop-shadow(0 0 20px rgba(255, 255, 255, 0.7)) drop-shadow(0 0 50px rgba(255, 255, 255, 0.35));
    -webkit-filter: brightness(1.8) drop-shadow(0 0 20px rgba(255, 255, 255, 0.7)) drop-shadow(0 0 50px rgba(255, 255, 255, 0.35));
    transition: transform 0.12s ease-out, filter 0.3s ease;
    will-change: transform, filter;
}

/* Idle: gentle breathing animation */
.audio-integral-overlay[data-state="idle"] .ai-star {
    animation: aiStarBreathe 3s ease-in-out infinite;
}

/* Only animate transform — filter stays static from .ai-star base rule (avoids repaint per frame) */
@keyframes aiStarBreathe {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50%      { transform: translate(-50%, -50%) scale(1.15); }
}

/* State text */
.ai-status-text {
    color: #fff;
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
}

.ai-sub-text {
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    text-align: center;
    transition: all 0.3s ease;
}

/* Listening state: recording wave inside circle */
.ai-rec-wave {
    display: none;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    height: 50px;
    z-index: 1;
}

.ai-rec-wave.active {
    display: flex;
}

.ai-rec-wave .ai-wave-bar {
    width: 4px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.8);
    transition: height 0.1s ease-out;
    min-height: 6px;
}

/* State-specific circle styles */
.audio-integral-overlay[data-state="idle"] .ai-circle-bg {
    border-color: rgba(212, 168, 67, 0.3);
}

/* Listening: star VISIBLE with red glow (JS controls scale via volume) */
.audio-integral-overlay[data-state="listening"] .ai-circle-bg {
    border-color: rgba(220, 38, 38, 0.5);
    animation: aiCircleListening 2s ease-in-out infinite;
}

.audio-integral-overlay[data-state="listening"] .ai-star {
    animation: none;
    filter: brightness(1.8) drop-shadow(0 0 25px rgba(220, 38, 38, 0.6)) drop-shadow(0 0 50px rgba(220, 38, 38, 0.3));
    -webkit-filter: brightness(1.8) drop-shadow(0 0 25px rgba(220, 38, 38, 0.6)) drop-shadow(0 0 50px rgba(220, 38, 38, 0.3));
}

.audio-integral-overlay[data-state="listening"] .ai-rec-wave {
    display: flex;
}

@keyframes aiCircleListening {
    0%, 100% { background: radial-gradient(circle, rgba(220, 38, 38, 0.3) 0%, rgba(220, 38, 38, 0.1) 70%, transparent 100%); }
    50%      { background: radial-gradient(circle, rgba(220, 38, 38, 0.5) 0%, rgba(220, 38, 38, 0.15) 70%, transparent 100%); }
}

/* Processing: pulsing rotation + orbital loading ring */
.audio-integral-overlay[data-state="processing"] .ai-star {
    animation: aiStarProcessing 1.5s ease-in-out infinite;
}

.audio-integral-overlay[data-state="processing"] .ai-circle-bg {
    border-color: rgba(26, 91, 196, 0.5);
}

.audio-integral-overlay[data-state="processing"] .ai-circle-bg::after {
    content: '';
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: rgba(26, 91, 196, 0.8);
    animation: aiLoadingRing 1s linear infinite;
}

@keyframes aiStarProcessing {
    0%   { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
    50%  { transform: translate(-50%, -50%) rotate(180deg) scale(0.9); }
    100% { transform: translate(-50%, -50%) rotate(360deg) scale(1); }
}

@keyframes aiLoadingRing {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Speaking: green pulse glow */
.audio-integral-overlay[data-state="speaking"] .ai-star {
    animation: aiStarSpeaking 2s ease-in-out infinite;
    filter: brightness(1.8) drop-shadow(0 0 20px rgba(52, 211, 153, 0.5)) drop-shadow(0 0 40px rgba(52, 211, 153, 0.3));
    -webkit-filter: brightness(1.8) drop-shadow(0 0 20px rgba(52, 211, 153, 0.5)) drop-shadow(0 0 40px rgba(52, 211, 153, 0.3));
}

.audio-integral-overlay[data-state="speaking"] .ai-circle-bg {
    border-color: rgba(52, 211, 153, 0.4);
}

.audio-integral-overlay[data-state="speaking"] .ai-pulse-ring {
    border-color: rgba(52, 211, 153, 0.2);
}

@keyframes aiStarSpeaking {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50%      { transform: translate(-50%, -50%) scale(1.1); }
}

/* AI Timer */
.ai-timer {
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    min-width: 40px;
    text-align: center;
}

/* ================================================================
   15b. DEDICATED TALK BUTTON (Hold-to-Talk)
   ================================================================ */

/* Bottom area container */
.ai-bottom-area {
    position: absolute;
    bottom: 30px;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 3;
}

/* Talk button wrapper (for ring positioning) */
.ai-talk-btn-wrapper {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Animated ring around button */
.ai-talk-btn-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 2.5px solid rgba(26, 91, 196, 0.4);
    animation: aiTalkRingPulse 2.5s ease-in-out infinite;
    pointer-events: none;
    transition: border-color 0.3s ease;
}

/* Ring: idle = blue pulse */
@keyframes aiTalkRingPulse {
    0%, 100% { width: 80px; height: 80px; opacity: 0.6; }
    50%      { width: 100px; height: 100px; opacity: 0; }
}

/* Ring: listening = red expansive */
.audio-integral-overlay[data-state="listening"] .ai-talk-btn-ring {
    border-color: rgba(239, 68, 68, 0.6);
    animation: aiTalkRingListening 1.2s ease-out infinite;
}

@keyframes aiTalkRingListening {
    0%   { width: 80px; height: 80px; opacity: 0.8; }
    100% { width: 120px; height: 120px; opacity: 0; }
}

/* Ring: processing = blue rotating */
.audio-integral-overlay[data-state="processing"] .ai-talk-btn-ring {
    border-color: transparent;
    border-top-color: rgba(26, 91, 196, 0.8);
    border-right-color: rgba(26, 91, 196, 0.3);
    width: 88px;
    height: 88px;
    animation: aiTalkRingProcessing 1s linear infinite;
}

@keyframes aiTalkRingProcessing {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to   { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Ring: speaking = green */
.audio-integral-overlay[data-state="speaking"] .ai-talk-btn-ring {
    border-color: rgba(52, 211, 153, 0.5);
    animation: aiTalkRingPulseSpeaking 2s ease-in-out infinite;
}

@keyframes aiTalkRingPulseSpeaking {
    0%, 100% { width: 80px; height: 80px; opacity: 0.5; }
    50%      { width: 96px; height: 96px; opacity: 0; }
}

/* Talk button */
.ai-talk-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--voice-primary-light) 0%, var(--voice-primary) 100%);
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(.4,0,.2,1),
                background 0.2s cubic-bezier(.4,0,.2,1),
                box-shadow 0.2s cubic-bezier(.4,0,.2,1),
                opacity 0.2s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 4px 20px rgba(26, 91, 196, 0.4), 0 0 0 0 rgba(26, 91, 196, 0);
    position: relative;
    z-index: 1;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-appearance: none;
    will-change: transform, background;
}

.ai-talk-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 28px rgba(26, 91, 196, 0.5), 0 0 0 4px rgba(26, 91, 196, 0.1);
}

.ai-talk-btn:active {
    transform: scale(0.95);
}

/* Talk button: listening state (red, pressed down) */
.audio-integral-overlay[data-state="listening"] .ai-talk-btn {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.5), 0 0 0 0 rgba(239, 68, 68, 0);
    transform: scale(0.92);
}

/* Talk button: processing state (blue dim) */
.audio-integral-overlay[data-state="processing"] .ai-talk-btn {
    background: linear-gradient(135deg, var(--voice-primary-light) 0%, var(--voice-primary) 100%);
    opacity: 0.7;
    box-shadow: 0 4px 16px rgba(26, 91, 196, 0.3);
}

/* Talk button: speaking state (green) */
.audio-integral-overlay[data-state="speaking"] .ai-talk-btn {
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    box-shadow: 0 4px 20px rgba(52, 211, 153, 0.5), 0 0 0 0 rgba(52, 211, 153, 0);
}

/* Talk button label */
.ai-talk-btn-label {
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    transition: all 0.3s ease;
    letter-spacing: 0.2px;
}

/* Bottom controls (speed + sound wave) */
.ai-bottom-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 4px;
}

.ai-bottom-controls .speed-btn {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 5px 10px;
    font-size: 12px;
}

.ai-bottom-controls .speed-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.ai-bottom-controls .speed-btn.active {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.15);
}

.ai-sound-wave {
    display: none;
    align-items: flex-end;
    gap: 3px;
    height: 24px;
}

.ai-sound-wave.playing {
    display: flex;
}

.ai-sound-wave .wave-bar {
    background: rgba(255, 255, 255, 0.7);
    width: 3px;
}

/* ================================================================
   16. SESSION SEPARATOR
   ================================================================ */

/* Session separator in chat */
.ai-session-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 16px 12px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--voice-primary);
    letter-spacing: 0.3px;
}

.ai-session-separator::before,
.ai-session-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(11, 61, 145, 0.2), transparent);
}

.ai-session-separator .separator-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    background: linear-gradient(135deg, #e8f0fe, #dbeafe);
    border: 1px solid rgba(11, 61, 145, 0.15);
    border-radius: 20px;
    white-space: nowrap;
}

.ai-session-separator .separator-badge i {
    font-size: 11px;
}

/* ================================================================
   17. RESPONSIVE MOBILE
   ================================================================ */
@media (max-width: 480px) {
    .voice-status-bar {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        padding: 5px 10px;
        flex-wrap: wrap;
        gap: 6px;
    }

    .voice-badge {
        font-size: 10px;
        padding: 2px 8px;
    }

    .voice-speed-control {
        margin-left: 0;
    }

    .speed-btn {
        padding: 2px 6px;
        font-size: 10px;
    }

    .auto-read-btn {
        display: inline-flex !important;
        visibility: visible !important;
        height: 26px;
        min-width: 26px;
        padding: 0 6px;
        font-size: 12px;
        border-radius: 13px;
    }

    .auto-read-btn .auto-read-label {
        display: none;
    }

    .audio-live-btn {
        display: inline-flex !important;
        visibility: visible !important;
        padding: 4px 10px;
        font-size: 11px;
    }

    .audio-live-btn span {
        display: none;
    }

    .voice-toast {
        bottom: 80px;
        font-size: 12px;
        padding: 8px 16px;
    }

    .voice-toast.voice-toast-rich {
        max-width: 280px;
        padding: 10px 14px;
    }

    .voice-mic-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
        font-size: 14px;
        border-radius: 10px;
    }

    .chat-footer .send-btn {
        border-radius: 10px !important;
        width: 36px !important;
        height: 36px !important;
    }

    .recording-overlay {
        padding: 10px 12px;
        gap: 8px;
    }

    .recording-overlay .rec-text {
        font-size: 12px;
    }

    .tts-listen-btn {
        font-size: 11px;
        padding: 3px 10px;
    }

    .guest-voice-banner {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        padding: 6px 10px;
        font-size: 12px;
    }

    .gvb-link {
        align-self: flex-end;
    }

    .gvb-actions {
        flex-direction: column;
        width: 100%;
        gap: 6px;
    }

    .gvb-btn {
        justify-content: center;
        width: 100%;
        padding: 8px 14px;
    }

    .guest-limit-banner {
        margin: 8px;
        padding: 12px 16px;
    }

    .guest-limit-banner .guest-limit-btn {
        padding: 7px 16px;
        font-size: 12px;
    }

    /* Audio Integral - mobile */
    .ai-circle {
        width: 160px;
        height: 160px;
    }

    .ai-star {
        width: 100px;
        height: 100px;
    }

    .ai-status-text {
        font-size: 18px;
    }

    .ai-exit-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    /* Talk button - smaller on mobile */
    .ai-talk-btn {
        width: 72px;
        height: 72px;
        font-size: 24px;
    }

    .ai-talk-btn-wrapper {
        width: 90px;
        height: 90px;
    }

    .ai-talk-btn-ring {
        width: 72px;
        height: 72px;
        animation-name: aiTalkRingPulseMobile;
    }

    .ai-talk-btn-label {
        font-size: 12px;
    }

    .ai-bottom-area {
        bottom: 24px;
        bottom: calc(24px + env(safe-area-inset-bottom));
        gap: 10px;
    }
}

/* Mobile ring animation — outside @media for Safari compatibility */
@keyframes aiTalkRingPulseMobile {
    0%, 100% { width: 72px; height: 72px; opacity: 0.6; }
    50%      { width: 90px; height: 90px; opacity: 0; }
}

/* ================================================================
   18. ANIMATIONS
   ================================================================ */
@keyframes voiceFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
