.chat-hidden {
    display: none;
}

.chat-visible {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.chat-header {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    padding: var(--spacing-md);
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
}

/* Mobile-responsive chat container */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh; /* Full viewport height */
    padding: 0;
    margin: 0;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    padding-bottom: 80px; /* Space for input bar */
}

/* Fixed input container at bottom */
.input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--midnight-blue);
    padding: 15px;
    border-top: 1px solid rgba(139, 92, 246, 0.3);
    backdrop-filter: blur(10px);
}

.input-wrapper {
    max-width: 100%;
    margin: 0 auto;
}

/* Mobile-optimized message bubbles */
.message-bubble {
    max-width: 85% !important; /* Better for mobile */
    margin: 8px 0;
    word-wrap: break-word;
}

.user-message {
    margin-left: auto; /* Push user messages to right */
    margin-right: 10px;
}

.lie-message {
    margin-right: auto; /* Keep Lie messages on left */
    margin-left: 10px;
}

/* Mobile touch optimization */
.send-button, .voice-btn {
    min-height: 44px; /* Apple recommended touch target */
    min-width: 44px;
    padding: 12px;
}

#message-input {
    min-height: 44px;
    padding: 12px 20px;
    font-size: 16px; /* Prevents zoom on iOS */
}

/* Mobile-specific styles */
@media (max-width: 768px) {
    .chat-container {
        padding: 5px;
    }
    
    .message-bubble {
        max-width: 90% !important;
        padding: 12px;
        margin: 6px 0;
    }
    
    .input-container {
        padding: 10px;
    }
    
    .input-wrapper {
        gap: 8px;
    }
    
    /* Hide unnecessary elements on mobile */
    .voice-options {
        display: none; /* Show on tap instead */
    }
    
    /* Mobile-optimized header */
    .chat-header {
        padding: 10px 15px;
    }
    
    .header-content h2 {
        font-size: 1.4rem;
    }
}

/* Very small mobile devices */
@media (max-width: 480px) {
    .message-bubble {
        max-width: 95% !important;
        padding: 10px;
    }
    
    .input-container {
        padding: 8px;
    }
    
    #message-input {
        font-size: 14px;
        padding: 10px 15px;
    }
}

/* ===== MOBILE RESPONSIVENESS FIXES ===== */

/* Main chat container mobile fix */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 0;
    margin: 0;
}

/* Messages area with bottom padding for input */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    padding-bottom: 80px; /* Space for fixed input */
}

/* Fixed input bar at bottom */
.input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--midnight-blue);
    padding: 15px;
    border-top: 1px solid rgba(139, 92, 246, 0.3);
    backdrop-filter: blur(10px);
    z-index: 1000;
}

.input-wrapper {
    max-width: 100%;
    margin: 0 auto;
}

/* Mobile-optimized message bubbles */
.message-bubble {
    max-width: 85%;
    margin: 8px 0;
    word-wrap: break-word;
}

.user-message {
    margin-left: auto;
    margin-right: 10px;
}

.lie-message {
    margin-right: auto;
    margin-left: 10px;
}

/* Mobile touch targets */
.send-button, .voice-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 12px;
}

#message-input {
    min-height: 44px;
    padding: 12px 20px;
    font-size: 16px;
}

/* Mobile media queries */
@media (max-width: 768px) {
    .chat-container {
        padding: 5px;
    }
    
    .message-bubble {
        max-width: 90%;
        padding: 12px;
    }
    
    .input-container {
        padding: 10px;
    }
    
    .chat-header {
        padding: 10px 15px;
    }
    
    .header-content h2 {
        font-size: 1.4rem;
    }
}

@media (max-width: 480px) {
    .message-bubble {
        max-width: 95%;
        padding: 10px;
    }
    
    #message-input {
        font-size: 14px;
        padding: 10px 15px;
    }
    
    .input-container {
        padding: 8px;
    }
}


/* Handle mobile keyboard properly */
@media (max-height: 700px) {
    .messages-container {
        padding-bottom: 60px; /* Less space when keyboard is open */
    }
    
    .input-container {
        padding: 8px;
    }
}


/* Typing Indicator Styles */
.typing-indicator {
    opacity: 0.9;
    max-width: 120px !important;
}

.typing-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--electric-violet);
    animation: typingPulse 1.4s ease-in-out infinite both;
}

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

@keyframes typingPulse {
    0%, 80%, 100% { 
        transform: scale(0.8); 
        opacity: 0.5; 
    }
    40% { 
        transform: scale(1.2); 
        opacity: 1; 
    }
}

.typing-text {
    font-size: 0.8rem;
    opacity: 0.7;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.header-content h2 {
    font-size: 1.8rem;
    background: linear-gradient(135deg, var(--electric-violet) 0%, var(--neon-cyan) 100%);
    background-clip: text;
    color: transparent;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--neon-cyan);
    animation: pulse 2s infinite;
}

.status-thinking .status-dot {
    background: var(--electric-violet);
    animation: thinkingPulse 1.5s infinite;
}

