/* client/lumi-terminal.css */

.terminal-light-beam {
    position: absolute;
    top: 0px !important;
    left: 0 !important;
    width: 100% !important;
    height: 3px !important; /* Aumentado para 3px conforme solicitado */
    pointer-events: none;
    z-index: 1100;
    overflow: hidden;
}

.terminal-light-beam::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 350px; /* Largura aumentada conforme solicitado */
    height: 100%;
    background: linear-gradient(90deg, 
        transparent 0%, 
        var(--accent-color, #FFD700) 50%, 
        transparent 100%
    );
    box-shadow: 0 0 15px var(--accent-color, #FFD700);
    animation: beam-sweep 4s cubic-bezier(0.4, 0, 0.2, 1) 2s infinite;
    transform: translateX(-350px);
}

.terminal-light-beam svg {
    display: none; /* Hide old SVG implementation */
}

/* --- Main Container --- */
.lumi-terminal-container {
    position: fixed;
    bottom: 20px;
    left: 20px; 
    transform: translateX(0);
    width: 700px;
    max-width: 90%; 
    
    /* ... existing properties ... */
    
    will-change: height, width;
    /* Transição mais suave (Curve Bezier para efeito "premium") */
    transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}

.lumi-terminal-container.is-hidden {
    display: none !important;
}

/* --- States (Open, Minimized, Maximized) --- */

/* Estado Expandido (Sidebar Style) */
.lumi-terminal-container.open,
.lumi-terminal-container.maximized {
    --header-spacing: 140px; 
    bottom: 20px !important;
    top: auto !important; /* Keep it anchored to bottom */
    height: calc(100vh - var(--header-spacing) - 20px) !important;
    max-height: calc(100vh - var(--header-spacing) - 20px) !important;
    width: 700px !important;
    max-width: 90vw;
    border-radius: 12px; /* Cantos levemente arredondados no desktop */
    overflow-y: auto !important; /* Enable internal scrolling when expanded */
}

/* Estado Minimizado */
.lumi-terminal-container.minimized {
    height: 56px !important; /* Ajustado para a nova altura */
    min-height: 56px;
    overflow: hidden; /* Garante que nada vaze */
}

/* Quando minimizado ou colapsado, escondemos o formulário para evitar ícones flutuantes */
.lumi-terminal-container.minimized #lumi-terminal-form,
.lumi-terminal-container.collapsed #lumi-terminal-form {
    display: none !important;
}

/* Quando minimizado, escondemos explicitamente a saída */
.lumi-terminal-container.minimized .lumi-terminal-output {
    display: none;
}


/* Estado Colapsado */
.lumi-terminal-container.collapsed {
    height: 56px; /* Ajustado para a nova altura */
    width: 700px;
    max-width: 90%;
}

.lumi-terminal-container.collapsed .lumi-terminal-output {
    opacity: 0;
    /* height: 0; Removido para permitir cálculo, overflow do pai cuida disso */
}

/* --- Header & Controls --- */
.lumi-terminal-header {
    background-color: transparent; /* Remove fundo sólido para manter o blur */
    padding: 0 20px; /* Remove padding vertical para centralizar via flex */
    display: flex;
    align-items: center;
    cursor: grab;
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05); /* Divisória ultra sutil */
    
    /* Altura fixa igual ao container fechado para centralização perfeita */
    height: 56px; 
    min-height: 56px;
    flex-shrink: 0; 
    overflow: hidden; /* Prevent icons from sticking out */
}

.lumi-terminal-header span {
    font-family: 'Courier New', Courier, monospace;
    color: #ffffff;
    font-size: 0.9rem; /* Fonte levemente menor para elegância */
    letter-spacing: 0.5px;
}

.lumi-terminal-resize-handle {
    position: absolute;
    top: -5px;
    left: 0;
    width: 100%;
    height: 10px;
    cursor: row-resize;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0; /* Invisível até passar o mouse para ser mais limpo */
    transition: opacity 0.2s;
}

.lumi-terminal-container:hover .lumi-terminal-resize-handle {
    opacity: 1;
}

