/* =====================================
   DEMO CHAT - MOBILE OPTIMIZED CSS
   Otimizado para celular sem clipping
   ===================================== */

/* Variáveis customizadas */
:root {
    --mobile-padding: 0.5rem;
    --tablet-padding: 0.75rem;
    --desktop-padding: 1rem;
}

/* =====================================
   MOBILE FIRST APPROACH
   ===================================== */

/* ========== DEMO CONTAINER ==========*/
.demo-container {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    gap: 0;
    width: 100%;
    height: auto;
    margin: 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    max-width: 100%;
    box-sizing: border-box;
}

/* ========== DEMO SCREEN ==========*/
.demo-screen {
    position: relative;
    background: #0E0E10;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    width: 100%;
    height: auto;
    min-height: 240px;
    aspect-ratio: 16 / 9;
    order: 1;
}

.demo-background {
    position: absolute;
    inset: 0;
    background-image: url('/static/images/demo/ai-bg-1.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    transition: background-image 1.5s ease-out;
    opacity: 1;
    width: 100%;
    height: 100%;
    /* will-change removido para economizar memória GPU */
    contain: layout style;
}

/* ========== STREAM OVERLAY ==========*/
.stream-overlay {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 3px;
    pointer-events: none;
}

.stream-title {
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 4px 7px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100vw - 90px);
    line-height: 1.2;
}

.viewer-count {
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 0.6rem;
    width: fit-content;
    line-height: 1.1;
}

/* ========== STREAMER CAM ==========*/
.demo-streamer {
    position: absolute;
    bottom: 8px;
    right: 8px;
    z-index: 3;
    /* backdrop-filter removido para performance mobile */
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
}

.streamer-cam {
    width: 65px;
    height: 44px;
    border-radius: 4px;
    border: 2px solid var(--primary-color);
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    /* backdrop-filter removido para performance mobile */
    display: block;
    image-rendering: crisp-edges;
}

/* ========== DEMO CHAT ==========*/
.demo-chat {
    background: #18181B;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: auto;
    min-height: auto;
    box-shadow: none;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    order: 2;
    overflow: visible;
    flex-shrink: 0;
}

.chat-header {
    padding: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
    min-height: 32px;
    display: flex;
    align-items: center;
}

.chat-header h4 {
    color: #EFEFF1;
    margin: 0;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header i {
    color: #9146FF;
    font-size: 0.95rem;
    flex-shrink: 0;
}

/* ========== CHAT MESSAGES ==========*/
.chat-messages {
    flex: 1;
    padding: 0.6rem;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 200px;
    max-height: 240px;
    scrollbar-width: thin;
    scrollbar-color: #3A3A3D transparent;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 1;
}

.chat-messages::-webkit-scrollbar {
    width: 3px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: #3A3A3D;
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background-color: #4A4A4D;
}

/* ========== CHAT MESSAGE ==========*/
.chat-message {
    animation: messageAppear 0.25s ease;
    padding: 0.5rem 0.6rem;
    margin: 0;
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    font-size: 0.72rem;
    line-height: 1.5;
    transition: all 0.2s ease;
    border-radius: 3px;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    min-height: auto;
    flex-wrap: nowrap;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.6rem;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.chat-message:hover {
    background: rgba(255, 255, 255, 0.03);
}

.username {
    font-weight: 700;
    margin-right: 0.3rem;
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 0.71rem;
    min-width: fit-content;
    line-height: 1.5;
}

.username.viewer { 
    color: #EFEFF1; 
}

.username.mod { 
    color: #00FF00; 
    text-shadow: 0 0 3px rgba(0, 255, 0, 0.3);
}

.username.sub { 
    color: #9147FF;
    text-shadow: 0 0 3px rgba(145, 71, 255, 0.3);
}

.message-text {
    color: #EFEFF1;
    flex: 1;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    min-width: 0;
    display: inline;
    line-height: 1.5;
    text-align: left;
    white-space: normal;
    overflow: visible;
}

@keyframes messageAppear {
    0% {
        opacity: 0;
        transform: translateX(-10px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ========== DEMO COMMANDS ==========*/
/* ========== DEMO INPUT AREA ==========*/
.demo-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.2), rgba(20, 20, 30, 0.3));
    flex-shrink: 0;
    align-items: stretch;
    min-height: 40px;
}

.demo-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(138, 43, 226, 0.2);
    color: #EFEFF1;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-family: 'Courier New', monospace;
    transition: all 0.2s ease;
    cursor: pointer !important;
    outline: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    min-height: 32px;
    display: flex;
    align-items: center;
}

.demo-input:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(138, 43, 226, 0.5);
    box-shadow: 0 0 8px rgba(138, 43, 226, 0.2);
}