@keyframes thinkingPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: var(--spacing-md);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.message-bubble {
    max-width: 70%;
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    animation: messageSlide 0.3s ease-out;
}

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

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--electric-violet) 0%, #7c3aed 100%);
    border-bottom-right-radius: 4px;
}

.lie-message {
    align-self: flex-start;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-bottom-left-radius: 4px;
}

.input-container {
    padding: var(--spacing-md);
}

.input-wrapper {
    display: flex;
    gap: var(--spacing-sm);
    max-width: 800px;
    margin: 0 auto;
}

#message-input {
    flex: 1;
    padding: 1rem 1.5rem;
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 50px;
    background: rgba(15, 23, 42, 0.6);
    color: white;
    font-size: 1rem;
    outline: none;
}

#message-input:focus {
    border-color: var(--electric-violet);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.2);
}

/* Code Block Styles */
/* Ensure code blocks have proper contrast */
.code-block {
    background: #0f172a !important;
    border: 1px solid #8b5cf6 !important;
    border-radius: 8px !important;
    margin: 10px 0 !important;
    overflow: hidden !important;
}

.code-block pre {
    background: #0f172a !important;
    color: #f1f5f9 !important;
    padding: 15px !important;
    margin: 0 !important;
    overflow-x: auto !important;
}

.code-block code {
    background: transparent !important;
    color: #f1f5f9 !important;
    font-family: 'Courier New', Monaco, monospace !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(139, 92, 246, 0.1);
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
}

.code-language {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--neon-cyan);
    text-transform: uppercase;
}

.copy-btn {
    background: rgba(139, 92, 246, 0.3);
    border: 1px solid var(--electric-violet);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.3s;
}

.copy-btn:hover {
    background: var(--electric-violet);
    transform: scale(1.05);
}


.inline-code {
    background: rgba(139, 92, 246, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--neon-cyan);
}


.streaming-message {
    border-left: 3px solid var(--electric-violet);
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
    0%, 100% { border-left-color: var(--electric-violet); }
    50% { border-left-color: var(--neon-cyan); }
}

.send-button {
    padding: 1rem;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--electric-violet) 0%, var(--neon-cyan) 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(139, 92, 246, 0.4);
}


.search-status {
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 10px;
}

.search-online {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border: 1px solid #22c55e;
}

.search-offline {
    background: rgba(249, 115, 22, 0.2);
    color: #f97316;
    border: 1px solid #f97316;
}


.voice-interface {
    margin-bottom: 1rem;
}

.voice-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 50px;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.voice-btn.active {
    background: var(--electric-violet) !important;
    color: white !important;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.5);
}


.voice-btn:hover, .voice-btn.active {
    background: var(--electric-violet);
    color: white;
    transform: scale(1.1);
}

.voice-options {
    border-left: 2px solid var(--electric-violet);
    padding-left: 10px;
    margin-left: 5px;
}

.voice-option-btn {
    background: transparent;
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: var(--electric-violet);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 50%;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-option-btn:hover, .voice-option-btn.active {
    background: var(--electric-violet);
    color: white;
    border-color: var(--electric-violet);
}

.voice-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    opacity: 0.8;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--neon-cyan);
}

.status-dot.status-listening {
    background: #f59e0b;
    animation: pulse 1s infinite;
}

.status-dot.status-speaking {
    background: #10b981;
    animation: pulse 0.5s infinite;
}

.status-dot.status-error {
    background: #ef4444;
}

.status-listening { color: #f59e0b; }
.status-speaking { color: #10b981; }
.status-error { color: #ef4444; }
.status-active { color: var(--electric-violet); }

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


.voice-status.status-speaking::after {
    content: '♪';
    margin-left: 5px;
    animation: wave 1s infinite;
}

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

/* Search results in messages */
.search-result {
    background: rgba(139, 92, 246, 0.1);
    border-left: 3px solid var(--electric-violet);
    padding: 8px 12px;
    margin: 8px 0;
    border-radius: 4px;
    font-size: 0.9em;
}

.app-promo {
    background: linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%);
    color: white;
    padding: 15px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    animation: promoSlideDown 0.5s ease-out;
}

@keyframes promoSlideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.promo-content h3 {
    margin: 0 0 10px 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.promo-content p {
    margin: 0 0 15px 0;
    opacity: 0.9;
    font-size: 0.9rem;
}

.app-badges {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
    flex-wrap: wrap;
}

.play-store-btn, .app-store-btn {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.8rem;
    font-weight: 500;
}

.play-store-btn:hover, .app-store-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

@media (max-width: 768px) {
    .app-promo {
        padding: 12px;
    }
    
    .promo-content h3 {
        font-size: 1.1rem;
    }
    
    .app-badges {
        flex-direction: column;
        align-items: center;
    }
    
    .play-store-btn, .app-store-btn {
        width: 200px;
        padding: 10px;
    }
}

.promo-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.promo-close:hover {
    opacity: 1;
}