.lumi-terminal-resize-handle::before {
    content: '';
    width: 40px; /* Menor */
    height: 3px; /* Mais fino */
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.lumi-terminal-resize-handle:hover::before {
    background-color: var(--gold-primary, #D4AF37);
}

/* Buttons & Toggles */
.lumi-terminal-input-wrapper {
    position: relative;
    flex-grow: 1;
    display: flex;
    align-items: center;
    min-width: 0;
    overflow: hidden;
    gap: 2px;
}

.lumi-terminal-input {
    flex-grow: 1;
    flex-shrink: 1;
    min-width: 50px; /* Garante que o input possa encolher */
    background: none;
    border: none;
    outline: none;
    color: rgba(234, 234, 234, 0.9); /* Texto levemente suavizado */
    font-family: inherit;
    font-size: 0.95rem; /* Tamanho confortável */
    padding: 0;
    caret-color: #ffffff;
    position: relative;
    z-index: 2;
}

.lumi-terminal-button {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6); /* Cinza levemente transparente */
    font-size: 14px;
    cursor: pointer;
    padding: 5px;
    margin: 0 2px;
    transition: color 0.2s;
    flex-shrink: 0; /* Impede que os ícones encolham */
}

/* --- MORE OPTIONS MENU (BASE/MOBILE FIRST) --- */
.lumi-terminal-more-btn {
    display: none; 
}

.lumi-terminal-more-menu {
    display: none; /* Escondido por padrão (será flex no desktop ou mobile-active) */
}

/* --- DESKTOP SPECIFIC BAR --- */
@media (min-width: 769px) {
    .lumi-terminal-more-menu {
        display: flex !important;
        align-items: center;
        gap: 2px;
    }
    .lumi-terminal-more-menu .lumi-terminal-button span {
        display: none; /* Esconde texto no desktop bar */
    }
}

.lumi-terminal-ghost {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    color: rgba(255, 255, 255, 0.25); /* Cinza claro para o ghost text */
    font-family: inherit;
    font-size: 0.95rem;
    padding: 0;
    pointer-events: none;
    z-index: 1;
    display: flex;
    align-items: center;
    white-space: pre;
    overflow: hidden;
}

.lumi-terminal-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
    font-style: italic;
}

/* --- Autocomplete Suggestions --- */
.lumi-terminal-suggestions {
    position: absolute; /* Default to absolute for pop-up behavior */
    bottom: 100%; /* Pop up above the terminal bar when not open */
    top: auto;
    left: 0;
    right: 0;
    background-color: rgba(10, 10, 15, 0.95); /* Slightly more opaque for pop-up clarity */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    max-height: 150px;
    overflow-y: auto;
    z-index: 1100; /* Ensure it's above everything */
    display: none; /* Hidden by default */
}

.lumi-terminal-suggestions .suggestion-item {
    padding: 8px 20px;
    color: #ccc;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s, color 0.2s;
}

.lumi-terminal-suggestions .suggestion-item:hover {
    background-color: rgba(255, 215, 0, 0.1); /* Darker, more subtle hover */
    color: #FFD700;
}

.lumi-terminal-suggestions .suggestion-item.active {
    background-color: rgba(255, 215, 0, 0.2); /* Darker, more subtle active */
    color: #fff;
}

/* Quando o terminal está aberto, as sugestões ficam no topo da área interna */
.lumi-terminal-container.open .lumi-terminal-suggestions {
    position: sticky;
    top: 0;
    bottom: auto;
    border-bottom: 1px solid rgba(255, 215, 0, 0.3); /* Adiciona borda inferior para consistência */
}


/* --- Terminal Output Area --- */
.lumi-terminal-output {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px 20px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.5; /* Melhor leitura */
    
    display: block; /* Precisamos que o bloco exista para o JS calcular a altura */
    opacity: 1; 
    transition: opacity 0.3s ease;
    
    /* CRT Effects */
    position: relative;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%), 
                linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
    background-size: 100% 3px, 3px 100%;
    animation: crt-flicker 0.15s infinite;
}

.lumi-terminal-output::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: rgba(18, 16, 16, 0.03);
    opacity: 0;
    z-index: 2;
    pointer-events: none;
    animation: crt-flicker-heavy 0.15s infinite;
}

@keyframes crt-flicker {
    0% { opacity: 0.98; }
    50% { opacity: 1; }
    100% { opacity: 0.99; }
}

@keyframes crt-flicker-heavy {
    0% { opacity: 0; }
    10% { opacity: 0.01; }
    100% { opacity: 0; }
}

.lumi-terminal-line {
    margin-bottom: 8px; /* Mais espaço entre linhas */
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.2); /* Sutil glow no texto */
    position: relative;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    display: flex;
    align-items: flex-start;
    padding-right: 30px; /* Space for the X button */
}

.lumi-message-dismiss-btn {
    position: absolute;
    right: 5px;
    top: 5px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    font-size: 12px;
    padding: 5px;
    transition: all 0.2s ease;
    opacity: 0; /* Hidden by default, shown on hover */
    z-index: 5;
}

.lumi-terminal-line:hover .lumi-message-dismiss-btn {
    opacity: 1;
    color: rgba(255, 255, 255, 0.5);
}

.lumi-message-dismiss-btn:hover {
    color: #ff4444 !important;
    transform: scale(1.1);
}

.lumi-message-content {
    flex-grow: 1;
    word-break: break-word;
}

/* Ensure product grid and other special elements still work with the new line structure */
.lumi-terminal-line.products {
    display: block;
    padding-right: 0;
}

