/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #ffffff;
    color: #343541;
    line-height: 1.5;
    height: 100vh;
    overflow-x: hidden; /* Only hide horizontal overflow */
    overflow-y: auto; /* Allow vertical scrolling */
}

.app-container {
    display: flex;
    height: 100vh;
    background-color: #ffffff;
}

textarea {
    font-family: Arial, sans-serif; /* Change font */
    font-size: 14px; /* Adjust text size */
    color: #333; /* Text color */
    background-color: white; /* Background color */
    padding: 10px; /* Spacing inside */
    border-radius: 5px; /* Rounded corners */
    border: 1px solid #ccc; /* Border style */
}

/* Sidebar styles */
.sidebar {
    width: 280px;
    background-color: #f9f9f9;
    border-right: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
    height: 100%;
    /* Fix for transparent sidebar */
    opacity: 1 !important;
    backdrop-filter: none !important;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid #e5e5e5;
    background-color: #f9f9f9;
    position: relative; /* Ensure it layers properly */
    z-index: 1; /* Prevent other elements from appearing on top */
}

.new-chat-btn {
    width: 100%;
    padding: 10px 15px;
    background-color: #10a37f;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
    transition: background-color 0.3s;
}

.new-chat-btn:hover {
    background-color: #0d8c6c;
}

.model-selector {
    padding: 15px;
    border-bottom: 1px solid #e5e5e5;
    background-color: #f9f9f9;
    position: relative;
    z-index: 1;
}

.model-selector label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: #666;
}

.model-selector select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    background-color: white;
    font-size: 14px;
}

.model-selectorx {
     max-width: 400px;
    padding: 15px;
    border-bottom: 0px solid #e5e5e5;
    border-radius: 10px;
    background-color: #f9f9f9;
    position: relative;
    z-index: 1;
    
    margin: 0 auto;
    text-align: center;
}

.model-selectorx label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: #666;
}

.model-selectorx select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    background-color: white;
    font-size: 14px;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    /* Ensure the container has a proper background */
    background-color: #f9f9f9;
    /* Prevent margin collapse */
    padding-top: 5px;
    padding-bottom: 5px;
}

.user-box {
    justify-content: center;  /* Center horizontally */
    align-items: center;      /* Center vertically */
    text-align: center;       /* Ensure text is centered */
    font-size: 13px;
    height: 100%;             /* Take full height of container */
    width: 100%;              /* Ensure full width */
}

.user-box h4 {
    font-size: 18px;  /* Adjust the font size for h1 */
}
        
.button {
    display: inline-block;
    background: #429ef5;
    color: #ffffff;
    padding: 7px 14px;
    border: none;
    border-radius: 5px;
    text-decoration: none;
    margin-top: 10px;
}

/* Fixed chat item style - consolidated and improved */
.chat-item {
    padding: 8px 10px !important; /* Increase padding slightly */
    margin-bottom: 3px; /* Increase space between items */
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Add max-width and prevent text overflow */
    max-width: 100%;
    overflow: hidden;
}

.chat-title-container {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    /* Ensure the text doesn't extend beyond the container */
    max-width: calc(100% - 30px); /* Reserve space for the delete button */
}

.delete-chat-btn {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 2px 5px;
    font-size: 12px;
    opacity: 0.7;
    transition: opacity 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-chat-btn:hover {
    opacity: 1;
    color: #ff3b30;
}

.chat-item:hover {
    background-color: #f0f0f0;
}

.chat-item.active {
    background-color: #e5e5e5;
}

/* Main chat area styles */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative; /* Added position relative for positioning context */
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 80px; /* Extra space at bottom to prevent content being hidden behind input */
    max-width: 900px !important;
    
}

.welcome-message {
    max-width: 900px;
    margin: 60px auto;
    text-align: center;
    color: #444654;
}

.welcome-message h1 {
    font-size: 2rem;
    margin-bottom: 15px;
    line-height:36px;
}

.message {
    display: flex;
    padding: 20px;
    margin-bottom: 10px;
    width: 100%;
}

.user-message {
     font-size: 15px;
     background-color: #ebebeb;
    border-radius: 15px;
    max-width: 800px;
}

.assistant-message {
     font-size: 15px;
     background-color: #ffffff;
    border-radius: 15px;
        max-width: 800px;
}

