/* Import font dari Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg-main: #1c1c1c;
    --bg-sidebar: #121212;
    --bg-input: #2a2a2a;
    --text-primary: #e5e5e5;
    --text-secondary: #a3a3a3;
    --border-color: #3a3a3a;
    --accent-color: #bb86fc;
    --danger-color: #cf6679;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow: hidden;
}

.app-layout {
    display: flex;
    height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s;
    border-right: 1px solid var(--border-color);
}

.sidebar-header .new-chat-btn {
    width: 100%;
    padding: 12px;
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.sidebar-header .new-chat-btn:hover {
    background-color: var(--bg-input);
}

.chat-history {
    flex-grow: 1;
    margin-top: 20px;
    overflow-y: auto;
    padding-right: 4px;
}

.chat-history::-webkit-scrollbar {
    width: 6px;
}
.chat-history::-webkit-scrollbar-track {
    background: transparent;
}
.chat-history::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.chat-history-item {
    position: relative;
    width: 100%;
    padding: 10px;
    padding-right: 35px;
    background: none;
    border: none;
    color: var(--text-primary);
    border-radius: 6px;
    text-align: left;
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-history-item > span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}

.chat-history-item:hover {
    background-color: var(--bg-input);
}

.chat-history-item.active {
    background-color: var(--bg-input);
}

.delete-chat-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 4px;
    flex-shrink: 0;
}
.chat-history-item:hover .delete-chat-btn {
    display: flex;
}
.delete-chat-btn:hover {
    background-color: #4a4a4a;
    color: var(--danger-color);
}

.sidebar-footer .user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid var(--border-color);
}

.user-profile .user-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Main Chat Area Styling */
.chat-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
}

.sidebar-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.model-selector-container {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}
#model-selector {
    padding: 6px 12px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}
#model-selector:focus {
    outline: none;
    border-color: var(--accent-color);
}

#chat-container {
    flex-grow: 1;
    position: relative;
    overflow-y: auto;
    padding-top: 60px;
}

.initial-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 20px;
    transition: opacity 0.3s, visibility 0.3s;
}
.chat-active .initial-view {
    opacity: 0;
    visibility: hidden;
    height: 0;
}
.initial-view h1 {
    font-size: 24px;
    color: var(--text-secondary);
    font-weight: 500;
}
.initial-view .initial-logo {
    width: 50px;
    height: 50px;
    background-color: var(--accent-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}
.initial-logo svg { color: white; }

#chat-box {
    max-width: 800px;
    margin: 0 auto;
    padding: 32px 20px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.message {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}
.message .icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}
.message .text-content {
    padding-top: 4px;
    line-height: 1.7;
    font-size: 16px;
    word-break: break-word;
}
.message p:not(:last-child) {
    margin-bottom: 1em;
}

.user-message .icon {
    background-color: #71717a;
}
.bot-message .icon {
    background-color: var(--accent-color);
}
.bot-message .text-content pre {
    background-color: #121212;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid var(--border-color);
}
.bot-message .text-content code {
    font-family: 'Courier New', Courier, monospace;
}

.input-wrapper {
    width: 100%;
    padding: 0 20px 30px;
    background: linear-gradient(180deg, rgba(28,28,28,0) 0%, var(--bg-main) 30%);
}
#input-container {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px;
    transition: border-color 0.2s;
}
#input-container:focus-within {
    border-color: var(--accent-color);
}
#user-input {
    flex-grow: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    padding: 10px;
}
#user-input:focus {
    outline: none;
}

/* --- BAGIAN BARU: GAYA TOMBOL INPUT --- */
.input-button-wrapper {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}
.input-button-wrapper > button {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.2s;
}
.input-button-wrapper > button.hidden {
    opacity: 0;
    transform: scale(0.5);
    pointer-events: none;
}
#send-btn {
    background-color: #3a3a3a;
    color: var(--text-secondary);
}
#send-btn:hover {
    background-color: var(--accent-color);
    color: white;
}
#stop-btn {
    background-color: var(--danger-color);
    color: white;
}
/* --- AKHIR BAGIAN BARU --- */

.footer-note {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 12px;
}

.menu-toggle {
    display: none;
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 20;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
}

.typing-cursor {
    display: inline-block;
    width: 8px;
    height: 1em;
    background-color: var(--text-primary);
    animation: blink 1s step-end infinite;
}
@keyframes blink {
    from, to { background-color: transparent }
    50% { background-color: var(--text-primary); }
}

.thinking-indicator .dot-flashing {
    position: relative;
    width: 10px;
    height: 10px;
    border-radius: 5px;
    background-color: var(--accent-color);
    color: var(--accent-color);
    animation: dotFlashing 1s infinite linear alternate;
    animation-delay: .5s;
    margin: 10px;
}
.thinking-indicator .dot-flashing::before, .thinking-indicator .dot-flashing::after {
    content: '';
    display: inline-block;
    position: absolute;
    top: 0;
}
.thinking-indicator .dot-flashing::before {
    left: -15px;
    width: 10px;
    height: 10px;
    border-radius: 5px;
    background-color: var(--accent-color);
    color: var(--accent-color);
    animation: dotFlashing 1s infinite alternate;
    animation-delay: 0s;
}
.thinking-indicator .dot-flashing::after {
    left: 15px;
    width: 10px;
    height: 10px;
    border-radius: 5px;
    background-color: var(--accent-color);
    color: var(--accent-color);
    animation: dotFlashing 1s infinite alternate;
    animation-delay: 1s;
}
@keyframes dotFlashing {
    0% { background-color: var(--accent-color); }
    50%, 100% { background-color: rgba(187, 134, 252, 0.2); }
}

.thinking-block details {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1em;
    background-color: var(--bg-input);
}
.thinking-block summary {
    padding: 10px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    list-style: none;
}
.thinking-block summary::-webkit-details-marker {
    display: none;
}
.thinking-block summary::before {
    content: '►';
    margin-right: 8px;
    display: inline-block;
    transition: transform 0.2s;
}
.thinking-block details[open] > summary::before {
    transform: rotate(90deg);
}
.thinking-block .thinking-content {
    padding: 0 10px 10px 10px;
    font-size: 13px;
    color: #b0b0b0;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
    border-top: 1px solid var(--border-color);
    margin-top: 5px;
    padding-top: 10px;
}

@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
    }
    .sidebar-visible .sidebar {
        transform: translateX(0);
        box-shadow: 4px 0px 15px rgba(0,0,0,0.2);
    }
    .sidebar-visible .sidebar-overlay {
        display: block;
    }
    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .chat-area {
        width: 100%;
    }
    .model-selector-container {
        left: auto;
        right: 15px;
        transform: none;
    }
    #chat-box, .input-wrapper {
        padding-left: 15px;
        padding-right: 15px;
    }
    .message {
        max-width: 95%;
    }
    .message .text-content {
        font-size: 15px;
    }
    .footer-note {
        font-size: 11px;
    }
}