.lumi-terminal-line.user {
    color: #FFFFFF !important;
}

.lumi-terminal-line.lumi {
    color: #e0e0e0 !important;
}

.lumi-terminal-line.lumi-status {
    color: #888888 !important;
    font-size: 0.85rem;
}

.lumi-terminal-line a {
    color: #b0b0b0;
    text-decoration: underline;
}

/* --- Special Elements --- */
.ai-video-icon {
    width: 60px; /* Ícone um pouco menor para combinar com a barra fina */
    object-fit: cover;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.ai-video-icon:hover {
    opacity: 1;
}

/* Lumi Thinking Indicator */
#lumi-thinking-indicator {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    opacity: 0.8;
    color: #ffd700;
}

.thinking-dots {
    display: flex;
    gap: 3px;
    align-items: center;
}

.thinking-dots span {
    width: 4px;
    height: 4px;
    background-color: #ffd700;
    border-radius: 50%;
    display: inline-block;
    animation: thinking-jump 1.4s infinite ease-in-out;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinking-jump {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

.halo-spinner {
    width: 12px;
    height: 12px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 2px;
}

.halo-spinner div {
    background-color: rgba(255, 215, 0, 0.8);
    animation: halo-square-spin 1.5s infinite ease-in-out;
}

/* Stagger animation delays */
.halo-spinner div:nth-child(1) { animation-delay: 0.1s; }
.halo-spinner div:nth-child(2) { animation-delay: 0.2s; }
.halo-spinner div:nth-child(3) { animation-delay: 0.3s; }
.halo-spinner div:nth-child(4) { animation-delay: 0.4s; }
.halo-spinner div:nth-child(5) { animation-delay: 0.5s; }
.halo-spinner div:nth-child(6) { animation-delay: 0.6s; }
.halo-spinner div:nth-child(7) { animation-delay: 0.7s; }
.halo-spinner div:nth-child(8) { animation-delay: 0.8s; }
.halo-spinner div:nth-child(9) { animation-delay: 0.9s; }

@keyframes halo-square-spin {
    0%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* --- Mobile Styles (Responsividade) --- */
@media (max-width: 768px) {
    .lumi-terminal-container {
        left: 0;
        right: 0;
        width: 100% !important;
        max-width: 100% !important;
        bottom: 0;
        overflow: visible !important; /* ALLOWS MENU POP-UP */
        
        /* CORREÇÃO PARA O BUG DA BARRA: */
        /* Forçamos a altura fixa no mobile fechado (56px + espaço seguro) */
        height: calc(56px + env(safe-area-inset-bottom)); 
        
        min-height: 56px; 
        
        padding-bottom: env(safe-area-inset-bottom);
        
        /* Arredondamento mais sutil no mobile para ser elegante */
        border-radius: 12px 12px 0 0;
        border-top: 1px solid rgba(255, 215, 0, 0.2);
        
        /* Remove sombra lateral no mobile, mantém só superior */
        box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.3);
    }

    .lumi-terminal-container.open,
    .lumi-terminal-container.maximized {
        height: 100% !important;
        top: auto;
        bottom: 0;
        border-radius: 0;
        overflow-y: auto !important;
    }

    /* CORREÇÃO: Removemos o display: none que impedia o cálculo de altura,
       mas mantemos o controle visual através do container pai (overflow hidden) */
    
    .lumi-terminal-header {
        /* No mobile, removemos padding extra para manter a altura fina de 56px */
        padding-top: 0; 
        padding-bottom: 0;
        height: 56px; 
        overflow: visible !important; /* ALLOWS MENU POP-UP */
    }

    .lumi-terminal-prompt,
    .lumi-terminal-input {
        font-size: 0.9rem;
    }

    /* PREVENIR ÍCONES SAINDO DA TELA NO MOBILE */
    .lumi-terminal-header {
        padding: 0 10px; /* Reduz padding lateral */
    }

    .lumi-terminal-prompt {
        margin-right: 0.4rem; /* Reduz margem no mobile */
    }

    .lumi-terminal-prompt span {
        display: none; /* Esconde o texto 'LumiOS>' no mobile para ganhar espaço */
    }

    .lumi-terminal-input {
        min-width: 0; /* Permite que o input encolha o quanto for necessário */
    }

    .lumi-terminal-input-wrapper {
        overflow: visible !important; /* ALLOWS MENU POP-UP */
    }

    .lumi-terminal-button {
        margin: 0 2px; /* Reduz margem entre ícones */
        padding: 5px 3px;
        flex-shrink: 0;
    }

    /* --- MORE OPTIONS MENU (MOBILE) --- */
    .lumi-terminal-more-btn {
        display: flex !important; /* Mostra o botão de 'mais' apenas no mobile */
    }

    .lumi-terminal-more-menu {
        position: absolute;
        bottom: 100%;
        right: 0;
        background: rgba(15, 15, 20, 0.95); /* Matched to terminal background with higher opacity for clarity */
        backdrop-filter: blur(15px);
        border: 1px solid rgba(255, 215, 0, 0.3);
        border-radius: 12px; /* All corners rounded */
        display: none; /* Escondido por padrão */
        flex-direction: column;
        padding: 10px;
        z-index: 1001;
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
        margin-bottom: 5px;
        min-width: 150px;
    }

    .lumi-terminal-more-menu.active {
        display: flex;
        animation: menuFadeIn 0.3s ease-out;
    }

    .lumi-terminal-more-menu .lumi-terminal-button {
        display: flex !important;
        align-items: center;
        gap: 12px;
        padding: 12px 15px;
        width: 100%;
        color: rgba(255, 255, 255, 0.8);
        font-size: 0.9rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .lumi-terminal-more-menu .lumi-terminal-button:last-child {
        border-bottom: none;
    }

    .lumi-terminal-more-menu .lumi-terminal-button i {
        width: 20px;
        text-align: center;
    }

    /* Hide from main bar only if they are there, show them in the menu */
    #ui-sound-toggle, 
    #lumi-help-btn, 
    #lumi-clear-history-btn,
    #lumi-terminal-close-btn {
        display: none;
    }

    /* Force visibility inside the menu */
    .lumi-terminal-more-menu #ui-sound-toggle, 
    .lumi-terminal-more-menu #lumi-help-btn, 
    .lumi-terminal-more-menu #lumi-clear-history-btn,
    .lumi-terminal-more-menu #lumi-terminal-close-btn {
        display: flex !important;
    }

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

    .ai-video-icon {
        width: 45px; /* Ícone menor no mobile */
    }

    /* Garantir consistência do efeito de feixe no mobile */
    .terminal-light-beam {
        height: 3px !important;
        top: 0px !important;
        width: 1000% !important;
    }
}

/* --- Lumi Follow-up Buttons (New) --- */
.lumi-follow-ups {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    margin-bottom: 15px;
    animation: fadeIn 0.5s ease-out forwards;
}

.lumi-terminal-line .follow-up-btn {
    background: rgba(255, 215, 0, 0.05);
    border: 1px solid rgba(255, 215, 0, 0.3);
    color: #FFD700;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-family: 'Courier New', Courier, monospace;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.lumi-terminal-line .follow-up-btn:hover {
    background: rgba(255, 215, 0, 0.15);
    border-color: #FFD700;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.1);
}

.lumi-terminal-line .follow-up-btn:active {
    transform: scale(0.95);
}

/* --- Order Tracker Stepper (Visual) --- */
.lumi-order-tracker {
    margin: 20px 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 215, 0, 0.1);
}

