/* 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;
    line-height: 1.6;
    color: #333;
    background-color: #f9f9f9;
    transition: background-color 0.3s, color 0.3s;
}

body.dark-mode {
    background-color: #1a1a1a;
    color: #f0f0f0;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* Sidebar Styles */
.sidebar {
    width: 280px;
    background-color: #ffffff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    z-index: 100;
}

body.dark-mode .sidebar {
    background-color: #252525;
    border-right: 1px solid #3d3d3d;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

body.dark-mode .sidebar-header {
    border-bottom: 1px solid #3d3d3d;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
}

body.dark-mode .sidebar-header h2 {
    color: #f0f0f0;
}

.new-chat-button {
    margin: 15px;
    padding: 10px 15px;
    background-color: #4a90e2;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 0.2s;
}

.new-chat-button:hover {
    background-color: #3a80d2;
}

.conversations-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.conversations-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.conversation-item {
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.conversation-item:hover {
    background-color: #f0f0f0;
}

body.dark-mode .conversation-item:hover {
    background-color: #333;
}

.conversation-item.active {
    background-color: #e6f0ff;
}

body.dark-mode .conversation-item.active {
    background-color: #2c3e50;
}

.conversation-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-date {
    font-size: 0.8rem;
    color: #888;
    margin-top: 4px;
}

body.dark-mode .conversation-date {
    color: #aaa;
}

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

body.dark-mode .sidebar-footer {
    border-top: 1px solid #3d3d3d;
}

.model-select-container {
    display: flex;
    align-items: center;
    gap: 5px;
}

.model-select-container label {
    font-size: 0.9rem;
    color: #555;
}

body.dark-mode .model-select-container label {
    color: #ccc;
}

.model-selector {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    font-size: 0.9rem;
    width: 50px;
}

body.dark-mode .model-selector {
    background-color: #333;
    border: 1px solid #555;
    color: #f0f0f0;
    width: 100px;
}

.theme-toggle, .clear-all-button {
    padding: 8px 12px;
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 0.2s;
}

body.dark-mode .theme-toggle, 
body.dark-mode .clear-all-button {
    border: 1px solid #555;
    color: #f0f0f0;
}

.theme-toggle:hover, .clear-all-button:hover {
    background-color: #f0f0f0;
}

body.dark-mode .theme-toggle:hover, 
body.dark-mode .clear-all-button:hover {
    background-color: #333;
}

.clear-all-button {
    color: #e74c3c;
}

/* Chat Area Styles */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chat-header {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #fff;
    z-index: 10;
}

body.dark-mode .chat-header {
    background-color: #252525;
    border-bottom: 1px solid #3d3d3d;
}

.chat-title-container {
    flex: 1;
    overflow: hidden;
}

.chat-title-container h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-actions {
    display: flex;
    gap: 10px;
}

.action-button {
    background: none;
    border: none;
    font-size: 1rem;
    color: #888;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
}

.action-button:hover {
    background-color: #f0f0f0;
    color: #333;
}

body.dark-mode .action-button {
    color: #ccc;
}

body.dark-mode .action-button:hover {
    background-color: #333;
    color: #fff;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-color: #f9f9f9;
}

body.dark-mode .chat-messages {
    background-color: #1a1a1a;
}

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

.welcome-content {
    max-width: 600px;
    padding: 30px;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body.dark-mode .welcome-content {
    background-color: #252525;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.welcome-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
}

.welcome-icon {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #4a90e2;
    color: white;
    border-radius: 50%;
    font-size: 1.5rem;
}

.welcome-content h2 {
    margin: 0;
    font-size: 1.5rem;
}

.welcome-content p {
    margin: 15px 0;
    color: #666;
}

body.dark-mode .welcome-content p {
    color: #ccc;
}

.suggestion-section {
    margin-top: 20px;
}

.suggestion-section h3 {
    font-size: 1rem;
    margin-bottom: 10px;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.suggestion-chip {
    padding: 8px 12px;
    background-color: #e6f0ff;
    border-radius: 16px;
    font-size: 0.9rem;
    color: #4a90e2;
    cursor: pointer;
    transition: background-color 0.2s;
}

body.dark-mode .suggestion-chip {
    background-color: #2c3e50;
}

.suggestion-chip:hover {
    background-color: #d0e3ff;
}

body.dark-mode .suggestion-chip:hover {
    background-color: #3a5472;
}

.message {
    display: flex;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background-color: #4a90e2;
    color: white;
}

.assistant-message .message-avatar {
    background-color: #34a853;
    color: white;
}

.message-content {
    flex: 1;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    overflow-wrap: break-word;
    word-break: break-word;
}

.user-message .message-content {
    background-color: #e6f0ff;
    color: #333;
    border-top-left-radius: 2px;
}

body.dark-mode .user-message .message-content {
    background-color: #2c3e50;
    color: #f0f0f0;
}

.assistant-message .message-content {
    background-color: #f0f0f0;
    color: #333;
    border-top-right-radius: 2px;
}

body.dark-mode .assistant-message .message-content {
    background-color: #333;
    color: #f0f0f0;
}

.message-content p {
    margin-bottom: 0.8em;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content pre {
    background-color: #f5f5f5;
    border-radius: 4px;
    padding: 10px;
    overflow-x: auto;
    position: relative;
    margin: 1em 0;
}

body.dark-mode .message-content pre {
    background-color: #1d1d1d;
}

.message-content code {
    font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
}

.message-content pre code {
    white-space: pre;
    word-spacing: normal;
    word-break: normal;
    line-height: 1.5;
    tab-size: 4;
    hyphens: none;
    padding: 0;
    margin: 0;
    overflow-x: auto;
    display: block;
}

.message-content p code, 
.message-content li code {
    background-color: #f0f0f0;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.9em;
}

body.dark-mode .message-content p code, 
body.dark-mode .message-content li code {
    background-color: #2d2d2d;
}

.copy-code-button {
    position: absolute;
    top: 5px;
    right: 5px;
    padding: 4px 8px;
    font-size: 0.75rem;
    background-color: #e0e0e0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

body.dark-mode .copy-code-button {
    background-color: #444;
    color: #eee;
}

.copy-code-button:hover {
    opacity: 1;
}

.message-content ul, 
.message-content ol {
    margin: 0.8em 0;
    padding-left: 1.5em;
}

.message-content blockquote {
    border-left: 3px solid #ddd;
    margin: 0.8em 0;
    padding-left: 1em;
    color: #777;
}

body.dark-mode .message-content blockquote {
    border-left-color: #555;
    color: #bbb;
}

.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

.message-content th, 
.message-content td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
}

body.dark-mode .message-content th, 
body.dark-mode .message-content td {
    border-color: #444;
}

.message-content th {
    background-color: #f5f5f5;
    font-weight: 600;
}

body.dark-mode .message-content th {
    background-color: #2d2d2d;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    color: #777;
    animation: fadeIn 0.3s ease-in-out;
}

body.dark-mode .typing-indicator {
    color: #aaa;
}

.dot-flashing {
    position: relative;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #777;
    animation: dotFlashing 1s infinite linear alternate;
    animation-delay: 0.5s;
}

body.dark-mode .dot-flashing {
    background-color: #aaa;
}

.dot-flashing::before, .dot-flashing::after {
    content: '';
    display: inline-block;
    position: absolute;
    top: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #777;
    animation: dotFlashing 1s infinite alternate;
}

body.dark-mode .dot-flashing::before, 
body.dark-mode .dot-flashing::after {
    background-color: #aaa;
}

.dot-flashing::before {
    left: -14px;
    animation-delay: 0s;
}

.dot-flashing::after {
    left: 14px;
    animation-delay: 1s;
}

@keyframes dotFlashing {
    0% { background-color: #777; }
    50%, 100% { background-color: #e0e0e0; }
}

body.dark-mode @keyframes dotFlashing {
    0% { background-color: #aaa; }
    50%, 100% { background-color: #555; }
}

.message-form {
    display: flex;
    padding: 15px;
    background-color: #fff;
    border-top: 1px solid #e0e0e0;
    position: relative;
}

body.dark-mode .message-form {
    background-color: #252525;
    border-top: 1px solid #3d3d3d;
}

.message-input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 18px;
    font-size: 0.95rem;
    resize: none;
    outline: none;
    max-height: 150px;
    background-color: #f9f9f9;
}

body.dark-mode .message-input {
    background-color: #333;
    border: 1px solid #555;
    color: #f0f0f0;
}

.message-input:focus {
    border-color: #4a90e2;
}

body.dark-mode .message-input:focus {
    border-color: #4a90e2;
}

.send-button {
    margin-left: 10px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #4a90e2;
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

.send-button:hover {
    background-color: #3a80d2;
}

.send-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    width: 400px;
    max-width: 90%;
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1010;
}

body.dark-mode .modal-content {
    background-color: #252525;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.modal-header {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
}

body.dark-mode .modal-header {
    border-bottom: 1px solid #3d3d3d;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.modal-body {
    padding: 15px;
}

.modal-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.95rem;
}

body.dark-mode .modal-input {
    background-color: #333;
    border: 1px solid #555;
    color: #f0f0f0;
}

.modal-footer {
    padding: 15px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

body.dark-mode .modal-footer {
    border-top: 1px solid #3d3d3d;
}

.modal-button {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.modal-button.primary {
    background-color: #4a90e2;
    color: white;
    border: none;
}

.modal-button.primary:hover {
    background-color: #3a80d2;
}

.modal-button.secondary {
    background-color: transparent;
    border: 1px solid #ddd;
    color: #555;
}

body.dark-mode .modal-button.secondary {
    border: 1px solid #555;
    color: #ddd;
}

.modal-button.secondary:hover {
    background-color: #f0f0f0;
}

body.dark-mode .modal-button.secondary:hover {
    background-color: #333;
}

.modal-button.danger {
    background-color: #e74c3c;
    color: white;
    border: none;
}

.modal-button.danger:hover {
    background-color: #c0392b;
}

/* Mobile styles */
.mobile-only {
    display: none;
}

@media screen and (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .sidebar {
        position: fixed;
        left: -280px;
        height: 100%;
        transition: left 0.3s ease;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .icon-button {
        background: none;
        border: none;
        font-size: 1.2rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #555;
    }
    
    body.dark-mode .icon-button {
        color: #ddd;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}
