/* Import font dari Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #0084ff;
    --primary-dark: #0066cc;
    --bg-dark: #1e1e1e;
    --bg-darker: #121212;
    --container-bg: #2b2d31;
    --container-border: #424242;
    --header-bg: #202123;
    --input-bg: #40444b;
    --input-border: #52565d;
    --text-light: #e0e0e0;
    --text-lighter: #f0f0f0;
    --text-gray: #a0a0a0;
    --user-message: #0084ff;
    --bot-message: #3f4147;
    --settings-bg: #2d2f33;
    --settings-panel: #36393f;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, var(--bg-darker), var(--bg-dark));
    color: var(--text-light);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
}

#chat-container {
    width: 100%;
    max-width: 900px;
    height: 90vh;
    max-height: 900px;
    background-color: var(--container-bg);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--container-border);
    overflow: hidden;
    position: relative;
}

#chat-header {
    background-color: var(--header-bg);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--container-border);
}

.header-left h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-lighter);
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-left h1:before {
    content: "•";
    color: var(--primary);
    font-size: 1.8rem;
}

.model-info {
    font-size: 0.8rem;
    color: var(--text-gray);
    margin-top: 4px;
}

.header-right {
    display: flex;
    gap: 12px;
}

#chat-header button {
    background: var(--input-bg);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.2s ease;
}

#chat-header button:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}

#chat-log {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scroll-behavior: smooth;
}

/* Scrollbar styling */
#chat-log::-webkit-scrollbar {
    width: 8px;
}
#chat-log::-webkit-scrollbar-track {
    background: var(--container-bg);
}
#chat-log::-webkit-scrollbar-thumb {
    background-color: var(--input-bg);
    border-radius: 10px;
    border: 2px solid var(--container-bg);
}
#chat-log::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary);
}

.message {
    padding: 16px 20px;
    border-radius: 18px;
    max-width: 85%;
    line-height: 1.6;
    opacity: 0;
    transform: translateY(10px);
    animation: fadeIn 0.4s ease forwards;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    background-color: var(--user-message);
    align-self: flex-end;
    color: white;
    border-bottom-right-radius: 5px;
}

.bot-message {
    background-color: var(--bot-message);
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.message-header {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.9rem;
}

.user-message .message-header {
    color: rgba(255, 255, 255, 0.9);
}

.bot-message .message-header {
    color: var(--primary);
}

.message-header i {
    margin-right: 8px;
    font-size: 0.9rem;
}

/* Input area */
#input-form {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-top: 1px solid var(--container-border);
    background-color: var(--header-bg);
    gap: 12px;
}

#user-input {
    flex-grow: 1;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    padding: 14px 18px;
    border-radius: 24px;
    color: var(--text-light);
    font-size: 1rem;
    transition: all 0.3s ease;
    height: 52px;
    resize: none;
}

#user-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 132, 255, 0.2);
}

#file-upload {
    display: none;
}

#file-upload-button, #send-button {
    background: var(--input-bg);
    border: none;
    width: 46px;
    height: 46px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-light);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

#file-upload-button:hover, #send-button:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}

#send-button:disabled {
    background: var(--input-border);
    cursor: not-allowed;
    transform: none;
}

/* Thinking indicator */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 0;
}

.thinking-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-gray);
    animation: bounce 1.4s infinite ease-in-out both;
}

.thinking-indicator span:nth-child(1) { animation-delay: -0.32s; }
.thinking-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* Settings Panel */
#settings-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 100%;
    max-width: 380px;
    height: 100vh;
    background-color: var(--settings-panel);
    z-index: 1000;
    padding: 24px;
    transition: right 0.4s ease;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
}

#settings-panel.active {
    right: 0;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--container-border);
}

.settings-header h2 {
    font-size: 1.5rem;
    color: var(--text-lighter);
}

#close-settings {
    background: transparent;
    border: none;
    color: var(--text-light);
    font-size: 1.2rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

#close-settings:hover {
    background: var(--input-bg);
    color: var(--primary);
}

.setting-group {
    margin-bottom: 24px;
}

.setting-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
    color: var(--text-lighter);
}

.setting-group textarea {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 14px;
    color: var(--text-light);
    font-family: inherit;
    font-size: 0.95rem;
    min-height: 120px;
    resize: vertical;
    transition: all 0.3s ease;
}

.setting-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 132, 255, 0.2);
}

.setting-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.setting-item {
    flex: 1;
}

.setting-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-lighter);
    font-size: 0.95rem;
}

.setting-item input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    background: var(--input-bg);
    border-radius: 10px;
    outline: none;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.setting-item input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 4px rgba(0, 132, 255, 0.2);
}

.tooltip {
    font-size: 0.85rem;
    color: var(--text-gray);
    margin-top: 6px;
    line-height: 1.4;
}

.setting-group button {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 10px;
}

#reset-settings {
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--input-border);
}

#reset-settings:hover {
    background: var(--input-bg);
}

#save-settings {
    background: var(--primary);
    color: white;
}

#save-settings:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 132, 255, 0.3);
}

/* Markdown & Code Styling */
.bot-message table {
    border-collapse: collapse;
    width: 100%;
    margin: 15px 0;
    font-size: 0.9em;
    border: 1px solid #5f6368;
}

.bot-message th, .bot-message td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #5f6368;
}

.bot-message th {
    background-color: #4a4d52;
    color: var(--text-lighter);
    font-weight: 500;
}

.bot-message tr:nth-of-type(even) {
    background-color: #44464a;
}

.bot-message pre {
    background-color: #1e1e1e;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid #5f6368;
    color: #d4d4d4;
    font-family: 'Courier New', Courier, monospace;
    margin: 12px 0;
}

.bot-message code {
    font-family: 'Courier New', Courier, monospace;
    background-color: #1e1e1e;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.95em;
}

.bot-message blockquote {
    border-left: 4px solid var(--primary);
    margin: 12px 0;
    padding-left: 15px;
    color: #b0b0b0;
    font-style: italic;
}

/* Responsive design */
@media (max-width: 768px) {
    #chat-container {
        height: 95vh;
        max-height: none;
        border-radius: 12px;
    }
    
    #settings-panel {
        max-width: 100%;
        padding: 20px 16px;
    }
    
    .setting-row {
        flex-direction: column;
        gap: 24px;
    }
    
    .message {
        max-width: 90%;
        padding: 14px 18px;
    }
    
    #input-form {
        padding: 12px 16px;
    }
    
    #user-input {
        padding: 12px 16px;
        height: 48px;
    }
    
    #file-upload-button, #send-button {
        width: 42px;
        height: 42px;
    }
    
    .settings-header h2 {
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    #chat-header {
        padding: 14px 16px;
    }
    
    .header-left h1 {
        font-size: 1.2rem;
    }
    
    #chat-log {
        padding: 16px;
        gap: 20px;
    }
    
    .message {
        max-width: 95%;
    }
}

/* MathJax/KaTeX styling */
.katex {
    font-size: 1.1em !important;
}

.katex-display {
    margin: 1em 0 !important;
    overflow-x: auto;
    overflow-y: hidden;
}

/* Message content container */
.message-content {
    line-height: 1.7;
}

.message-content p {
    margin-bottom: 0.8rem;
}

/* Fix for message padding */
.message {
    padding: 16px 20px !important;
}

/* Better code block scrolling */
.bot-message pre {
    max-width: 100%;
    overflow-x: auto;
}