.message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 3px;
    margin-right: 15px;
    background-color: #10a37f;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.user-avatar {
    background-color: #444654;
}

.message-content {
    flex: 1;
    max-width: 100%;
}

.message-content pre {
    background-color: #f7f7f8;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 15px 0;
}

.message-content code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
    font-size: 0.9em;
}

.code-copy-button {
    color: grey;
}
.message-content p {
    margin-bottom: 10px;
}

.message-content ul, .message-content ol {
    margin-left: 20px;
    margin-bottom: 10px;
}

/* Chat input styles */
.chat-input-container {
    border-top: 1px solid #e5e5e5;
    padding: 15px;
    background-color: #ffffff;
    position: sticky; /* Make it sticky */
    bottom: 0; /* Stick to bottom */
    width: 100%;
    z-index: 10; /* Ensure it stays on top */
    box-shadow: 0 -2px 5px rgba(0,0,0,0.05); /* Subtle shadow for better visibility */
    max-width: 900px !important;
}

#chat-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    max-width: 900px;
    margin: 0 auto;
    position: relative;
}

#user-input {
    flex: 1;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 12px 40px 12px 12px;
    resize: none;
    font-size: 16px;
    outline: none;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

#send-button {
    position: absolute;
    right: 10px;
    bottom: 10px;
    background: transparent;
    border: none;
    color: green !important;
    background-color:transparent !important;
    font-size: 16px;
    cursor: pointer;
    transition: color 0.2s;
}

#send-button:hover {
    color: #0d8c6c;
}

.input-info {
    max-width: 800px;
    margin: 5px auto 0;
    font-size: 12px;
    color: #666;
}

/* Loading indicator */
.loading-indicator {
    display: flex;
    align-items: center;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 18px;
    background-color: #f5f5f5;
    max-width: 800px;
}

/* Teks "Typing..." dengan kursor */
.typing-text {
    font-size: 14px;
    color: #666;
    margin-right: 8px;
    display: inline-block;
    white-space: nowrap;
    border-right: 2px solid black; /* Simulasi kursor */
    animation: blinkCursor 0.8s infinite;
}

/* Animasi berkedip untuk kursor */
@keyframes blinkCursor {
    50% { border-color: transparent; }
}

/* Blinking dots */
.dot {
    width: 8px;
    height: 8px;
    margin: 0 4px;
    background-color: #10a37f;
    border-radius: 50%;
    animation: blink 1.5s infinite;
}

.dot:nth-child(2) {
    animation-delay: 0.2s;
}

.dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes blink {
    0% { opacity: 0.2; }
    50% { opacity: 1; }
    100% { opacity: 0.2; }
}


.title-display {
    display: none;
}

/* Error message */
.error-message {
    background-color: #fdeded;
    color: #b71c1c;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 15px;
    max-width: 800px;
}

/* Code highlighting */
.hljs {
    background-color: #f7f7f8 !important;
}

/* Sidebar toggle button */
.sidebar-toggle-btn {
    display: none; /* Hidden by default on desktop */
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 100;
    background: #f9f9f9;
    border: 1px solid #e5e5e5;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.sidebar-toggle-btn:hover {
    background: #f0f0f0;
    transform: scale(1.05);
}

.sidebar-toggle-btn i {
    font-size: 16px;
    color: #333;
}

