/* Override base root variables first */
:root {
    --primary-color: #3b82f6;
    --primary-color-dark: #2563eb;
    --surface-color: #1e293b;
    --background-color: #0f172a;
    --border-color: #334155;
    --text-color: #f1f5f9;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
}

/* Full-width container for chat interface */
.chat-full-width-container {
    display: flex;
    height: 100vh;
    width: 100%;
    position: relative;
    background-color: var(--background-color);
    margin: 0;
    padding: 0;
}

/* Sidebar Styles */
#sidebar {
    width: 280px;
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    padding: 20px;
    overflow-y: auto;
    height: 100vh;
    position: relative;
    z-index: 100;
    transition: transform 0.3s ease-in-out;
}

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

.sidebar h2 {
    margin: 0;
    font-size: 1.5em;
    color: var(--text-color);
}

.primary-color {
    color: var(--primary-color);
}

.btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    width: 100%;
    text-align: center;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn:hover {
    background-color: var(--primary-color-dark);
}

.model-selector {
    margin-bottom: 20px;
}

.model-selector label {
    font-size: 0.9em;
    color: #94a3b8;
    display: block;
    margin-bottom: 5px;
}

.model-selector select {
    width: 100%;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background-color: var(--background-color);
    color: var(--text-color);
    font-size: 14px;
}

.sidebar h3 {
    color: #94a3b8;
    font-size: 0.9em;
    margin-bottom: 10px;
    margin-top: 0;
}

#conversations-list {
    margin-top: 10px;
}

.conversation-item {
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background-color: transparent;
}

.conversation-item:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

.conversation-item.active {
    background-color: #334155;
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 5px;
}

.conversation-title {
    font-weight: 600;
    flex: 1;
    word-break: break-word;
    color: var(--text-color);
}

.conversation-actions {
    display: flex;
    gap: 5px;
    margin-left: 10px;
}

.conversation-copy-btn,
.delete-conv-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.conversation-copy-btn {
    color: #94a3b8;
}

.conversation-copy-btn:hover {
    color: #3b82f6;
    background-color: rgba(59, 130, 246, 0.1);
}

.conversation-copy-btn.copied {
    color: #10b981;
}

.delete-conv-btn {
    color: #ef4444;
}

.delete-conv-btn:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

.conversation-meta {
    font-size: 0.8em;
    color: #94a3b8;
    margin-bottom: 2px;
}

.conversation-model {
    font-size: 0.8em;
    color: #60a5fa;
}

.no-conversations {
    color: #94a3b8;
    text-align: center;
    padding: 20px;
}

/* Mobile Toggle Button */
.mobile-toggle-btn {
    display: none;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    font-size: 20px;
}

.mobile-close-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
    pointer-events: all;
}

/* Main Chat Area */
#main-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: calc(100% - 280px);
    height: 100vh;
    position: relative;
    padding: 0;
}

.chat-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--surface-color);
}

.chat-header h3 {
    margin: 0;
    font-size: 1.1em;
    color: var(--text-color);
}

#current-model {
    color: #94a3b8;
    font-size: 0.85em;
    margin-top: 2px;
}

#messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

/* Input Area */
.input-area {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    background-color: var(--surface-color);
}

.input-container {
    display: flex;
    gap: 10px;
}

#message-input {
    flex: 1;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--background-color);
    color: var(--text-color);
    resize: none;
    min-height: 50px;
    font-size: 0.95em;
    font-family: inherit;
    max-width: 100%;
}

.input-hint {
    margin-top: 8px;
    font-size: 0.8em;
    color: #94a3b8;
}

/* Override button styles specifically for chat input */
.input-area .btn {
    width: auto !important;
    padding: 12px 24px !important;
    font-size: 14px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

/* Message Styles */
.message {
    margin-bottom: 20px;
    border-radius: 8px;
    padding: 15px;
    max-width: 80%;
    position: relative;
}

.user-message {
    background-color: #1e3a8a;
    align-self: flex-end;
    margin-left: auto;
    color: white;
}

.assistant-message {
    background-color: var(--surface-color);
    align-self: flex-start;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

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

.message-role {
    font-weight: 600;
    color: inherit;
}

.user-message .message-role {
    color: #60a5fa;
}

.assistant-message .message-role {
    color: #34d399;
}

.message-actions {
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s;
}

.message:hover .message-actions {
    opacity: 1;
}

.message-copy-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    width: 28px;
    height: 28px;
}

.message-copy-btn:hover {
    color: #3b82f6;
    background-color: rgba(59, 130, 246, 0.1);
}

.message-copy-btn.copied {
    color: #10b981;
}

.message-content {
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    color: var(--text-color);
}

/* Thinking Indicator */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinning-wheel {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
}

.thinking-indicator {
    display: flex;
    align-items: center;
    color: #94a3b8;
    font-style: italic;
}

.stop-btn {
    background-color: #ef4444;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    margin-left: 8px;
}

.stop-btn:hover {
    background-color: #dc2626;
}

/* Code Block Styling */
.code-block {
    position: relative;
    margin: 15px 0;
    border-radius: 8px;
    overflow: hidden;
    background-color: #1e293b;
    border: 1px solid #334155;
}

.code-block pre {
    margin: 0;
    padding: 15px;
    overflow-x: auto;
    color: #e2e8f0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
}

.code-block .code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    background-color: #334155;
    color: #94a3b8;
    font-size: 12px;
}

.code-block .copy-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.code-block .copy-btn:hover {
    background-color: #2563eb;
}

.code-block .copy-btn.copied {
    background-color: #10b981;
}

/* Notification */
.copy-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #10b981;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10000;
    font-size: 14px;
    animation: slideIn 0.3s ease-out;
}

.copy-notification.error {
    background-color: #ef4444;
}

@keyframes slideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chat-full-width-container {
        display: block;
    }

    #sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        z-index: 1000;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        box-shadow: 2px 0 20px rgba(0,0,0,0.3);
    }

    #sidebar.sidebar-open {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: all;
    }

    .mobile-toggle-btn {
        display: block;
        z-index: 1001;
    }

    .mobile-close-btn {
        display: flex;
    }

    #main-chat-area {
        width: 100%;
        height: 100vh;
    }

    .message {
        max-width: 90%;
    }

    body.sidebar-open {
        overflow: hidden;
    }
}

/* Desktop Styles */
@media (min-width: 769px) {
    .sidebar-overlay {
        display: none;
    }

    .mobile-toggle-btn {
        display: none;
    }

    .mobile-close-btn {
        display: none;
    }
}

/* Top Navigation Bar */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px; /* Reduced padding */
    background-color: var(--surface-color); /* Match the sidebar background */
    border-bottom: 1px solid var(--border-color);
}

.nav-left {
    display: flex;
    gap: 10px;
}

.nav-right {
    position: relative;
}

/* Dropdown Button */
.dropdown-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 6px 12px; /* Reduced padding */
    border-radius: 4px;
    border: none;
    cursor: pointer;
    display: block; /* Ensure the button is always visible */
}

.dropdown-content {
    display: none;
    position: absolute;
    right: inherit;
    background-color: white;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
    border-radius: 5px;
    overflow: hidden;
}

.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
}

.dropdown-content a:hover {
    background-color: #f1f1f1;
}

/* Hide the hamburger menu by default */
.hamburger-menu {
    display: none; /* Hide the button by default */
}

/* Show the hamburger menu on smaller screens */
@media (max-width: 768px) {
    .hamburger-menu {
        display: block; /* Show the button */
    }
}
