:root {
    --bg-color: #121212; /* Nuansa hitam sebagai warna dominan */
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --primary-blue: #bfdbfe; /* Biru muda */
    --dark-blue: #1e3a8a; /* Biru gelap untuk kontras */
    --user-bubble: #000000;
    --ai-bubble: #e0f2fe; /* Biru muda sangat terang */
    --ai-text: #121212;
    --border-color: #333333;
    --input-bg: #1e1e1e;
    --font-family: 'Nunito', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
}

.chat-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1440px;
    height: 100%;
    position: relative;
    background-color: var(--bg-color);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background-color: #1a1a1a;
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.header-info h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-blue);
}

.header-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.new-chat-btn {
    background-color: transparent;
    color: var(--primary-blue);
    border: 1px solid var(--primary-blue);
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 600;
    transition: all 0.3s;
}

.new-chat-btn:hover {
    background-color: var(--primary-blue);
    color: var(--bg-color);
}

.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    padding-bottom: 120px; /* Space for fixed input */
}

/* Shortcuts UI */
.shortcuts-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    margin: auto 0;
    padding: 20px;
}

.welcome-text {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--primary-blue);
}

.shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.shortcut-btn {
    background-color: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 0.95rem;
    transition: all 0.3s;
}

.shortcut-btn:hover {
    background-color: var(--dark-blue);
    border-color: var(--primary-blue);
}

/* Messages */
.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 20px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
}

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

.message.user {
    align-self: flex-end;
    background-color: var(--user-bubble);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-right-radius: 4px;
}

.message.ai {
    align-self: flex-start;
    background-color: var(--ai-bubble);
    color: var(--ai-text);
    border-bottom-left-radius: 4px;
}

/* Markdown styling inside AI bubble */
.message.ai p { margin-bottom: 8px; }
.message.ai p:last-child { margin-bottom: 0; }
.message.ai strong { font-weight: 700; }
.message.ai em { font-style: italic; }
.message.ai ul, .message.ai ol { margin-left: 20px; margin-bottom: 8px; }
.message.ai code {
    background-color: rgba(0,0,0,0.1);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}
.message.ai pre {
    background-color: #2d2d2d;
    color: #f8f8f2;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 8px;
}
.message.ai pre code {
    background-color: transparent;
    padding: 0;
    color: inherit;
}

/* Input Area */
.chat-input-area {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 20px;
    background: linear-gradient(180deg, transparent, var(--bg-color) 20%);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 8px 16px;
    gap: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    background-color: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(10px);
}

#message-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 1rem;
    resize: none;
    padding: 8px 0;
    max-height: 120px;
    outline: none;
}

#message-input::placeholder {
    color: var(--text-secondary);
}

#send-btn {
    background-color: var(--primary-blue);
    color: var(--bg-color);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 2px;
    flex-shrink: 0;
}

#send-btn:hover {
    background-color: var(--dark-blue);
    color: var(--primary-blue);
}

.api-key-warning {
    color: #f87171;
    font-size: 0.85rem;
    text-align: center;
    margin-top: 8px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background-color: var(--ai-bubble);
    border-radius: 20px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: fit-content;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: var(--ai-text);
    border-radius: 50%;
    opacity: 0.6;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

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

@media (min-width: 768px) {
    .chat-input-area {
        padding: 24px 40px;
    }
    .chat-box {
        padding: 24px 40px;
    }
}
