/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background-color: #1a1a2e;
    color: #ffffff;
    height: 100vh;
    overflow: hidden;
}

/* Container Layout */
.container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: #16213e;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #0f3460;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid #0f3460;
}

.new-chat-btn {
    width: 100%;
    padding: 12px 16px;
    background-color: transparent;
    border: 1px solid #0f3460;
    color: #ffffff;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    font-size: 14px;
}

.new-chat-btn:hover {
    background-color: #0f3460;
}

.conversations-list {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
}

.conversation-item {
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s ease;
    word-break: break-word;
}

.conversation-item:hover {
    background-color: #0f3460;
}

.conversation-item.active {
    background-color: #e94560;
}

.conversation-title {
    flex: 1;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.delete-btn {
    opacity: 0;
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.conversation-item:hover .delete-btn {
    opacity: 1;
}

.delete-btn:hover {
    background-color: #e94560;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid #0f3460;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.export-btn, .import-btn {
    width: 100%;
    padding: 8px 12px;
    background-color: transparent;
    border: 1px solid #0f3460;
    color: #ffffff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.export-btn:hover, .import-btn:hover {
    background-color: #0f3460;
}

/* Main Chat Area */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #1a1a2e;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid #0f3460;
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    display: none;
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
}

.sidebar-toggle:hover {
    background-color: #0f3460;
}

#chatTitle {
    font-size: 18px;
    font-weight: 600;
}

/* Messages */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

.welcome-message {
    text-align: center;
    margin-top: 40vh;
    transform: translateY(-50%);
}

.welcome-message h2 {
    font-size: 32px;
    margin-bottom: 8px;
    color: #e94560;
}

.welcome-message p {
    font-size: 16px;
    color: #cccccc;
}

.message {
    margin-bottom: 24px;
    animation: messageAppear 0.3s ease;
}

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

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.message-role {
    font-weight: 600;
    font-size: 14px;
}

.message-role.user {
    color: #e94560;
}

.message-role.assistant {
    color: #4CAF50;
}

.message-timestamp {
    font-size: 12px;
    color: #888888;
}

.message-content {
    line-height: 1.6;
    color: #ffffff;
}

.message-content h1, .message-content h2, .message-content h3 {
    margin: 16px 0 8px 0;
    color: #ffffff;
}

.message-content h1 { font-size: 24px; }
.message-content h2 { font-size: 20px; }
.message-content h3 { font-size: 18px; }

.message-content p {
    margin: 8px 0;
}

.message-content ul, .message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message-content li {
    margin: 4px 0;
}

.message-content blockquote {
    border-left: 4px solid #e94560;
    margin: 16px 0;
    padding-left: 16px;
    color: #cccccc;
}

.message-content code {
    background-color: #0f3460;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
}

.message-content pre {
    background-color: #0f3460;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    overflow-x: auto;
    position: relative;
}

.message-content pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}

.code-header {
    display: flex;
    justify-content: between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #16213e;
}

.code-language {
    font-size: 12px;
    color: #cccccc;
}

.copy-btn {
    background: transparent;
    border: 1px solid #16213e;
    color: #cccccc;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background-color: #16213e;
    border-color: #e94560;
    color: #e94560;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px;
    color: #cccccc;
    font-size: 14px;
}

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

.typing-dots span {
    width: 8px;
    height: 8px;
    background-color: #e94560;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

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

/* Input Area */
.input-container {
    padding: 24px;
    border-top: 1px solid #0f3460;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: end;
    gap: 12px;
    background-color: #16213e;
    border-radius: 12px;
    padding: 12px 16px;
    border: 1px solid #0f3460;
    transition: border-color 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: #e94560;
}

#messageInput {
    flex: 1;
    background: transparent;
    border: none;
    color: #ffffff;
    resize: none;
    outline: none;
    font-size: 16px;
    line-height: 1.5;
    max-height: 120px;
    overflow-y: auto;
}

#messageInput::placeholder {
    color: #888888;
}

#sendButton {
    background-color: #e94560;
    border: none;
    color: #ffffff;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

#sendButton:hover:not(:disabled) {
    background-color: #d63651;
    transform: scale(1.05);
}

#sendButton:disabled {
    background-color: #666666;
    cursor: not-allowed;
    transform: none;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex;
    }

    .messages-container {
        padding: 16px;
    }

    .input-container {
        padding: 16px;
    }

    .welcome-message {
        margin-top: 30vh;
    }

    .welcome-message h2 {
        font-size: 24px;
    }
}

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

::-webkit-scrollbar-track {
    background: #16213e;
}

::-webkit-scrollbar-thumb {
    background: #0f3460;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #e94560;
}
/* Settings Modal */
.modal-overlay { position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.7); z-index:1000; display:flex; align-items:center; justify-content:center; }
.modal-content { background:#1a1a2e; border:1px solid #2a2a4a; border-radius:12px; padding:24px; width:90%; max-width:420px; }
.modal-content h3 { margin:0 0 16px; color:#e0e0e0; }
.modal-content label { display:block; margin:8px 0 4px; color:#aaa; font-size:13px; }
.modal-content input[type="text"], .modal-content input[type="password"] { width:100%; padding:8px 12px; background:#0f0f23; border:1px solid #333; border-radius:6px; color:#e0e0e0; font-size:14px; box-sizing:border-box; }
.modal-actions { display:flex; gap:8px; margin-top:16px; }
.modal-actions button { flex:1; padding:8px; border:none; border-radius:6px; cursor:pointer; font-size:14px; }
.modal-actions button:first-child { background:#e94560; color:#fff; }
.modal-actions button:last-child { background:#333; color:#ccc; }
.settings-btn { width:100%; padding:8px; background:transparent; border:1px solid #2a2a4a; color:#aaa; border-radius:8px; cursor:pointer; margin-bottom:4px; }
.settings-btn:hover { background:#1a1a3a; color:#e0e0e0; }
