/* Mafox AI Chatbot Styles */
:root {
    --chat-primary: #00d4ff;
    --chat-secondary: #8b5cf6;
    --chat-bg: #0a0f1a;
    --chat-bg-glass: rgba(10, 15, 26, 0.95);
    --chat-text: #ffffff;
    --chat-text-muted: #9ca3af;
    --chat-border-radius: 16px;
    --chat-font: 'Inter', sans-serif;
    --chat-mono: 'JetBrains Mono', monospace;
}

/* Floating Toggle Button (Hologram Edition) */
.mafox-chat-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 70px;
    /* Slightly larger for glow */
    height: 70px;
    background: transparent;
    /* Remove solid background */
    border-radius: 50%;
    border: none;
    cursor: pointer;
    z-index: 9999;
    /* Remove box-shadow from container, moving to icon */
    /* box-shadow: 0 0 20px rgba(0, 212, 255, 0.4); */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mafox-chat-toggle:hover {
    transform: scale(1.1);
}

/* Hide Toggle when Chat is Open */
.mafox-chat-toggle.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

/* Hologram Icon Styling */
.hologram-icon {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    opacity: 0.9;
    box-shadow:
        0 0 15px var(--chat-primary),
        inset 0 0 10px var(--chat-primary);
    animation: hologramPulse 4s infinite ease-in-out;
    filter: drop-shadow(0 0 5px rgba(0, 212, 255, 0.8));
}

@keyframes hologramPulse {

    0%,
    100% {
        box-shadow: 0 0 15px var(--chat-primary), inset 0 0 10px var(--chat-primary);
        filter: brightness(1) drop-shadow(0 0 5px rgba(0, 212, 255, 0.8));
        opacity: 0.85;
    }

    50% {
        box-shadow: 0 0 30px var(--chat-primary), inset 0 0 20px var(--chat-secondary);
        filter: brightness(1.2) drop-shadow(0 0 15px rgba(0, 212, 255, 1));
        opacity: 1.0;
    }
}

.mafox-chat-toggle .notification-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 12px;
    height: 12px;
    background: #FF0055;
    border-radius: 50%;
    z-index: 10;
    box-shadow: 0 0 5px #FF0055;
}

/* Chat Hint Bubble */
.chat-hint-bubble {
    position: absolute;
    top: -12px;
    right: -12px;
    background: #ff0055;
    /* Vibrant Pink/Red */
    color: #fff;
    border-radius: 12px;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(255, 0, 85, 0.4);
    animation: floatBubble 3s ease-in-out infinite;
    z-index: 20;
    pointer-events: none;
    /* Let clicks pass through to button */
}

.chat-hint-bubble svg {
    display: block;
    fill: #fff;
    /* White bubble */
}

.chat-hint-bubble svg circle {
    fill: #ff0055;
    /* Dots match bg */
}

@keyframes floatBubble {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

/* Chat Window */
.mafox-chat-window {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 350px;
    height: 550px;
    /* Fixed height */
    background: var(--chat-bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: var(--chat-border-radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0);
    opacity: 0;
    transition: all 0.3s ease;
    font-family: var(--chat-font);
}

.mafox-chat-window.active {
    transform: scale(1);
    opacity: 1;
}

/* Chat Header - Compact Vertical Layout */
.chat-header {
    background: rgba(10, 15, 26, 0.95);
    border-bottom: none;
    padding: 10px 12px;
    /* Reduced padding */
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* Reduced gap */
    border-radius: 16px 16px 0 0;
    position: relative;
    flex-shrink: 0;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    /* Align top to handle close button */
    width: 100%;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-avatar {
    width: 36px;
    /* Smaller avatar */
    height: 36px;
    border-radius: 50%;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(0, 212, 255, 0.3);
}

.title-text {
    display: flex;
    flex-direction: column;
}

.title-text span {
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    letter-spacing: 0.5px;
}

.chat-status {
    width: 8px;
    height: 8px;
    background: #00ff88;
    border-radius: 50%;
    box-shadow: 0 0 5px #00ff88;
    margin-top: 4px;
    /* Space below name */
}

/* Close Button - Top Right */
.chat-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 5px;
    margin-top: -5px;
    /* Visual adjustment */
    transition: color 0.3s;
}

.chat-close:hover {
    color: #fff;
}

/* Center Action Area (Mic) */
.header-center {
    display: flex;
    justify-content: center;
    width: 100%;
    padding-bottom: 10px;
    margin-bottom: 0;
    border-bottom: 2px solid #00d4ff;
    /* Blue Separator */
}

/* Adjust Mic Button Hover */
.chat-mic:hover {
    background: rgba(0, 212, 255, 0.2) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.15);
}

/* Messages Area - Messenger Style Scrolling */
.chat-messages {
    flex: 1;
    min-height: 0;
    /* CRITICAL for flex scrolling */
    padding: 15px 15px 40px 15px;
    /* Extra bottom padding for safety */
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Message Bubbles */
.message {
    max-width: 80%;
    padding: 12px 16px;
    /* Slightly more padding */
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    position: relative;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.bot {
    align-self: flex-start;
    background: #1e293b;
    /* Solid dark color for readability */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom-left-radius: 2px;
    color: #e2e8f0;
    /* Brighter white/grey for text */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.3), rgba(139, 92, 246, 0.3));
    /* More opaque */
    border: 1px solid rgba(0, 212, 255, 0.4);
    border-bottom-right-radius: 2px;
    color: #fff;
    box-shadow: 0 2px 5px rgba(0, 212, 255, 0.1);
}

/* Input Area - Permanent Footer */
.chat-input-area {
    margin-top: auto;
    padding: 15px;
    background: #0a0f1a;
    /* Solid background - no glass */
    border-top: 1px solid rgba(0, 212, 255, 0.2);
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.3);
    /* Shadow to separate from messages */
    z-index: 10;
}