/* Mobile sidebar behavior */
@media (max-width: 768px) {
    /* Update app container to allow absolute positioning */
    .app-container {
        position: relative;
        overflow-x: hidden;
    }
    
    /* Sidebar positioning for mobile */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 250px;
        z-index: 200;
        transition: transform 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        background-color: #f9f9f9 !important; /* Force solid background */
        opacity: 1 !important;
    }
    
    /* Sidebar hidden state */
    .sidebar-hidden {
        transform: translateX(-100%);
    }
    
    /* Ensure sidebar is shown when open */
    .sidebar:not(.sidebar-hidden) {
        display: flex !important;
        opacity: 1 !important;
        background-color: #f9f9f9 !important;
    }
    
    /* Adjust chat container to take full width */
    .chat-container {
        width: 100%;
        padding-left: 10px;
        padding-right: 10px;
    }
    
    /* Show all sidebar elements when sidebar is visible */
    .sidebar:not(.sidebar-hidden) .sidebar-header,
    .sidebar:not(.sidebar-hidden) .model-selector,
    .sidebar:not(.sidebar-hidden) .chat-history {
        display: block !important;
    }
    
    /* Ensure proper spacing for title when sidebar is hidden */
    .title-display {
        margin-top: 10px;
        padding-left: 40px; /* Make room for the toggle button */
    }
    
    /* For devices under 480px (smaller phones) */
    @media (max-width: 480px) {
        .sidebar {
            width: 85%; /* Wider sidebar on very small screens */
        }
    }
    
    /* Previous mobile styles - reordered for clarity */
    .app-container {
        flex-direction: column;
    }
    
    .chat-container {
        height: calc(100vh - 80px); /* Reduced height calculation */
        min-height: 400px; /* Set minimum height */
    }
    
    .chat-input-container {
        padding: 10px; /* Smaller padding on mobile */
        position: fixed; /* Fixed position on mobile */
        bottom: 0;
        left: 0;
        right: 0;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1); /* Add shadow for visibility */
    }
    
    .chat-messages {
        padding-bottom: 190px !important; /* Add space for the fixed input container */
    }
    
    .message {
        padding: 15px; /* Reduced padding for messages on mobile */
    }
    
    .message-avatar {
        width: 20px;
        height: 20px;
        border-radius: 3px;
        margin-right: 10px;
        display: none; /* Hide avatars on mobile */
    }
    
    /* When the sidebar is NOT visible */
    .sidebar.sidebar-hidden {
        width: 100%;
        height: auto;
        max-height: 80px; /* Reduced height */
    }
    
    /* Don't hide these when sidebar is visible */
    .chat-history,
    .sidebar-header,
    .model-selector {
        display: none !important;
    }
    
    .title-display {
        display: block;
        color: orange !important;
        text-align: center;
        padding: 10px 0;
    }
    
    .welcome-message {
        margin: 30px auto; /* Reduced margin on mobile */
    }
    
    .welcome-message h1 {
        font-size: 1.5rem; /* Smaller heading on mobile */
    }
}
/* Scroll to top button - works on all devices */
.scroll-to-top {
    position: fixed;
    bottom: 110px; /* Positioned above the chat input container */
    right: 20px;
    z-index: 999; /* Higher z-index to ensure visibility */
    width: 40px;
    height: 40px;
    
    color: #10a37f;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex; /* Use flex for alignment */
    align-items: center;
    justify-content: center;
    opacity: 0.9; /* Slightly transparent */
}

.scroll-to-top:hover {
    color: #0d8c6c;
    transform: scale(1.1);
    opacity: 1;
}

.scroll-to-top i {
    font-size: 20px; /* Larger icon */
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .scroll-to-top {
        bottom: 110px; /* Higher position on mobile */
        right: 15px;
        width: 40px; /* Larger button on mobile */
        height: 40px;
        opacity: 0.95; /* More visible on mobile */
        color: #0d8c6c; /* Darker color for better visibility */
    }
    .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 5px;
    padding-top: 70px; 
    padding-bottom: 80px; /* Extra space at bottom to prevent content being hidden behind input */
}
    
    .message-content {
    flex: 1;
    max-width: 100%;
    font-size: 0.95em;
}

.message-content pre {
    background-color: #f7f7f8;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 15px 0;
    max-width: 100%;
        font-size: 0.8em;
}

.message-content code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
    font-size: 0.95em;
    max-width: 100%;
}
}
.welcome-new-chat-btn {
    margin: 15px auto;
    display: block;
    width: auto; /* Override the 100% width from the sidebar button */
    padding: 10px 15px;
    background-color: #10a37f; /* Match your existing new-chat-btn color */
    transition: background-color 0.3s;
}

.welcome-new-chat-btn:hover {
    background-color: #0d8c6c;
}
/* Add this to your CSS file */
.sidebar-toggle-btn {
    position: fixed;
    left: 10px;
    top: 0px;
    z-index: 1000;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    display: none; /* Hidden by default, shown on mobile */
    box-shadow: none;
}

.toggle-image {
    width: 130px; /* Set to exact 200px as requested */
    height: auto;
    display: block;
}

/* Ensure the entire button area is clickable */
.sidebar-toggle-btn:focus {
    outline: none;
}

