/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   BOTLERS EXPERIENCE - SPA avec Botler contrôleur
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
    background: #000;
    color: #000;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* LAYOUT 70/30 */
.botler-experience {
    position: relative;
    height: 100vh;
    overflow: hidden;
}

.content-frame {
    width: 100%;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f2ebdd;
    position: relative;
}

#content-container {
    position: fixed;
    left: 0;
    top: 0;
    width: 70%;
    height: 100vh;
    transition: opacity 0.3s ease;
    z-index: 1; /* Below widget (z-index: 9999) but visible */
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   DEMO HTML LAYOUT
   Demo HTML files have their own 70/30 layout with avatar placeholder.
   We let them keep their natural layout, and our bot widget overlays on top.
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* Let demos keep their natural layout - bot widget will overlay with higher z-index */

.content-loader {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(139, 92, 246, 0.1);
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.botler-widget {
    position: fixed;
    top: 0;
    right: 0;
    width: 30%;
    min-width: 450px;
    max-width: 900px;  /* Adjusted for proper 30% on large screens */
    height: 100vh;
    background: #000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
    opacity: 1;
    transition: opacity 0.8s ease-out;
}

/* Hide widget initially until splash screen is dismissed */
.botler-widget.hidden {
    opacity: 0;
    pointer-events: none;
}

/* MODE SELECTOR */
.mode-selector {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    gap: 8px;
    padding: 12px;
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mode-btn {
    flex: 1;
    padding: 10px 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.2);
}

.mode-btn.active {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.5);
    color: #fff;
}

.mode-btn .icon {
    font-size: 20px;
}

.mode-btn .label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   BOTLER TAB GLOW PULSE - Incite au clic
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.mode-btn[data-mode="botler"]:not(.active) {
    animation: botlerGlowPulse 2s ease-in-out infinite;
    box-shadow: 0 0 0 rgba(139, 92, 246, 0);
}

@keyframes botlerGlowPulse {
    0%, 100% {
        box-shadow: 0 0 8px rgba(139, 92, 246, 0.3),
                    0 0 16px rgba(139, 92, 246, 0.2);
        border-color: rgba(139, 92, 246, 0.4);
    }
    50% {
        box-shadow: 0 0 16px rgba(139, 92, 246, 0.5),
                    0 0 24px rgba(139, 92, 246, 0.3),
                    0 0 32px rgba(139, 92, 246, 0.2);
        border-color: rgba(139, 92, 246, 0.7);
    }
}

/* Stop animation when Botler tab is active */
.mode-btn[data-mode="botler"].active {
    animation: none;
}

/* AVATAR CONTAINER */
.avatar-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin-top: 56px;
}

.avatar-container.hidden {
    display: none;
}

#avatar-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.status-indicator {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    color: white;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.avatar-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-content {
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
}

.placeholder-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
}

.placeholder-text {
    font-size: 16px;
    font-weight: 500;
}

/* AVATAR START OVERLAY */
.avatar-start-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    z-index: 50;
}

.avatar-start-btn {
    padding: 20px 40px;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    border: none;
    border-radius: 50px;
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.4);
    transition: all 0.3s ease;
}

.avatar-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(139, 92, 246, 0.6);
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
}

.avatar-start-btn:active {
    transform: translateY(0);
}

.avatar-start-btn svg {
    width: 24px;
    height: 24px;
}

/* CHAT CONTAINER */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
    margin-top: 56px;
}

.chat-container.hidden {
    display: none;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-message {
    display: flex;
    gap: 12px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user {
    flex-direction: row-reverse;
}

.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #8b5cf6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.chat-message.user .chat-avatar {
    background: #3b82f6;
}

.chat-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 14px;
    line-height: 1.5;
}

.chat-message.user .chat-bubble {
    background: #3b82f6;
}

/* VOICE TRANSCRIPT */
.voice-transcript {
    padding: 8px 20px;
    background: rgba(139, 92, 246, 0.1);
    border-top: 1px solid rgba(139, 92, 246, 0.2);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.voice-transcript.hidden {
    display: none;
}

.transcript-label {
    font-weight: 600;
    color: #8b5cf6;
    margin-bottom: 4px;
}

.transcript-text {
    color: rgba(255, 255, 255, 0.8);
    font-style: italic;
}

/* CHAT INPUT */
.chat-input-wrapper {
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 8px;
    align-items: center;
}

#chat-input {
    flex: 1;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    color: #fff;
    font-size: 14px;
    outline: none;
    transition: all 0.3s;
}

#chat-input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(139, 92, 246, 0.5);
}

#chat-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.send-btn,
.voice-toggle-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #8b5cf6;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.send-btn:hover,
.voice-toggle-btn:hover {
    background: #7c3aed;
    transform: scale(1.05);
}

.voice-toggle-btn {
    background: rgba(255, 255, 255, 0.1);
}

.voice-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.voice-toggle-btn.active {
    background: #ef4444;
}

