* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

html, body {
    height: 100%;
    width: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: #0f0f0f;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* App Layout */
.app {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 100%);
}

/* Header */
.header {
    border-bottom: 1px solid #2a2a2a;
    background: rgba(15, 15, 15, 0.9);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 12px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Main Section */
.main {
    flex: 1;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    min-height: auto;
    padding-bottom: 60px;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Prevent vertical stretching */
    min-height: auto;
}
/* Messages */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
}

.welcome-message {
    text-align: center;
    color: #888;
    margin-top: 2rem;
    padding: 0 16px;
}

.welcome-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-subtitle {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
}

/* Messages Styling */
.message {
    display: flex;
    max-width: 85%;
    animation: fadeIn 0.5s ease-in-out;
}

.message.user {
    align-self: flex-end;
    justify-content: flex-end;
}

.message.assistant {
    align-self: flex-start;
    justify-content: flex-start;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    white-space: pre-wrap;
    line-height: 1.5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.message.assistant .message-bubble {
    background: #1e1e1e;
    color: #e0e0e0;
    border: 1px solid #333;
    border-bottom-left-radius: 6px;
}

.message-text {
    font-size: 0.95rem;
}

.message-time {
    font-size: 0.75rem;
    margin-top: 8px;
    opacity: 0.6;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-self: flex-start;
    max-width: 85%;
}

.typing-bubble {
    background: #1e1e1e;
    padding: 12px 16px;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid #333;
}

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

.typing-dot {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0s; }

.typing-bubble span {
    color: #888;
    font-size: 0.9rem;
}

/* Input Area */
.input-container {
    border-top: 1px solid #2a2a2a;
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(15px);
    padding: 16px;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 10;
    padding-bottom: calc(env(safe-area-inset-bottom) + 16px);
}

.input-wrapper {
    max-width: 100%;
    margin: 0 auto 8px auto;
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#messageInput {
    flex: 1;
    padding: 12px 16px;
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 20px;
    resize: none;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    min-height: 48px;
    max-height: 120px;
    color: #fff;
    transition: all 0.3s ease;
    line-height: 1.4;
}

#messageInput::placeholder {
    color: #888;
    font-size: 0.95rem;
}

#messageInput:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

#sendButton {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    flex-shrink: 0;
    min-width: 48px;
}

#sendButton:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

#sendButton:disabled {
    background: #333;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Disclaimer */
.disclaimer {
    text-align: center;
    font-size: 0.7rem;
    color: #666;
    margin-top: 8px;
    line-height: 1.3;
    padding: 0 8px;
}

/* Scrollbar Styling */
.messages::-webkit-scrollbar {
    width: 6px;
}

.messages::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 3px;
}

.messages::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

.messages::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Fix for Mobile Viewport Height (Android/iOS) */
@supports (-webkit-touch-callout: none) {
    .app, .main, .chat-container {
        height: -webkit-fill-available;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .message {
        max-width: 90%;
    }
    
    .messages {
        padding: 16px 12px 12px 12px;
        gap: 12px;
    }
    
    .input-container {
        padding: 12px;
        padding-bottom: calc(env(safe-area-inset-bottom) + 12px);
    }
    
    .message-bubble {
        padding: 10px 14px;
    }
    
    .header {
        padding: 10px 0;
    }
    
    .header h1 {
        font-size: 1.3rem;
    }
    
    .welcome-message {
        margin-top: 1.5rem;
        padding: 0 12px;
    }
    
    .welcome-title {
        font-size: 1.1rem;
    }
    
    .welcome-subtitle {
        font-size: 0.85rem;
    }
    
    #messageInput {
        padding: 10px 14px;
        min-height: 44px;
        font-size: 0.9rem;
    }
    
    #sendButton {
        padding: 10px 14px;
        min-width: 44px;
    }
    
    .disclaimer {
        font-size: 0.65rem;
        padding: 0 4px;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .messages {
        padding: 12px 8px 8px 8px;
    }
    
    .input-container {
        padding: 8px;
        padding-bottom: calc(env(safe-area-inset-bottom) + 8px);
    }
    
    .input-wrapper {
        gap: 8px;
    }
    
    #messageInput {
        padding: 8px 12px;
        min-height: 40px;
        font-size: 0.85rem;
    }
    
    #messageInput::placeholder {
        font-size: 0.85rem;
    }
    
    #sendButton {
        padding: 8px 12px;
        min-width: 40px;
    }
    
    .disclaimer {
        font-size: 0.6rem;
    }
}

/* Selection Styling */
::selection {
    background: rgba(102, 126, 234, 0.3);
}

/* Focus Outline */
*:focus {
    outline: none;
}
