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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #121212;
    color: #ffffff;
    height: 100vh;
    overflow: hidden;
}

/* View Management */
.view {
    display: none;
    height: 100vh;
}

body[data-view="landing"] #view-landing {
    display: flex;
}

body[data-view="chat"] #view-chat {
    display: flex;
    flex-direction: column;
}

/* Landing View */
#view-landing {
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.container {
    max-width: 400px;
    width: 100%;
}

h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    text-align: center;
}

p {
    text-align: center;
    margin-bottom: 2rem;
    color: #b3b3b3;
}

.version {
    text-align: center;
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 1.5rem;
    font-style: italic;
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: #b3b3b3;
    font-size: 0.9rem;
}

input, textarea {
    width: 100%;
    padding: 0.75rem;
    background-color: #1e1e1e;
    border: 1px solid #333;
    border-radius: 4px;
    color: #fff;
    font-size: 1rem;
}

input:focus, textarea:focus {
    outline: none;
    border-color: #007acc;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.button-group {
    display: flex;
    gap: 0.75rem;
    margin-top: 2rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    flex: 1;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: #007acc;
    color: white;
}

.btn-primary:hover {
    background-color: #005a9e;
}

.btn-secondary {
    background-color: #333;
    color: white;
}

.btn-secondary:hover {
    background-color: #444;
}

/* Chat View */
#view-chat {
    height: 100vh;
}

.chat-header {
    padding: 1rem;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: flex-end;
}

.messages-panel {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    scroll-behavior: smooth;
}

.message {
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

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

.message-content {
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    word-wrap: break-word;
    white-space: pre-wrap;
    line-height: 1.4;
}

.message.user .message-content {
    background-color: #1f2a44;
    color: #fff;
}

.message.assistant .message-content {
    background-color: #1b1b1b;
    color: #fff;
    border: 1px solid #333;
}

.message-role {
    font-size: 0.8rem;
    color: #b3b3b3;
    margin-bottom: 0.25rem;
}

/* Typing Indicator */
.typing-indicator {
    padding: 1rem;
    display: flex;
    justify-content: center;
    gap: 0.25rem;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: #666;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.dot:nth-child(2) {
    animation-delay: 0.2s;
}

.dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Error Banner */
.error-banner {
    background-color: #dc3545;
    color: white;
    padding: 0.75rem 1rem;
    margin: 0 1rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

/* Composer */
.composer {
    position: relative;
    padding: 1rem;
    border-top: 1px solid #333;
    background-color: #121212;
}

#composer {
    width: 100%;
    min-height: 60px;
    max-height: 150px;
    resize: none;
    border-radius: 8px;
    padding-right: 45px; /* Space for send button */
    padding-bottom: 0.75rem;
    padding-top: 0.75rem;
}

#sendButton {
    position: absolute;
    bottom: 1.75rem;
    right: 1.5rem;
    padding: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #333;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.6;
}

#sendButton::before {
    content: '';
    width: 0;
    height: 0;
    border-left: 6px solid #999;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    margin-left: 1px;
}

#sendButton:enabled {
    background-color: #007acc;
    opacity: 1;
}

#sendButton:enabled::before {
    border-left-color: white;
}

#sendButton:enabled:hover {
    background-color: #005a9e;
    transform: scale(1.05);
}

#sendButton:disabled {
    background-color: #333;
    cursor: not-allowed;
    opacity: 0.4;
}

#sendButton:disabled::before {
    border-left-color: #666;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .composer {
        padding: 0.75rem;
    }
    
    #sendButton {
        width: 32px;
        height: 32px;
        bottom: 1.5rem;
        right: 1rem;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    /* Mobile keyboard fixes */
    body {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile */
    }
    
    #view-chat {
        height: 100vh;
        height: 100dvh;
    }
    
    /* Ensure composer stays visible when keyboard is open */
    .composer {
        position: sticky;
        bottom: 0;
        background-color: #121212;
        z-index: 100;
    }
    
    /* Adjust messages panel to account for keyboard */
    .messages-panel {
        padding-bottom: 0.5rem;
    }
}