.lumi-stepper {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin-bottom: 10px;
}

.lumi-stepper::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    z-index: 1;
}

.lumi-step {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 20%;
}

.lumi-step-icon {
    width: 30px;
    height: 30px;
    background: #1a1a1a;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
    transition: all 0.4s ease;
}

.lumi-step.completed .lumi-step-icon {
    background: #FFD700;
    border-color: #FFD700;
    color: #000;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

.lumi-step.active .lumi-step-icon {
    background: #1a1a1a;
    border-color: #FFD700;
    color: #FFD700;
    animation: step-pulse 2s infinite;
}

.lumi-step-label {
    font-size: 0.65rem;
    color: #888;
    text-align: center;
    white-space: nowrap;
}

.lumi-step.active .lumi-step-label,
.lumi-step.completed .lumi-step-label {
    color: #fff;
    font-weight: bold;
}

@keyframes step-pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(255, 215, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); }
}

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

/* --- Terminal Overlay (Confirm) --- */
.lumi-terminal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1200;
    border-radius: 12px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.lumi-terminal-overlay.hidden {
    display: none;
    opacity: 0;
}

.confirm-content {
    text-align: center;
    padding: 20px;
    color: #fff;
    font-family: 'Courier New', Courier, monospace;
}

.confirm-content p {
    margin-bottom: 20px;
    font-size: 0.95rem;
    color: #FFD700;
}

.confirm-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.confirm-btn {
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.confirm-btn.yes {
    background: rgba(255, 0, 0, 0.1);
    color: #ff4444;
    border-color: rgba(255, 0, 0, 0.3);
}

.confirm-btn.yes:hover {
    background: #ff4444;
    color: #fff;
}

.confirm-btn.no {
    background: rgba(255, 255, 255, 0.05);
    color: #ccc;
    border-color: rgba(255, 255, 255, 0.2);
}

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

/* --- Voice Input Styles --- */
#lumi-mic-btn.recording {
    color: #ff4444;
    animation: mic-pulse 1.5s infinite ease-in-out;
}

@keyframes mic-pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}