.chat-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 10px 15px;
    color: var(--chat-text);
    font-family: var(--chat-font);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.3s;
}

.chat-input:focus {
    border-color: var(--chat-primary);
}

.chat-send {
    background: var(--chat-primary);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.chat-send:hover {
    transform: scale(1.1);
}

.chat-send svg {
    width: 18px;
    height: 18px;
    fill: #000;
}

.chat-send:disabled {
    background: #333;
    cursor: not-allowed;
}

/* Typing Indicator */
.typing-indicator .dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--chat-text-muted);
    border-radius: 50%;
    margin-right: 4px;
    animation: typing 1s infinite alternate;
}

.typing-indicator .dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator .dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Typing Indicator Text */
.typing-indicator .typing-text {
    display: inline-block;
    width: auto !important;
    margin-right: 10px;
    font-size: 0.9em;
    color: var(--chat-text-muted);
}

@keyframes typing {
    from {
        opacity: 0.3;
        transform: translateY(0);
    }

    to {
        opacity: 1;
        transform: translateY(-3px);
    }
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .mafox-chat-window {
        width: 100%;
        height: 100%;
        max-height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
}

/* --- Voice Mode Styles --- */

/* Mic Button in Header */
.chat-mic {
    background: none;
    border: none;
    color: var(--chat-text-muted);
    cursor: pointer;
    transition: color 0.3s, transform 0.2s;
    margin-right: 10px;
}

.chat-mic:hover {
    color: var(--chat-primary);
    transform: scale(1.1);
}

/* Voice Widget (Desktop Floating) */
.voice-overlay {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 350px;
    max-height: 600px;
    height: auto;
    background: var(--chat-bg-glass);
    backdrop-filter: blur(10px);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: var(--chat-border-radius);
    border: 1px solid rgba(0, 212, 255, 0.2);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
}

.voice-overlay.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

/* Voice Header with Title */
.voice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(0, 212, 255, 0.3);
}

.voice-title {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    margin: 0;
    letter-spacing: 0.5px;
}

.voice-header .voice-close-x {
    position: static;
    background: none;
    border: none;
    font-size: 24px;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: color 0.3s;
    padding: 0;
    line-height: 1;
}

.voice-header .voice-close-x:hover {
    color: #fff;
}

.voice-content {
    text-align: center;
    padding: 30px 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Status Icons Container */
.voice-status-container {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    position: relative;
    width: 100%;
}

/* 1. Listening State (Mic) */
.voice-mic-icon {
    width: 60px;
    height: 60px;
    background: rgba(0, 212, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--chat-primary);
    position: absolute;
    transition: all 0.3s;
    opacity: 0;
    transform: scale(0.8);
    z-index: 2;
    /* On top of waves */
}

.voice-mic-icon svg {
    width: 30px;
    height: 30px;
    fill: currentColor;
}

.voice-status-container[data-state="listening"] .voice-mic-icon {
    opacity: 1;
    transform: scale(1);
    animation: micPulse 2s infinite;
}

@keyframes micPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 212, 255, 0.4);
        transform: scale(1);
    }

    10% {
        transform: scale(1.1) rotate(3deg);
    }

    20% {
        transform: scale(1) rotate(-3deg);
    }

    30% {
        transform: scale(1.1) rotate(3deg);
    }

    40% {
        transform: scale(1);
    }

    70% {
        box-shadow: 0 0 0 20px rgba(0, 212, 255, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0, 212, 255, 0);
        transform: scale(1);
    }
}

