/* public/style.css (FINAL UI & STYLING) */
:root {
    --color-primary-text: #4d4198;
    --color-background: #ffffff; 
    --color-surface: #ffffff; 
    --color-border-subtle: #d3d3d3; 
    --color-user-bubble: #e6e9f2; 
    --color-ai-bubble: #f1f1f1; 
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Poppins', sans-serif; 
    background-color: var(--color-background);
    display: flex;
    align-items: flex-start; 
    min-height: 100vh;
    width: 100%;
}

#chat-container {
    width: 100%; max-width: 100%; height: 100vh; 
    background-color: var(--color-surface); border-radius: 0;
    display: flex; flex-direction: column; margin: 0; overflow: hidden;
}

/* --- HEADER --- */
#main-header { 
    display: flex; 
    justify-content: flex-start; 
    align-items: center; 
    padding: 20px 40px; 
}
.logo-area { display: flex; align-items: center; gap: 15px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background-color: #f0f0f0; overflow: hidden; display: flex; justify-content: center; align-items: center; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.app-name { font-size: 1.8rem; font-weight: 600; color: var(--color-primary-text); }
.header-divider { border: 0; height: 1px; background-color: var(--color-border-subtle); margin-bottom: 20px; }

/* --- RIWAYAT CHAT & MESSAGES --- */
#chat-history {
    flex-grow: 1; padding: 20px 40px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 12px;
    background-color: var(--color-background);
}
#chat-history::-webkit-scrollbar { width: 6px; }
#chat-history::-webkit-scrollbar-thumb { background-color: #ced4da; border-radius: 10px; }

.message {
    max-width: 75%; /* Lebar pesan standar (desktop) */
    padding: 10px 15px; border-radius: 12px; line-height: 1.6;
    word-wrap: break-word; font-weight: 400; animation: fadeIn 0.3s ease-out; 
    position: relative;
}

.user-message { align-self: flex-end; background-color: var(--color-user-bubble); color: var(--color-primary-text); border-bottom-right-radius: 3px; }
.ai-message { align-self: flex-start; background-color: var(--color-ai-bubble); color: #212529; border-bottom-left-radius: 3px; padding-top: 15px; }
.system-message { align-self: center; max-width: 60%; background-color: #fff3cd; color: #856404; text-align: center; font-style: italic; font-size: 0.85em; padding: 8px 15px; border-radius: 15px; }

/* --- GAYA MARKDOWN & COPY --- */
.ai-message p { margin-bottom: 8px; }
.ai-message strong { font-weight: 600; }
.ai-message ul, .ai-message ol { margin-left: 20px; margin-bottom: 8px; padding-left: 10px; }
.ai-message li { margin-bottom: 4px; }
.ai-message pre {
    position: relative; 
    padding-top: 35px; 
    background-color: #333; color: #f8f8f2; padding: 10px; border-radius: 6px;
    overflow-x: auto; font-size: 0.9rem; line-height: 1.4; font-family: 'Courier New', monospace;
    margin-top: 10px; margin-bottom: 10px;
}
.ai-message code { background-color: #e0e0e0; color: #c7254e; padding: 2px 4px; border-radius: 3px; font-family: 'Courier New', monospace; }
.ai-message pre code { background-color: transparent; color: inherit; padding: 0; border-radius: 0; }

/* Tombol Copy PESAN UTUH */
.copy-btn {
    position: absolute; top: 5px; right: 5px; background-color: #d3d3d3; 
    color: #444; border: none; padding: 3px 8px; border-radius: 5px; 
    font-size: 0.75rem; cursor: pointer; opacity: 0; 
    transition: opacity 0.3s, background-color 0.3s; font-family: inherit; font-weight: 600;
}
.copy-btn i { margin-right: 4px; }
.copy-btn:hover { background-color: #bdbdbd; }
.ai-message:hover .copy-btn { opacity: 1; }

/* Tombol Copy CODE BLOCK */
.code-copy-btn {
    position: absolute;
    top: 0; right: 0;
    background-color: #555; 
    color: white;
    border: none;
    padding: 5px 10px;
    border-top-right-radius: 6px;
    border-bottom-left-radius: 6px; 
    font-size: 0.8rem;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    opacity: 0.8;
    transition: background-color 0.2s, opacity 0.2s;
    z-index: 10; 
}

.code-copy-btn:hover {
    background-color: #333;
    opacity: 1;
}


/* --- GAYA TYPING INDICATOR --- */
.typing-indicator {
    display: inline-flex; 
    align-items: center;
    font-size: 1.2rem;
    color: #555; 
    padding: 5px 10px;
}

.typing-indicator span {
    opacity: 0;
    animation: typing-bounce 1.4s infinite; 
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}


/* --- INPUT AREA --- */
#input-area { padding: 25px 40px 40px 40px; background-color: var(--color-surface); }
.input-wrapper {
    display: flex; align-items: center; position: relative;
    border: 1px solid var(--color-border-subtle); border-radius: 50px; 
    padding: 10px 15px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05); 
}
#user-input {
    flex-grow: 1; padding: 8px 10px; border: none; resize: none; 
    min-height: 25px; max-height: 150px; font-family: inherit; font-size: 1rem; outline: none; background: none;
}
.send-icon-btn {
    width: 40px; height: 40px; border-radius: 50%; background-color: var(--color-primary-text);
    color: white; border: none; cursor: pointer; font-size: 1.1rem; 
    display: flex; justify-content: center; align-items: center; transition: background-color 0.2s, opacity 0.2s;
}
.send-icon-btn:hover:not(:disabled) { background-color: #3b337c; }
.send-icon-btn:disabled { background-color: #ccc; cursor: not-allowed; opacity: 0.7; }

/* --- Responsiveness (FULL WIDTH MENTOK UJUNG) --- */
@media (min-width: 1024px) {
    /* Full width desktop */
    #main-header, .header-divider, #chat-history, #input-area { 
        margin-left: 0;
        margin-right: 0;
    }
    
    #main-header, #chat-history, #input-area { 
        padding-left: 40px; 
        padding-right: 40px; 
    }
    
    #input-area .input-wrapper { 
        max-width: 800px; 
        margin-left: auto; 
        margin-right: auto; 
    }
}
@media (max-width: 768px) {
    #chat-container { height: 100vh; max-width: 100%; border-radius: 0; box-shadow: none; }
    #main-header, #chat-history, #input-area { padding-left: 15px; padding-right: 15px; }
    #main-header { padding-top: 15px; padding-bottom: 15px; }
    #input-area { padding-bottom: 15px; }

    /* Modifikasi penting untuk lebar pesan di mobile */
    .message {
        max-width: 90%; 
    }
}