@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600&display=swap');

:root {
    --bg-dark: #0f172a;
    --sidebar-bg: #111827; 
    --accent: #6366f1;    
    --accent-hover: #4f46e5;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.08);
    --glass: rgba(30, 41, 59, 0.7);
    --sidebar-width: 280px;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Outfit', sans-serif; -webkit-tap-highlight-color: transparent; }

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100dvh; 
    display: flex;
    overflow: hidden;
    font-size: 16px;
}

/* --- OVERLAY --- */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    z-index: 900;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.overlay.active { opacity: 1; visibility: visible; }

/* --- SIDEBAR --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo-area {
    padding: 0.5rem 0.5rem 1.5rem;
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-area span { color: var(--accent); }

.new-chat-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    transition: 0.2s;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.new-chat-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }

.history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

.history-item {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-item:hover { background: rgba(255,255,255,0.05); color: var(--text-main); }
.history-item.active { background: rgba(99, 102, 241, 0.1); color: var(--accent); font-weight: 500; }

/* --- MAIN CHAT AREA --- */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: radial-gradient(circle at top right, #1e1b4b 0%, var(--bg-dark) 50%);
    width: 100%;
}

/* Header Chat - Tata Letak 3 Kolom */
header {
    height: auto;
    min-height: 65px;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    z-index: 10;
}

/* Header Kiri (Menu + Logo) */
.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

/* Header Tengah (Judul) */
.header-center {
    text-align: center;
    flex: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Header Kanan (Spacer) */
.header-right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
}

/* --- FIX: GAYA LOGO PROFIL YANG DIPERBAIKI --- */
.profile-img {
    width: 42px;
    height: 42px;
    min-width: 42px; /* Kunci ukuran minimum */
    max-width: 42px; /* Kunci ukuran maksimum */
    flex-shrink: 0;  /* Jangan biarkan gepeng */
    border-radius: 50%; 
    object-fit: cover;
    border: 2px solid var(--accent);
    background: #1e293b;
    transition: transform 0.2s;
}

.profile-img:hover {
    transform: scale(1.05);
}

/* Tombol Menu */
.menu-btn {
    display: none; 
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
}

header h2 { font-size: 1rem; font-weight: 600; margin-bottom: 2px; }

header .status { 
    font-size: 0.75rem; 
    color: #10b981; 
    display: flex; 
    align-items: center; 
    gap: 5px; 
}
header .status::before { content: ''; width: 6px; height: 6px; background: #10b981; border-radius: 50%; display: block; }

.view-stats {
    font-size: 0.7rem;
    color: #64748b;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Chat Box */
#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
}

.message {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.6;
    position: relative;
    word-wrap: break-word;
}

.message.user {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.ai {
    align-self: flex-start;
    background: rgba(51, 65, 85, 0.5);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

/* Input Area */
.input-area {
    padding: 1rem;
    background: var(--bg-dark);
    border-top: 1px solid var(--border);
}

.input-wrapper {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 6px;
    transition: 0.3s;
}

.input-wrapper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2); }

input[type="text"] {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px 16px;
    color: white;
    outline: none;
    font-size: 1rem;
}

button#send-btn {
    background: var(--accent);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    flex-shrink: 0;
}

button#send-btn:hover { background: var(--accent-hover); transform: rotate(-10deg); }

/* --- RESPONSIF --- */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        width: 80%;
        max-width: 300px;
        box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    }
    .sidebar.open { transform: translateX(0); }
    
    .menu-btn { display: block; } 
    
    /* FIX RESPONSIF: Update min/max width juga */
    .profile-img { 
        width: 38px; 
        height: 38px;
        min-width: 38px;
        max-width: 38px;
    }
    
    .header-left { flex: 0 auto; gap: 10px; }
    .header-right { flex: 0 auto; width: 30px; }
    
    .message { max-width: 85%; font-size: 0.9rem; padding: 12px 16px; }
    .input-area { padding: 10px; }
    .logo-area { justify-content: space-between; }
}

/* CODE BLOCK */
pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 3rem 1rem 1rem 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
}

p code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    color: #ff79c6;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
    font-family: sans-serif;
}

.copy-btn:hover { background: var(--accent); }
pre::-webkit-scrollbar { height: 8px; }
pre::-webkit-scrollbar-thumb { background: #4b5563; border-radius: 4px; }