.demo-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.demo-send-btn {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.2), rgba(138, 43, 226, 0.1));
    border: 1px solid rgba(138, 43, 226, 0.3);
    color: var(--primary-light);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    min-width: 40px;
    flex-shrink: 0;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.demo-send-btn:hover {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.3), rgba(138, 43, 226, 0.2));
    border-color: rgba(138, 43, 226, 0.5);
    transform: scale(1.05);
}

.demo-send-btn:active {
    background: rgba(138, 43, 226, 0.25);
    transform: scale(0.95);
    box-shadow: 0 1px 4px rgba(138, 43, 226, 0.15);
}

.demo-send-btn i {
    font-size: 1rem;
}

.demo-commands {
    padding: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.25rem;
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.2), rgba(20, 20, 30, 0.3));
    flex-shrink: 0;
    min-height: auto;
    overflow: hidden;
}

.demo-cmd-btn {
    background: rgba(138, 43, 226, 0.1);
    border: 1px solid rgba(138, 43, 226, 0.3);
    color: var(--primary-light);
    padding: 0.5rem 0.75rem;
    border-radius: 5px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Courier New', monospace;
    font-weight: 600;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
}

.demo-cmd-btn:active {
    background: rgba(138, 43, 226, 0.2);
    transform: scale(0.97);
    box-shadow: 0 1px 4px rgba(138, 43, 226, 0.15);
}

.demo-cmd-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========== TABLET ADJUSTMENTS (768px) ========== */
@media (max-width: 768px) and (min-width: 481px) {
    .demo-container {
        border-radius: 16px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    }

    .demo-screen {
        min-height: 280px;
    }

    .stream-overlay {
        top: 10px;
        left: 10px;
        gap: 5px;
    }

    .stream-title {
        font-size: 0.75rem;
        padding: 5px 9px;
    }

    .viewer-count {
        font-size: 0.7rem;
        padding: 3px 6px;
    }

    .demo-streamer {
        bottom: 10px;
        right: 10px;
    }

    .streamer-cam {
        width: 85px;
        height: 57px;
    }

    .chat-header {
        padding: 0.75rem;
    }

    .chat-header h4 {
        font-size: 0.9rem;
    }

    .chat-messages {
        padding: 0.8rem;
        gap: 0.5rem;
        max-height: 280px;
        min-height: 200px;
    }

    .chat-message {
        font-size: 0.78rem;
        padding: 0.55rem 0.7rem;
        padding-bottom: 0.65rem;
        min-height: 28px;
    }

    .username {
        font-size: 0.76rem;
    }

    .demo-input-area {
        padding: 0.75rem;
        gap: 0.5rem;
    }

    .demo-input {
        padding: 0.6rem 0.85rem;
        font-size: 0.8rem;
        min-height: 36px;
    }

    .demo-send-btn {
        padding: 0.6rem 0.85rem;
        min-height: 36px;
        min-width: 36px;
    }

    .demo-commands {
        padding: 0.75rem;
        gap: 0.375rem;
        overflow: hidden;
    }

    .demo-cmd-btn {
        font-size: 0.75rem;
        padding: 0.6rem 0.85rem;
    }
}