@media (max-width: 768px) {
    .sidebar-toggle-btn {
        display: block;
    }
    
    .sidebar-hidden {
        display: none !important;
    }
}
.chat-input-container {
        position: relative;
        padding-bottom: 10px;
    }
    
    /* File upload container styling */
    .uploaded-files-container {
        width: 100%;
        background-color: white;
        border-top: 1px solid #e0e0e0;
        border-radius: 8px 8px 0 0;
        box-shadow: 0 -2px 5px rgba(0,0,0,0.05);
        max-height: 150px;
        overflow-y: auto;
        margin-bottom: 10px;
        display: none; /* Hidden by default, shown when files are uploaded */
    }
    
    .uploaded-files-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 15px;
        border-bottom: 1px solid #f0f0f0;
        font-weight: bold;
        background-color: #f9f9f9;
        max-width: 800px;
    }
    
    .clear-files-btn {
        background-color: transparent;
        border: none;
        color: #ff5252;
        cursor: pointer;
        font-size: 14px;
        padding: 2px 5px;
    }
    
    .clear-files-btn:hover {
        text-decoration: underline;
    }
    
    .uploaded-files-list {
        padding: 8px;
    }
    
    .file-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 10px;
        margin-bottom: 5px;
        background-color: #f5f5f5;
        border-radius: 4px;
        max-width: 800px;
    }
    
    .file-info {
        display: flex;
        align-items: center;
        max-width: 80%;
    }
    
    .file-icon {
        margin-right: 8px;
        color: #4285F4;
    }
    
    .file-name {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 14px;
    }
    
    .file-size {
        font-size: 12px;
        color: #757575;
        margin-left: 8px;
    }
    
    .remove-file-btn {
        background-color: transparent;
        border: none;
        color: #ff5252;
        cursor: pointer;
        font-size: 14px;
    }
    
    /* Form styling */
    #chat-form {
        display: flex;
        position: relative;
        border: 1px solid #ddd;
        border-radius: 8px;
        background: white;
    }
    
    .file-upload-button-container {
        position: absolute;
        top: 12px;
        left: 10px;
        z-index: 5;
    }
    
    .upload-btn {
        background-color: transparent;
        border: none;
        color: #6e6e6e;
        cursor: pointer;
        font-size: 18px;
        padding: 5px;
        transition: color 0.3s;
    }
    
    .upload-btn:hover {
        color: #4285F4;
    }
    
    #user-input {
        flex-grow: 1;
        padding: 12px 12px 12px 40px; /* Add left padding for the upload button */
        border: none;
        border-radius: 8px;
        resize: none;
        outline: none;
        font-family: Arial, sans-serif;
        font-size: 16px;
        line-height: 1.4;
    }
    
    #send-button {
        width: 50px;
        height: 50px;
        margin: 5px;
    }
    
    .input-info {
        display: flex;
        justify-content: flex-end;
        color: #777;
        font-size: 12px;
        margin-top: 5px;
    }
    
    /* Mobile responsiveness */
    @media (max-width: 768px) {
        .uploaded-files-container {
            max-height: 120px;
        }
        
        .file-item {
            padding: 5px 8px;
        }
        
        #user-input {
            font-size: 14px;
        }
    }
    
/* Add these styles to your styles.css file or within your <style> tag in the head section */
.mobile-benefits-container {
    margin: 15px auto;
    max-width: 90%;
}

.mobile-benefits-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.mobile-benefit-item {
    background-color: #d9fcea;
    border-radius: 8px;
    padding: 10px 5px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.2s ease;
}

.mobile-benefit-item:active {
    transform: scale(0.98);
}

.mobile-benefit-icon {
    font-size: 20px;
    margin-bottom: 5px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-benefit-text h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 300;
    color: #444;
    line-height: 1.2;
}

/* Ensure this works well on very small screens */
@media (max-width: 320px) {
    .mobile-benefits-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .mobile-benefit-text h4 {
        font-size: 10px;
    }
}    

/* Model info styles */
.model-info {
    display: inline-flex;
    align-items: center;
    font-size: 0.85em;
    color: grey;
    margin-right: 12px;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: rgba(0, 0, 0, 0.05);
}

.model-info i {
    margin-right: 4px;
}

/* Container for utility buttons */
.message-utility-buttons {
    display: flex;
    align-items: center;
    margin-top: 8px;
    justify-content: flex-end;
}

/* Make sure the copy button looks good */
.copy-icon {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: rgba(0, 0, 0, 0.05);
    cursor: pointer;
}

.copy-icon:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.copy-icon i {
    margin-right: 4px;
}