/* 2. Thinking State (Spinner) */
.voice-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--chat-primary);
    border-radius: 50%;
    position: absolute;
    opacity: 0;
    transition: all 0.3s;
}

.voice-status-container[data-state="thinking"] .voice-spinner,
.voice-status-container[data-state="connecting"] .voice-spinner {
    opacity: 1;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 3. Speaking State (Waves) */
.voice-waves {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 60px;
    position: absolute;
    opacity: 0;
    transition: all 0.3s;
}

/* Show in Speaking AND Listening */
.voice-status-container[data-state="speaking"] .voice-waves,
.voice-status-container[data-state="listening"] .voice-waves {
    opacity: 1;
}

/* Animations active in both states */
.voice-status-container[data-state="speaking"] .wave,
.voice-status-container[data-state="listening"] .wave {
    animation: waveDance 1.2s infinite ease-in-out;
}

.voice-status-container[data-state="speaking"] .wave:nth-child(1),
.voice-status-container[data-state="listening"] .wave:nth-child(1) {
    animation-delay: 0.1s;
}

.voice-status-container[data-state="speaking"] .wave:nth-child(2),
.voice-status-container[data-state="listening"] .wave:nth-child(2) {
    animation-delay: 0.2s;
}

.voice-status-container[data-state="speaking"] .wave:nth-child(3),
.voice-status-container[data-state="listening"] .wave:nth-child(3) {
    animation-delay: 0.3s;
}

.voice-status-container[data-state="speaking"] .wave:nth-child(4),
.voice-status-container[data-state="listening"] .wave:nth-child(4) {
    animation-delay: 0.2s;
}

.voice-status-container[data-state="speaking"] .wave:nth-child(5),
.voice-status-container[data-state="listening"] .wave:nth-child(5) {
    animation-delay: 0.1s;
}


.wave {
    width: 6px;
    height: 20px;
    background: linear-gradient(to top, var(--chat-primary), var(--chat-secondary));
    border-radius: 3px;
    transition: height 0.1s ease;
    /* Smooth visualizer */
}

@keyframes waveDance {

    0%,
    100% {
        height: 10px;
    }

    50% {
        height: 40px;
    }
}

/* Text Status */
.voice-status-text {
    font-family: var(--chat-font);
    font-size: 1.25rem;
    color: #fff;
    margin-bottom: 5px;
    font-weight: 600;
    min-height: 1.5em;
}

.voice-subtext {
    font-size: 0.85rem;
    color: var(--chat-text-muted);
    margin-bottom: 20px;
    line-height: 1.5;
    padding: 0 10px;
}

/* Transcript Area */
.voice-transcripts {
    max-height: 0;
    overflow-y: auto;
    margin: 0;
    padding: 0 10px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    transition: max-height 0.3s ease, margin 0.3s ease;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.voice-transcripts.visible {
    max-height: 200px;
    margin-bottom: 20px;
    padding: 10px;
}

/* Controls */
.voice-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.transcription-toggle {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--chat-text-muted);
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.transcription-toggle:hover,
.transcription-toggle.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

.voice-stop-btn {
    background: rgba(255, 59, 48, 0.2);
    border: 1px solid rgba(255, 59, 48, 0.5);
    color: #ff3b30;
    padding: 10px 24px;
    border-radius: 30px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

.voice-stop-btn:hover {
    background: rgba(255, 59, 48, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 59, 48, 0.2);
}

.voice-close-x {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--chat-text-muted);
    cursor: pointer;
    transition: color 0.3s;
}

.voice-close-x:hover {
    color: #fff;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .voice-overlay {
        position: fixed;
        width: 100% !important;
        height: 100% !important;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 0;
        max-height: none;
        transform: translateY(0) scale(0.9);
    }

    .voice-overlay.active {
        transform: scale(1);
    }

    .voice-stop-btn {
        padding: 15px 30px;
        /* Larger touch target */
        font-size: 1rem;
    }

    .transcription-toggle {
        padding: 15px;
        width: 50px;
        height: 50px;
    }
}