/* Reset and base configuration */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #212121;
    color: #ececf1;
    overflow-x: hidden;
    overflow-y: auto;
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #212121;
}

/* Main content area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
}

/* Landing page styles */
.landing-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px;
    max-width: 100%;
}

.welcome-section {
    text-align: center;
    margin-bottom: 40px;
}

.welcome-title {
    font-size: 36px;
    font-weight: 600;
    color: #ececf1;
    margin: 0;
    line-height: 1.2;
}

/* Input section */
.input-section {
    width: 100%;
    max-width: 768px;
    position: relative;
    padding: 0 20px;
}

/* Landing input section */
.landing-container .input-section {
    padding: 0 20px;
}

.input-container {
    position: relative;
    width: 100%;
}

.input-field {
    position: relative;
    display: flex;
    align-items: center;
    background-color: #2f2f2f;
    border: 1px solid #424242;
    border-radius: 26px;
    padding: 12px 16px;
    transition: all 0.2s ease;
    min-height: 52px;
}

.input-field:focus-within {
    border-color: #565856;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

.attach-btn {
    background: none;
    border: none;
    color: #8e8ea0;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
    transition: all 0.2s ease;
}

.attach-btn:hover {
    background-color: #404040;
    color: #ececf1;
}

.message-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: #ececf1;
    font-size: 16px;
    line-height: 1.5;
    padding: 0 8px;
    font-family: inherit;
    resize: none;
    min-height: 24px;
    max-height: 200px;
}

.message-input::placeholder {
    color: #8e8ea0;
}

.voice-btn,
.options-btn {
    background: none;
    border: none;
    color: #8e8ea0;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    transition: all 0.2s ease;
}

.voice-btn:hover,
.options-btn:hover {
    background-color: #404040;
    color: #ececf1;
}

/* Chat interface */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.chat-header {
    display: flex;
    justify-content: center;
    padding: 16px 20px;
    border-bottom: 1px solid #424242;
}

.new-chat-btn {
    background: #2f2f2f;
    border: 1px solid #424242;
    color: #ececf1;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.new-chat-btn:hover {
    background: #404040;
    border-color: #565856;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 120px;
    scroll-behavior: smooth;
    max-width: 768px;
    margin: 0 auto;
    width: 100%;
}

.message-wrapper {
    margin-bottom: 24px;
    width: 100%;
}

.message-wrapper.user {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}

.message-wrapper.assistant {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 16px;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 16px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-wrapper.user .message-content {
    background-color: #2f2f2f;
    color: #ececf1;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

.message-wrapper.assistant .message-content {
    background-color: transparent;
    color: #ececf1;
    border-bottom-left-radius: 4px;
    padding-left: 0;
    margin-right: auto;
}

.message-wrapper.assistant.thinking .message-content {
    background-color: transparent;
    padding: 4px 0;
}

/* Input section in chat */
.chat-container .input-section {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, transparent 0%, #212121 20%);
    padding: 20px;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: none;
    width: 100%;
}

.chat-container .input-section .input-container {
    max-width: 768px;
    width: 100%;
    margin: 0 auto;
}

/* Footer */
.footer {
    padding: 16px 20px;
    text-align: center;
    font-size: 14px;
    color: #8e8ea0;
    background-color: #212121;
    border-top: 1px solid #424242;
}

.footer p {
    max-width: 768px;
    margin: 0 auto;
}

.link {
    color: #8e8ea0;
    text-decoration: underline;
    text-decoration-color: rgba(142, 142, 160, 0.5);
    transition: all 0.2s ease;
}

.link:hover {
    color: #ececf1;
    text-decoration-color: #ececf1;
}

/* Loading indicator */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #2f2f2f;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.loading-dots {
    display: flex;
    gap: 8px;
    align-items: center;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: #8e8ea0;
    border-radius: 50%;
    animation: loadingBounce 1.4s ease-in-out infinite both;
}

.dot:nth-child(1) {
    animation-delay: -0.32s;
}

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

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

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

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

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

.messages-container::-webkit-scrollbar-thumb:hover {
    background: #6e6e6e;
}

/* Responsive design */
@media (max-width: 768px) {
    .welcome-title {
        font-size: 28px;
    }

    .input-section {
        padding: 0 16px;
    }

    .messages-container {
        padding: 16px;
        padding-bottom: 120px;
    }

    .message-content {
        max-width: 85%;
        font-size: 15px;
    }

    .chat-container .input-section {
        padding: 16px;
    }

    .footer {
        padding: 12px 16px;
        font-size: 12px;
        line-height: 1.4;
    }

    .footer p {
        word-wrap: break-word;
        hyphens: auto;
    }
}

@media (max-width: 480px) {
    .welcome-title {
        font-size: 24px;
        padding: 0 16px;
    }

    .input-field {
        min-height: 48px;
        padding: 10px 14px;
    }

    .message-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .message-content {
        max-width: 90%;
        font-size: 14px;
        padding: 10px 14px;
    }
}

/* Focus states for accessibility */
.attach-btn:focus,
.voice-btn:focus,
.options-btn:focus {
    outline: 2px solid #565856;
    outline-offset: 2px;
}

.message-input:focus {
    outline: none;
}

/* Dark mode optimizations */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #212121;
        color: #ececf1;
    }
}

/* Animation for message appearance */
@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-wrapper {
    animation: messageSlideIn 0.3s ease-out;
}

/* Additional improvements */
.input-field:hover {
    border-color: #565856;
}

.message-wrapper.assistant .message-content {
    position: relative;
}

/* Send button styling (when text is entered) */
.send-btn {
    background: #ececf1;
    border: none;
    color: #212121;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    transition: all 0.2s ease;
    min-width: 32px;
    height: 32px;
}

.send-btn:hover {
    background-color: #d1d5db;
}

.send-btn:active {
    transform: scale(0.95);
}

/* Thinking indicator */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 8px 12px;
}

.thinking-dot {
    width: 6px;
    height: 6px;
    background-color: #8e8ea0;
    border-radius: 50%;
    animation: thinkingPulse 1.4s ease-in-out infinite both;
}

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

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