* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background-color: #202123;
    color: white;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #4a4a4a;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #4a4a4a;
}

.sidebar-header h2 {
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-icon {
    font-size: 14px;
    color: #8e8ea0;
    cursor: pointer;
    transition: color 0.2s;
    margin-left: auto;
}

.settings-icon:hover {
    color: #10a37f;
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    background-color: #343541;
    color: white;
    border: 1px solid #565869;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.new-chat-btn:hover {
    background-color: #40414f;
}

.model-selector {
    padding: 15px 20px;
    border-bottom: 1px solid #4a4a4a;
}

.model-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.model-header label {
    font-size: 14px;
    color: #c5c5d2;
}

.refresh-btn {
    background: none;
    border: none;
    color: #c5c5d2;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.refresh-btn:hover {
    color: #10a37f;
    background-color: #343541;
}

.refresh-btn.loading {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.model-selector select {
    width: 100%;
    padding: 8px 12px;
    background-color: #343541;
    color: white;
    border: 1px solid #565869;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 8px;
}

.model-info {
    font-size: 12px;
    color: #8e8ea0;
    line-height: 1.4;
}

.model-info .provider {
    color: #10a37f;
    font-weight: 500;
}

.model-info .context-length {
    color: #f59e0b;
}

.model-info .modalities {
    color: #8e8ea0;
}

.model-info .warning {
    color: #f59e0b;
    font-weight: 500;
}

/* API Key Items (used in settings modal) */
.api-key-list {
    margin-bottom: 10px;
}

.api-key-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background-color: #343541;
    border-radius: 4px;
    margin-bottom: 5px;
    font-size: 12px;
}

.api-key-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    margin-right: 10px;
}

.api-key-actions {
    display: flex;
    gap: 5px;
}

.api-key-edit-btn,
.api-key-delete-btn {
    background: none;
    border: none;
    color: #8e8ea0;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 12px;
}

.api-key-edit-btn:hover {
    color: #10a37f;
    background-color: #40414f;
}

.api-key-delete-btn:hover {
    color: #ef4444;
    background-color: #40414f;
}

.api-key-name {
    color: white;
    font-weight: 500;
}

.api-key-usage {
    color: #c5c5d2;
}

.api-key-usage.low {
    color: #10a37f;
}

.api-key-usage.medium {
    color: #f59e0b;
}

.api-key-usage.high {
    color: #ef4444;
}

.add-api-key-btn {
    width: 100%;
    padding: 8px 12px;
    background-color: #10a37f;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s;
}

.add-api-key-btn:hover {
    background-color: #0d8a6f;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.chat-item {
    padding: 10px 15px;
    margin-bottom: 5px;
    background-color: #343541;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
}

.chat-item-title {
    color: white;
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-date {
    color: #8e8ea0;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item:hover {
    background-color: #40414f;
}

.chat-item.active {
    background-color: #40414f;
    border-left: 3px solid #10a37f;
}

.chat-item-delete {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #8e8ea0;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
    z-index: 2;
}

.chat-item-delete:hover {
    background: #ef4444;
    color: #fff;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #343541;
}

.chat-header {
    padding: 15px 20px;
    background-color: #40414f;
    border-bottom: 1px solid #565869;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    color: white;
    font-size: 16px;
    font-weight: 500;
}

.header-actions {
    color: #c5c5d2;
    font-size: 14px;
}

.api-key-used {
    color: #c5c5d2;
    font-size: 12px;
    margin-left: 10px;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100%;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 0;
    line-height: 1;
    width: 100%;
    box-sizing: border-box;
}

.chat-messages > * {
    margin: 0;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
}

.welcome-message {
    text-align: center;
    color: #c5c5d2;
    margin-top: 100px;
}

.welcome-message i {
    font-size: 48px;
    margin-bottom: 20px;
    color: #10a37f;
}

.welcome-message h2 {
    margin-bottom: 10px;
    color: white;
}

.message {
    display: flex;
    align-items: flex-start;
    margin: 4px 0;
    padding: 0;
    gap: 8px;
    line-height: 1;
    width: 100%;
}

.message.assistant {
    justify-content: flex-start;
}

.message.user {
    justify-content: flex-end;
}

.message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background-color: #10a37f;
    color: white;
}

.message.assistant .message-avatar {
    background-color: #565869;
    color: white;
}

.message-content {
    flex: 0 1 auto;
    word-wrap: break-word;
    white-space: pre-wrap;
    line-height: 1.5;
    margin: 0;
    padding: 0;
    max-width: 70%;
    min-width: 0;
    overflow-wrap: break-word;
}