/* INFO CAPTURE OVERLAY */
.info-capture-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 20%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    transition: transform 0.3s ease;
    border-top: 1px solid rgba(139, 92, 246, 0.3);
}

.info-capture-overlay.hidden {
    transform: translateY(100%);
}

.info-capture-content {
    width: 85%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-label {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

#info-input {
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    color: #fff;
    font-size: 15px;
    outline: none;
    transition: all 0.3s;
}

#info-input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(139, 92, 246, 0.6);
}

#info-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.info-actions {
    display: flex;
    gap: 10px;
}

.btn-cancel,
.btn-submit {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s;
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-submit {
    background: #8b5cf6;
    color: #fff;
}

.btn-submit:hover {
    background: #7c3aed;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   LIVE TRANSCRIPTION DISPLAY (Real-time speech capture feedback)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.live-transcription {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 100;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.transcription-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.mic-icon {
    color: #ef4444;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.transcription-label {
    font-size: 12px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.transcription-text {
    font-size: 14px;
    color: #fff;
    line-height: 1.5;
    min-height: 20px;
    font-style: italic;
}

.transcription-text:empty::before {
    content: "Listening...";
    color: #6b7280;
    font-style: normal;
}

/* Volume Indicator */
.volume-indicator {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 12px 20px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    z-index: 100;
    animation: pulse-volume 2s ease-in-out infinite;
    cursor: pointer;
    transition: all 0.3s ease;
}

.volume-indicator:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.05);
}

.volume-indicator svg {
    flex-shrink: 0;
}

@keyframes pulse-volume {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

.volume-indicator {
    opacity: 1;
    transition: opacity 0.5s ease;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   MOBILE RESPONSIVE DESIGN (<768px)
   Widget in top (30vh or 40vh), vertical mode buttons on left
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

@media (max-width: 768px) {
    /* Content adjusts for top widget */
    .content-frame {
        padding-top: 30vh; /* Default for Voice/Botler modes */
        min-height: 100vh; /* Full height to show all content */
        height: auto; /* Can grow if content is taller */
        width: 100%;
    }

    /* Content adjusts when Chat mode is active (40vh) */
    body.chat-mode-active .content-frame {
        padding-top: 40vh;
        min-height: 100vh;
        height: auto;
    }

    /* Content container: full width on mobile for proper centering */
    #content-container {
        width: 100%;
        min-height: 70vh; /* Account for 30vh widget at top */
        height: auto;
        margin-top: 30vh; /* Push content below 30vh widget */
        padding-top: 10px;
    }

    /* Adjust for chat mode (40vh widget) */
    body.chat-mode-active #content-container {
        min-height: 60vh; /* Account for 40vh widget at top */
        margin-top: 40vh; /* Push content below 40vh widget in chat mode */
    }

    /* Widget takes full width, positioned at top */
    .botler-widget {
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        height: 30vh; /* Default for Voice/Botler */
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
        flex-direction: row; /* Change to horizontal layout */
    }

    /* Chat mode gets more height */
    .botler-widget.chat-mode {
        height: 40vh;
    }

    /* Mode selector: vertical on left side */
    .mode-selector {
        position: relative;
        flex-direction: column;
        width: 60px;
        height: 100%;
        padding: 0;
        gap: 0;
        border-bottom: none;
        border-right: 1px solid rgba(255, 255, 255, 0.1);
    }

    /* Mode buttons: equal height, vertical stack */
    .mode-btn {
        flex: 1;
        width: 100%;
        padding: 12px 4px;
        border-radius: 0;
        border: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        font-size: 9px;
    }

    .mode-btn:last-child {
        border-bottom: none;
    }

    .mode-btn .icon {
        font-size: 24px;
    }

    .mode-btn .label {
        font-size: 8px;
    }

    /* Avatar container adjusts for mobile */
    .avatar-container {
        margin-top: 0;
        width: calc(100% - 60px); /* Account for mode selector */
        height: 100%;
    }

    /* Voice orb container */
    .voice-orb-container {
        width: calc(100% - 60px);
        height: 100%;
    }

    /* Chat container for mobile */
    .chat-container {
        margin-top: 0;
        width: calc(100% - 60px);
        height: 100%;
    }

    /* Chat messages: scrollable, auto-scroll to bottom */
    .chat-messages {
        height: calc(100% - 80px); /* Leave room for input */
        overflow-y: auto;
        padding: 12px;
    }

    /* Chat input wrapper */
    .chat-input-wrapper {
        position: absolute;
        bottom: 0;
        left: 60px;
        right: 0;
        padding: 12px;
        background: rgba(0, 0, 0, 0.95);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    /* Adjust avatar video for 16/9 ratio maintenance */
    #avatar-video {
        object-fit: cover; /* Maintain aspect ratio */
    }

    /* Live transcription tooltip positioning for mobile */
    .live-transcription {
        bottom: 10px;
        left: 70px; /* Account for mode selector */
        right: 10px;
        max-width: calc(100% - 80px);
    }
}