/* ========== DESKTOP ADJUSTMENTS (769px+) ========== */
@media (min-width: 769px) {
    .demo-container {
        grid-template-columns: 2fr 1fr;
        grid-template-rows: auto;
        border-radius: 20px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
        min-height: 500px;
    }

    .demo-screen {
        order: 1;
        min-height: 400px;
    }

    .stream-overlay {
        top: 20px;
        left: 20px;
        gap: 8px;
    }

    .stream-title {
        font-size: 0.9rem;
        padding: 8px 12px;
    }

    .viewer-count {
        font-size: 0.8rem;
        padding: 4px 8px;
    }

    .demo-streamer {
        bottom: 20px;
        right: 20px;
    }

    .streamer-cam {
        width: 120px;
        height: 80px;
        border: 3px solid var(--primary-color);
        border-radius: 8px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    }

    .demo-chat {
        order: 2;
        min-height: auto;
        height: auto;
        border-radius: 0 12px 12px 0;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
        border-top: none;
        display: flex;
        flex-direction: column;
    }

    .chat-header {
        padding: 1rem;
        flex-shrink: 0;
    }

    .chat-header h4 {
        font-size: 1rem;
        gap: 0.5rem;
    }

    .chat-messages {
        padding: 1.2rem;
        gap: 0.6rem;
        max-height: 360px;
        min-height: 280px;
        flex: 1;
        flex-shrink: 1;
    }

    .chat-message {
        font-size: 0.9rem;
        padding: 0.6rem 0.9rem;
        padding-bottom: 0.7rem;
        min-height: 30px;
    }

    .username {
        font-size: 0.92rem;
    }

    .demo-input-area {
        padding: 1rem;
        gap: 0.75rem;
        flex-shrink: 0;
        align-items: stretch;
        min-height: 44px;
    }

    .demo-input {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        min-height: 40px;
    }

    .demo-send-btn {
        padding: 0.75rem 1rem;
        min-height: 40px;
        min-width: 40px;
    }

    .demo-commands {
        padding: 1rem;
        gap: 0.5rem;
        overflow: hidden;
    }

    .demo-cmd-btn {
        font-size: 0.85rem;
        padding: 0.75rem 1rem;
    }
}

/* ========== PREVENT CLIPPING & OVERFLOW ========== */
.interactive-demo,
.demo-chat,
.demo-screen {
    box-sizing: border-box;
}

* {
    box-sizing: border-box;
}

/* Prevent text selection on buttons */
.demo-cmd-btn {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Smooth scrolling para chat messages */
@supports (scroll-behavior: smooth) {
    .chat-messages {
        scroll-behavior: smooth;
    }
}

/* Performance otimizada para mobile - removido will-change pesado */
.chat-message,
.demo-cmd-btn {
    /* will-change removido para economizar memória */
    contain: layout style;
}

/* Melhorar touch experience */
@media (hover: none) and (pointer: coarse) {
    .demo-cmd-btn {
        min-height: 44px;
        font-size: 0.75rem;
    }

    .chat-message {
        padding: 0.5rem 0.6rem;
        min-height: auto;
    }
}

/* ========== OTIMIZAÇÕES DE PERFORMANCE MOBILE ========== */
/* Respeitar preferência de movimento reduzido do usuário */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .demo-background {
        transition: none !important;
    }
    
    .chat-message {
        animation: none !important;
    }
}

/* Desativar efeitos pesados em dispositivos móveis */
@media (max-width: 768px) {
    /* Remover backdrop-filter que causa lag em mobile */
    .demo-streamer,
    .streamer-cam,
    .stream-overlay {
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
    }
    
    /* Simplificar transições */
    .demo-background {
        transition: background-image 0.8s ease-out !important;
    }
    
    /* Reduzir complexidade de animações */
    .chat-message {
        animation-duration: 0.15s !important;
    }
    
    /* Desativar transformações desnecessárias */
    .demo-cmd-btn:hover,
    .demo-cmd-btn:active {
        transform: none !important;
    }
    
    /* Otimização de scroll */
    .chat-messages {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: auto;
    }
}