.message-content:empty {
    display: none;
}

.message.assistant .message-content {
    background-color: #f7f7f8;
    padding: 8px 12px;
    border-radius: 8px;
    margin: 0;
    max-width: 70%;
    width: fit-content;
    min-width: 0;
}

.message.user .message-content {
    background-color: #007bff;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    margin: 0;
    max-width: 70%;
    width: fit-content;
    min-width: 0;
}

.message-content br {
    display: block;
    content: "";
    margin: 8px 0;
}

.message-content p {
    margin: 8px 0;
}

.message-content code {
    background-color: #2d3748;
    color: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    border: 1px solid #4a5568;
}

.message-content pre {
    background-color: #2d3748;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.5;
    border: 1px solid #4a5568;
}

.message-content pre code {
    background-color: transparent;
    color: inherit;
    padding: 0;
    border: none;
    border-radius: 0;
}

.message-content pre {
    background-color: #2d3748;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.5;
    border: 1px solid #4a5568;
}

.message-content pre code {
    background-color: transparent;
    color: inherit;
    padding: 0;
    border: none;
    border-radius: 0;
}

.message-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    margin-top: 10px;
}

.message-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background-color: #565869;
    border-radius: 6px;
    margin-top: 10px;
    color: white;
    text-decoration: none;
}

.message-file i {
    font-size: 20px;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
    margin: 0;
    line-height: 1;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: #8e8ea0;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
    margin: 0;
    padding: 0;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Chat Input */
.chat-input-container {
    padding: 20px;
    background-color: #40414f;
    border-top: 1px solid #565869;
}

.input-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.file-input-label,
.image-input-label {
    padding: 8px 12px;
    background-color: #565869;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.file-input-label:hover,
.image-input-label:hover {
    background-color: #6b6c7b;
}

/* ซ่อน input เมื่อไม่รองรับ */
.file-input-label.hidden,
.image-input-label.hidden {
    display: none !important;
}

/* Animation สำหรับการซ่อน/แสดง */
.file-input-label,
.image-input-label {
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.3s ease, transform 0.3s ease, display 0.3s ease;
}

.file-input-label[style*="display: none"],
.image-input-label[style*="display: none"] {
    opacity: 0;
    transform: scale(0.8);
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#messageInput {
    flex: 1;
    padding: 12px 16px;
    background-color: #40414f;
    border: 1px solid #565869;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    resize: none;
    max-height: 120px;
    min-height: 44px;
}

#messageInput:focus {
    outline: none;
    border-color: #10a37f;
}

#messageInput::placeholder {
    color: #8e8ea0;
}

.send-btn {
    padding: 12px 16px;
    background-color: #10a37f;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
    min-width: 44px;
}

.send-btn:hover {
    background-color: #0d8a6f;
}

.send-btn:disabled {
    background-color: #565869;
    cursor: not-allowed;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #40414f;
    margin: 15% auto;
    padding: 0;
    border-radius: 8px;
    width: 400px;
    max-width: 90%;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #565869;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    color: white;
    margin: 0;
}

.close {
    color: #c5c5d2;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: white;
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    color: #c5c5d2;
    margin-bottom: 5px;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    background-color: #343541;
    border: 1px solid #565869;
    border-radius: 4px;
    color: white;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: #10a37f;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #565869;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-primary {
    padding: 10px 20px;
    background-color: #10a37f;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.btn-primary:hover {
    background-color: #0d8a6f;
}

.btn-secondary {
    padding: 10px 20px;
    background-color: #565869;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.btn-secondary:hover {
    background-color: #6b6c7b;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #343541;
}

::-webkit-scrollbar-thumb {
    background: #565869;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #6b6c7b;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 250px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .api-key-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

/* Settings Modal */
.settings-section {
    margin-bottom: 20px;
}

.settings-section h4 {
    color: #c5c5d2;
    font-size: 16px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-section .api-key-list {
    margin-bottom: 15px;
}

.settings-section .add-api-key-btn {
    width: 100%;
    padding: 10px 12px;
    background-color: #10a37f;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.settings-section .add-api-key-btn:hover {
    background-color: #0d8a6f;
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 20px;
    background-color: white;
    border-top: 1px solid #e5e7eb;
    width: 100%;
    box-sizing: border-box;
}

.message-input {
    flex: 1;
    min-height: 20px;
    max-height: 120px;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    outline: none;
    width: 100%;
    box-sizing: border-box;
} 