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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.5;
    color: #343541;
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow-x: hidden;
    min-width: 768px; /* Minimum width to ensure UI elements don't collapse */
}

/* Sidebar styles */
.sidebar {
    width: 260px;
    background: #f5f5f5;  /* Light marble white */
    color: #333333;  /* Darker text for contrast */
    padding: 10px;
    display: flex;
    flex-direction: column;
    position: relative;
    min-width: 200px;
    max-width: 260px;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.logo {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 20px 0 20px;
}

.logo img {
    width: 40px;
    height: auto;
}

.logo h1 {
    font-size: 1.2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.manual-link {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2b63d9;
    font-size: 1.2rem;
    margin-left: 0.5rem;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.manual-link:hover {
    background-color: rgba(43, 99, 217, 0.1);
    transform: scale(1.1);
}

.new-chat {
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    padding: 10px;
    margin-bottom: 20px;
    cursor: pointer;
    transition: background-color 0.2s;
    color: #333333;
}

.new-chat:hover {
    background-color: #e8e8e8;
}

.chat-history {
    overflow-y: auto;
    max-height: calc(100vh - 180px);
    margin-top: 20px;
    padding: 0 10px;
}

/* Main content styles */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 20px;
    max-width: 1500px;
    margin: 0 auto;
    width: 60%;
    min-width: 300px;
    overflow-x: hidden;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    width: 100%;
}

/* Message Styles */
.message {
    padding: 15px;
    margin: 10px;
    border-radius: 20px;
    max-width: 80%;
    word-wrap: break-word;
    position: relative;
    padding-right: 15px; /* Reduced from 40px */
}

.user-message {
    background-color: #ebebeb;
    color: rgb(0, 0, 0);
    margin-left: auto;
    margin-right: 0;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    border-bottom-left-radius: 20px;
    width: auto; /* Let width be determined by content */
    max-width: 80%; /* Maintain maximum width constraint */
    text-align: left;
    float: right;
    clear: both;
    /* white-space: pre-wrap; */
}

.assistant-message {
    /* background-color: #ff0000; */
    background-color: #ffffff;
    color: rgb(0, 0, 0);
    margin-right: auto;
    margin-left: 0;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    border-bottom-right-radius: 20px;
    width: 100%;
    float: left; /* Float to left side */
    clear: both; /* Ensure proper stacking */
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 10px;
    margin-bottom: 10px;
}

.typing-indicator span {
    height: 8px;
    width: 8px;
    float: left;
    margin: 0 1px;
    background-color: #9E9E9E;
    display: block;
    border-radius: 50%;
    opacity: 0.4;
}

.typing-indicator span:nth-of-type(1) {
    animation: 1s blink infinite 0.3333s;
}

.typing-indicator span:nth-of-type(2) {
    animation: 1s blink infinite 0.6666s;
}

.typing-indicator span:nth-of-type(3) {
    animation: 1s blink infinite 0.9999s;
}

@keyframes blink {
    50% {
        opacity: 1;
    }
}

/* Search indicator styles */
.search-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    font-size: 14px;
    color: #666;
    font-style: italic;
}

.search-indicator-text {
    animation: searchPulse 1.5s ease-in-out infinite;
}

@keyframes searchPulse {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

/* Code block styling */
pre {
    position: relative;
    background-color: #f8f8f8;
    border-radius: 6px;
    margin: 1em 0;
    padding: 0;
    overflow: hidden;
}

code {
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    padding: 1em;
    display: block;
    overflow-x: auto;
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #e8e8e8;
    padding: 4px 10px;
    font-size: 0.8em;
    color: #666;
    border-bottom: 1px solid #ddd;
}

.code-language {
    text-transform: uppercase;
    font-weight: bold;
    font-size: 0.8em;
}

.code-block-copy-btn {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.code-block-copy-btn:hover {
    background-color: #d0d0d0;
    color: #333;
}

/* Message action buttons - repositioned to bottom of assistant messages */
.message-actions {
    display: flex;
    gap: 8px;
    position: relative;
    margin-top: 10px;
    opacity: 0;
    transition: opacity 0.2s ease;
    justify-content: flex-start;
}

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

/* Always show code block copy buttons */
.code-block-copy-btn {
    opacity: 0;
    transition: opacity 0.2s ease;
}

pre:hover .code-block-copy-btn {
    opacity: 1;
}

/* Markdown styling */
.assistant-message p {
    margin: 0.5rem 0;
    line-height: 1.5;
    white-space: pre-wrap;
}

.assistant-message h1,
.assistant-message h2,
.assistant-message h3 {
    margin: 1rem 0;
    line-height: 1.2;
}

.assistant-message ul,
.assistant-message ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.assistant-message li {
    margin: 0.25rem 0;
}

.assistant-message a {
    color: #7c7cff;
    text-decoration: none;
}

.assistant-message a:hover {
    text-decoration: underline;
}

.input-container {
    position: relative;
    padding: 20px;
    background-color: #ffffff;
    border-top: 1px solid #e5e5e5;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.input-box {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    /* background-color: #40414f; */
    background-color: #f5f5f5;
    border-radius: 20px;
    padding: 8px;
    min-height: 44px;
    transition: all 0.3s ease; /* Smooth transitions */
}

.input-box textarea {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 5px;
    resize: none;
    min-height: 24px;
    max-height: 200px;
    transition: height 0.1s ease-out, width 0.3s ease;
    overflow-y: auto;
    line-height: 1.5;
    font-size: 14px;
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

.input-box.typing-mode {
    background-color: #f0f8ff; /* Subtle background change when typing */
}

.input-box.typing-mode textarea {
    /* Slightly expand when controls are hidden */
    padding-left: 15px;
}

/* Webkit scrollbar styling */
.input-box textarea::-webkit-scrollbar {
    width: 6px;
}

.input-box textarea::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.input-box textarea::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.input-box textarea::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.input-box textarea::placeholder {
    color: #8e8ea0;
}

.send-button {
    background-color: #ff4444;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    height: 55px;
    width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.send-button:hover {
    background-color: #ff6666;
}

.attach-button {
    right: 45px;
    bottom: 10px;
}

.user-message img {
    border-radius: 0.5rem;
    margin: 0.5rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-link {
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
    color: #333333;
}

.nav-link:hover {
    background-color: #e8e8e8;
}

.nav-link.active {
    background-color: #e8e8e8;
    border-left: 3px solid #ff4444;
}

.nav-link i {
    width: 20px;
    text-align: center;
}

.bottom-links {
    padding: 0 15px;
    border-top: 1px solid #4d4d4f;
    margin-top: 20px;
    padding-top: 20px;
}

.logout {
    color: #8e8ea0;
}

.logout:hover {
    color: #ff4444;
    background-color: rgba(255, 68, 68, 0.1);
}

/* Login page styles */
.login-body {
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #1a1b1e;
    font-family: Arial, sans-serif;
    min-width: auto !important;
    width: 100%;
    overflow-x: auto;
}

.login-container {
    width: 100%;
    max-width: 520px;
    padding: 0 20px;
}

.login-box {
    background-color: #202123;
    padding: 40px 50px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

.login-logo {
    width: 60px;
    height: 60px;
    margin: 0 auto 15px;
    display: block;
    object-fit: contain;
}

.login-box h1 {
    color: #fff;
    font-size: 24px;
    margin-bottom: 30px;
    font-weight: normal;
    width: 100%;
    text-align: center;
}

.login-form {
    width: 100%;
    text-align: left;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    color: #8e8ea0;
    margin-bottom: 8px;
    font-size: 14px;
}

.login-form input {
    width: 100%;
    padding: 10px;
    border: none;
    background-color: #343541;
    border-radius: 5px;
    color: white;
    font-size: 16px;
    box-sizing: border-box;
}

.login-form input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 156, 128, 0.5);
}

.login-button {
    width: 100%;
    padding: 10px;
    background-color: #343541;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
    margin-top: 10px;
}

.login-button:hover {
    background-color: #40414f;
}

.register-link {
    text-align: center;
    margin-top: 20px;
    color: #8e8ea0;
    font-size: 14px;
}

.register-link a {
    color: #10a37f;
    text-decoration: none;
}

.register-link a:hover {
    text-decoration: underline;
}

.alert {
    background-color: #ff4444;
    color: white;
    padding: 12px;
    border-radius: 5px;
    margin: 15px 0;
    text-align: center;
    font-size: 14px;
}

.flash-messages {
    margin-bottom: 20px;
}

.flash-message {
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 5px;
    background-color: #f8d7da;
    color: #721c24;
    text-align: center;
    font-size: 14px;
}

.flash-message.success {
    background-color: #d4edda;
    color: #155724;
}

/* Add these animation styles */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Add page transition container */
.page-transition {
    width: 100%;
    animation: fadeIn 0.3s ease-in;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* User info styles */
.user-info {
    position: absolute;
    bottom: 20px;
    left: 20px;
    padding: 10px;
    color: #333333;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 180px;
}

.username {
    /* font-size: 14px;
    font-weight: 500; */
    font-size: 14px;
    color: #333333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.username::before {
    content: '\f007';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 12px;
}

/* Logout button styles */
.sidebar-footer {
    position: absolute;
    bottom: 20px;
    right: 20px;
    padding: 10px;
}

.logout-button {
    background-color: #ff4444;
    color: white;
    padding: 8px 16px;
    border-radius: 5px;
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s;
}

.logout-button:hover {
    background-color: #ff6666;
}

.chat-history-item {
    padding: 12px;
    margin: 8px;
    border-radius: 8px;
    background: #f5f5f5;
    cursor: pointer;
    transition: background 0.3s;
    font-size: 14px;
    color: #333333;
}

.chat-history-item:hover {
    background: #e8e8e8;
}

.chat-history-item.active {
    background: #e8e8e8;
    border-left: 3px solid #ff4444;
}

.chat-history small {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 4px;
}

/* Add these new styles at the top */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Update login-body to be more specific */
.login-body {
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #1a1b1e;
    font-family: Arial, sans-serif;
}

/* Add the transition to the login page as well */
.login-container {
    width: 100%;
    max-width: 520px;
    padding: 0 20px;
}

/* Add these new styles for the microphone button */
.mic-button {
    background: none;
    border: none;
    color: #8e8ea0;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    transition: color 0.3s ease;
    margin: 0 5px;
}

.mic-button:hover {
    color: #10a37f;
}

.mic-button.recording {
    color: #ff4444;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.chat-thread {
    position: relative;
    padding: 12px 15px;
    margin: 5px 0;
    cursor: pointer;
    color: #333333;  /* Changed from light to dark text */
    border-radius: 5px;
    transition: background-color 0.3s;
    border: 1px solid #f5f5f5;
    background-color: #f5f5f5;  /* Changed from dark to light background */
}

.chat-thread:hover {
    background-color: #e8e8e8;  /* Changed from dark to light hover */
    color: #333333;
    border-color: #d0d0d0;
}

.chat-thread.active {
    background-color: #e8e8e8;  /* Changed from dark to light active state */
    border-color: #d0d0d0;
    color: #333333;
}

.thread-actions {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    gap: 10px;
}

.chat-thread:hover .thread-actions {
    display: flex;
}

.thread-actions i {
    cursor: pointer;
    padding: 5px;
    color: #666666;  /* Changed to darker icon color */
    transition: color 0.2s;
}

.thread-actions i:hover {
    color: #007bff;  /* Keep blue for edit icon hover */
}

.thread-actions .fa-trash:hover {
    color: #dc3545;  /* Keep red for delete icon hover */
}

.chat-preview {
    font-size: 14px;
    color: #666666;  /* Changed to darker preview text */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-timestamp {
    font-size: 12px;
    color: #8e8ea0;
    margin-top: 4px;
}

.chat-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    color: #333333;  /* Changed to darker title text */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-preview-container {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background-color: #2a2b32;
    border-top: 1px solid #565869;
    padding: 15px;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
}

.image-preview-wrapper {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding: 5px;
    min-height: 100px;
}

.image-preview {
    position: relative;
    width: 150px;
    height: 150px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #565869;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.image-preview:hover img {
    transform: scale(1.05);
}

.remove-image {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background-color: #ff4444;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    padding: 0;
    line-height: 1;
    z-index: 1001;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.remove-image:hover {
    background-color: #ff6666;
    transform: scale(1.1);
}

/* Add these new styles */
.message-images {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.chat-image {
    max-width: 300px;
    max-height: 300px;
    margin: 5px;
    border-radius: 5px;
}

.mini-preview {
    display: flex;
    gap: 5px;
    margin: 0 5px;
    align-items: center;
    flex-wrap: wrap;
    max-height: 40px;
    overflow-y: auto;
}

.mini-preview img {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    object-fit: cover;
}

.mini-preview .count-badge {
    background-color: #ff4444;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 12px;
}

.math {
    background-color: #ffcccc; /* Light red background for formulas */
    padding: 10px; /* Padding around the formula */
    border-radius: 10px; /* Rounded corners for the formula box */
    font-family: 'Courier New', Courier, monospace; /* Monospace font for formulas */
    color: #000; /* Dark text color for formulas */
}

.assistant-message ul {
    padding-left: 20px; /* Indent the list */
    margin: 0; /* Remove default margin */
}

.assistant-message li {
    margin-bottom: 0.5rem; /* Space between list items */
}

.assistant-message a {
    color: #7c7cff;
    text-decoration: none;
}

.assistant-message a:hover {
    text-decoration: underline;
}

/* Sidebar Toggle Styles */
.sidebar.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    overflow: hidden !important;
    visibility: hidden !important;
    opacity: 0 !important;
    transition: all 0.3s ease !important;
}

.right-sidebar.collapsed {
    /* width: 0;
    overflow: hidden; */
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    overflow: hidden !important;
    visibility: hidden !important;
    opacity: 0 !important;
    transition: all 0.3s ease !important;
}

/* Toggle button styles */
.toggle-sidebar {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #e0e0e0;  /* Changed from #343541 to light gray */
    border: none;
    color: #333333;  /* Changed from white to dark gray */
    width: 24px;
    height: 48px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background-color 0.3s ease;
}

.toggle-sidebar:hover {
    background: #d0d0d0;  /* Changed from #40414f to lighter hover */
}

.toggle-left-sidebar {
    right: -24px;
    border-radius: 0 6px 6px 0;
}

.toggle-right-sidebar {
    left: -24px;
    border-radius: 6px 0 0 6px;
}

/* Collapsed sidebar toggle styles */
.sidebar-toggle-collapsed {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: #e0e0e0;  /* Changed to match regular toggle */
    border: none;
    color: #333333;  /* Changed to dark text */
    width: 24px;
    height: 48px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: background-color 0.3s ease;
}

.sidebar-toggle-collapsed:hover {
    background: #d0d0d0;  /* Changed hover state */
}

.left-toggle-collapsed {
    left: 0;
    border-radius: 0 6px 6px 0;
}

.right-toggle-collapsed {
    right: 0;
    border-radius: 6px 0 0 6px;
}

/* Arrow rotation styles */
.toggle-sidebar i,
.sidebar-toggle-collapsed i {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.toggle-left-sidebar i {
    transform: rotate(0deg);
}

.sidebar.collapsed .toggle-left-sidebar i,
.left-toggle-collapsed i {
    transform: rotate(180deg);
}

.toggle-right-sidebar i {
    transform: rotate(180deg);
}

.right-sidebar.collapsed .toggle-right-sidebar i,
.right-toggle-collapsed i {
    transform: rotate(0deg);
}

/* Right Sidebar specific styles */
.right-sidebar {
    width: 250px;
    background: #f5f5f5;
    color: #333333;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
}

.nav-links {
    flex: 1;
    padding: 10px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    text-decoration: none;
    color: #333333;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    margin-bottom: 10px;
    transition: background-color 0.2s;
}

.nav-link:hover {
    background-color: #e8e8e8;
}

.nav-link.active {
    background-color: #e8e8e8;
    border-left: 3px solid #ff4444;
}

.nav-link i {
    color: #333333;
}

.bottom-links {
    padding: 10px;
    border-top: 1px solid #e0e0e0;
    margin-top: auto;
}

.nav-link.logout {
    color: #ff4444;
    margin-bottom: 0;
}

.nav-link.logout:hover {
    background-color: #fff0f0;
}

/* Voice Chat Input Styles */
.input-box.voice-input {
    flex: 1;
    display: flex;
    align-items: center;
    background-color: #f5f5f5;
    border-radius: 8px;
    padding: 8px;
    min-height: 44px;
}

.input-box.voice-input textarea {
    flex: 1;
    padding: 10px;
    font-size: 16px;
    background: transparent;
    color: #000000;
    border: none;
    outline: none;
    resize: none;
    max-height: 200px;
    overflow-y: auto;
    line-height: 20px;
}

.input-box.voice-input textarea::placeholder {
    color: #8e8ea0;
}

.mic-button {
    background: none;
    border: none;
    color: #666666;
    font-size: 20px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.mic-button:hover {
    background-color: #f0f0f0;
}

.mic-button.recording {
    color: #ff4444;
}

.math-inline {
    font-family: 'Courier New', Courier, monospace;
    background-color: #f8f8f8;
    padding: 2px 6px;
    border-radius: 4px;
    color: #333333;
    display: inline-block;
    margin: 0 2px;
}

.math-block {
    background-color: #f8f8f8;
    padding: 10px;
    border-radius: 8px;
    font-family: 'Courier New', Courier, monospace;
    color: #333333;
    margin: 10px 0;
    overflow-x: auto;
}

/* Add this after the existing styles */
.floating-button {
    position: fixed;  /* Changed from absolute to fixed */
    background-color: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    z-index: 1000;
}

.floating-button:hover {
    background-color: #ff6666;
    transform: scale(1.1);
}

.floating-button.visible {
    display: flex;
}

.floating-button i {
    font-size: 12px;
}

.confirmation-button {
    background-color: #4CAF50;
    position: fixed;  /* Added position fixed */
    margin-left: 8px;
}

.confirmation-button:hover {
    background-color: #45a049;
}

.rejection-button {
    background-color: #f44336;
    position: fixed;  /* Added position fixed */
    margin-left: 16px;
}

.rejection-button:hover {
    background-color: #da190b;
}

/* Media queries for different screen sizes */
@media (max-width: 1200px) {
    .sidebar, .right-sidebar {
        width: 220px;
    }
}

@media (max-width: 992px) {
    .sidebar, .right-sidebar {
        width: 200px;
    }
}

/* For very small screens, collapse sidebars by default */
@media (max-width: 768px) {
    .sidebar:not(.collapsed), .right-sidebar:not(.collapsed) {
        width: 200px;
    }
    
    .sidebar.collapsed, .right-sidebar.collapsed {
        width: 0;
    }
    
    #leftSidebarToggleCollapsed, #rightSidebarToggleCollapsed {
        display: flex !important;
    }
}

/* Ensure the toggle buttons are always accessible */
.toggle-sidebar {
    z-index: 100;
}

/* Fix for right sidebar toggle button positioning */
.toggle-right-sidebar {
    left: -24px;
    z-index: 100;
}

/* Message action buttons - repositioned to bottom of assistant messages */
.message-actions {
    display: flex;
    gap: 8px;
    position: relative;
    margin-top: 10px;
    opacity: 0;
    transition: opacity 0.2s ease;
    justify-content: flex-start;
}

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

/* Remove this rule to prevent buttons from showing on user messages */
.user-message .message-actions {
    display: none;
}

.message-action-btn {
    background-color: #f0f0f0;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    color: #666666;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.message-action-btn:hover {
    background-color: #e0e0e0;
    color: #333333;
}

.copy-btn:hover {
    color: #007bff;
}

.sound-btn:hover {
    color: #28a745;
}

.code-btn:hover {
    color: #6c757d;
}

/* Toast notification */
#toast-notification {
    visibility: hidden;
    min-width: 250px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 4px;
    padding: 12px;
    position: fixed;
    z-index: 1000;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
}

#toast-notification.show {
    visibility: visible;
    opacity: 0.9;
}

/* Deep research toggle styles */
.deep-research-toggle {
    display: flex;
    align-items: center;
    margin-top: 8px;
    gap: 10px;
}

.toggle-label {
    font-size: 12px;
    color: #666666;
}

/* Toggle switch */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: #ff4444;
}

input:focus + .slider {
    box-shadow: 0 0 1px #ff4444;
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

.website-link {
    margin-top: auto;
    margin-bottom: 10px;
    padding: 0 15px;
}

.external-link {
    background-color: #4CAF50;
    color: white !important;
    border-radius: 5px;
    padding: 10px !important;
    text-align: center;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.external-link:hover {
    background-color: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.external-link i {
    margin-right: 8px;
}

/* Password visibility toggle styles */
.password-container {
    position: relative;
    width: 100%;
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    user-select: none;
    color: #8e8ea0;
    font-size: 16px;
    z-index: 10;
}

.toggle-password:hover {
    color: #fff;
}

/* Select dropdown styling to match dark theme */
.login-form select {
    width: 100%;
    padding: 10px;
    border: none;
    background-color: #343541;
    border-radius: 5px;
    color: white;
    font-size: 16px;
    box-sizing: border-box;
    appearance: auto; /* Ensures the dropdown arrow appears */
}

.login-form select:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 156, 128, 0.5);
}

.login-form select option {
    background-color: #343541;
    color: white;
}

/* Additional styling for the placeholder option */
.login-form select option[disabled] {
    color: #8e8ea0;
}

/* Add this to the end of your CSS file */
@media (max-width: 576px) {
    .login-container {
        width: 100%;
        max-width: 100%;
        padding: 0 15px;
    }
    
    .login-box {
        padding: 30px 25px;
    }
}

@media (max-height: 700px) {
    .login-box {
        padding: 25px 30px;
    }
    
    .login-form .form-group {
        margin-bottom: 15px;
    }
}

/* Fix for high zoom levels */
@media (max-width: 380px) {
    .login-box {
        padding: 20px 15px;
    }
}

/* Improve scrolling behavior on small screens */
@media (max-width: 576px) {
    .login-body {
        height: auto;
        min-height: 100vh;
    }
    
    .login-box {
        margin: 20px 0;
    }
}

/* Add scroll capability for very small screens */
@media (max-height: 600px) {
    .login-body {
        align-items: flex-start;
        overflow-y: auto;
        padding: 20px 0;
    }
    
    .login-container {
        margin: 20px 0;
    }
}

/* Ensure form elements have proper spacing */
.login-form .form-group:last-of-type {
    margin-bottom: 25px;
}

/* Override conflicting styles that might be causing issues */
.login-body {
    display: flex !important;
    overflow-y: auto !important;
}

/* Ensure consistent rendering across different browser zoom levels */
@media (max-width: 767px) {
    body.login-body {
        min-width: 0 !important;
    }
}

/* Completely revised dropdown styling */
.nav-link.dropdown {
    display: block;
    padding: 0;
    overflow: visible;
    position: relative;
    margin-bottom: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    background-color: #f5f5f5;
}

.dropdown-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    cursor: pointer;
    color: #333333;
    transition: background-color 0.2s;
}

.dropdown-header:hover {
    background-color: #e8e8e8;
}

.dropdown-menu {
    display: none;
    width: 100%;
    background-color: #f5f5f5;
    border-top: 1px solid #e0e0e0;
}

.nav-link.dropdown.open .dropdown-menu {
    display: block;
}

.dropdown-item {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 12px 12px 12px 32px !important;
    text-decoration: none !important;
    color: #333333 !important;
    background-color: #f5f5f5 !important;
    border: none !important;
    border-top: 1px solid #e0e0e0 !important;
    margin: 0 !important;
    transition: background-color 0.2s !important;
}

.dropdown-item:hover {
    background-color: #e8e8e8 !important;
}

.dropdown-item.active {
    background-color: #e8e8e8 !important;
    border-left: 3px solid #ff4444 !important;
}

.dropdown-icon {
    margin-left: auto;
    transition: transform 0.3s ease;
}

.nav-link.dropdown.open .dropdown-icon {
    transform: rotate(180deg);
}

.model-selector {
    position: relative;
    margin-right: 10px;
}

.model-selector select {
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 12px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='black' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 5px center;
    background-size: 16px;
    padding-right: 25px;
}

.model-selector select:hover {
    background-color: #e9e9e9;
}

/* Title placeholder styling for animation */
.title-placeholder {
    display: inline-block;
    position: relative;
    font-weight: 500;
    color: #333;
}

.title-placeholder.typing {
    border-right: 2px solid #ff4444;
    padding-right: 2px;
    animation: typing-cursor 0.7s step-end infinite;
}

@keyframes typing-cursor {
    from, to { border-color: transparent; }
    50% { border-color: #ff4444; }
}

/* User message action buttons */
.user-message-actions {
    display: flex;
    gap: 8px;
    position: absolute;
    right: 0;
    bottom: -30px; /* Position below the message bubble */
    opacity: 0;
    transition: opacity 0.2s ease;
    justify-content: flex-end;
}

.user-message {
    position: relative; /* Ensure position is relative for absolute positioning of buttons */
    margin-bottom: 35px; /* Add space below message for the buttons */
}

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

.edit-btn:hover {
    color: #ff4444; /* Red color for edit button */
}

/* Input controls disappearing effect */
.input-control {
    transition: all 0.3s ease;
    opacity: 1;
    transform: scale(1);
    max-width: 100px;
    overflow: hidden;
}

.input-control.hidden {
    opacity: 0;
    transform: scale(0.8);
    max-width: 0;
    margin: 0;
    padding: 0;
}

.input-control.hidden * {
    opacity: 0;
    pointer-events: none;
}

/* Mobile input controls */
.mobile-device .input-control {
    transition: all 0.3s ease !important;
    opacity: 1 !important;
    transform: scale(1) !important;
    max-width: 50px !important;
    overflow: hidden !important;
}

.mobile-device .input-control.hidden {
    opacity: 0 !important;
    transform: scale(0.8) !important;
    max-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.mobile-device .input-control.hidden * {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Hide individual model selector and upload button on mobile */
.mobile-device .model-selector,
.mobile-device .upload-button,
.mobile-device #modelSelectorControl,
.mobile-device #uploadButtonControl {
    display: none !important;
}

/* Hide input options button on desktop */
.input-options-button {
    display: none !important;
}

/* Combined input options button for mobile */
.mobile-device .input-options-button {
    display: flex !important;
    padding: 8px !important;
    font-size: 18px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    border-radius: 6px !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    background: none !important;
    border: none !important;
    color: #666666 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    position: relative !important;
    z-index: 100 !important;
}

.mobile-device .input-options-button:hover {
    background-color: #f0f0f0 !important;
    color: #333333 !important;
}

.mobile-device .input-options-button:active {
    background-color: #e0e0e0 !important;
    transform: scale(0.95) !important;
}

/* Hide mobile-specific popups on desktop */
.input-options-popup,
.model-selection-popup,
.model-selection-overlay {
    display: none !important;
}

/* Input options popup for mobile */
.mobile-device .input-options-popup {
    position: fixed !important;
    bottom: 180px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background-color: #ffffff !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15) !important;
    z-index: 1500 !important;
    min-width: 220px !important;
    max-width: 90vw !important;
    padding: 12px !important;
    display: none !important;
    transform-origin: bottom center !important;
    animation: inputOptionsPopupFadeIn 0.2s ease-out !important;
    margin-bottom: 8px !important;
}

.mobile-device .input-options-popup.show {
    display: flex !important;
    gap: 16px !important;
    transform: translateX(-50%) !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Input option items in popup */
.mobile-device .input-options-item {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 3px !important;
    padding: 8px 8px !important;
    border-radius: 6px !important;
    background-color: transparent !important;
    border: none !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    min-height: 55px !important;
    justify-content: center !important;
}

.mobile-device .input-options-item:hover {
    background-color: rgba(0,0,0,0.05) !important;
    border-radius: 6px !important;
    transform: translateY(-1px) !important;
}

.mobile-device .input-options-item:active {
    background-color: #dee2e6 !important;
    transform: translateY(0) !important;
}

.mobile-device .input-options-item i {
    font-size: 18px !important;
    color: #495057 !important;
    margin-bottom: 1px !important;
}

.mobile-device .input-options-item span {
    font-size: 12px !important;
    color: #495057 !important;
    font-weight: 500 !important;
    text-align: center !important;
    line-height: 1.1 !important;
}

/* Model selector text in popup */
.mobile-device .input-options-item.model-item .model-text {
    background: none !important;
    border: none !important;
    color: #495057 !important;
    font-size: 13px !important;
    text-align: center !important;
    cursor: pointer !important;
    outline: none !important;
    font-weight: 600 !important;
    margin-top: -2px !important;
    user-select: none !important;
}

/* Remove dropdown arrow - clean design */
.mobile-device .input-options-item.model-item {
    position: relative !important;
}

/* Model selection popup - mobile only */
.mobile-device .model-selection-popup {
    position: fixed !important;
    bottom: 200px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background-color: #ffffff !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 12px !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15) !important;
    z-index: 2000 !important;
    min-width: 200px !important;
    max-width: 90vw !important;
    padding: 8px 0 !important;
    display: none !important;
    flex-direction: column !important;
}

.mobile-device .model-selection-popup.show {
    display: flex !important;
    animation: modelPopupFadeIn 0.2s ease-out !important;
}

.mobile-device .model-option {
    display: flex !important;
    align-items: center !important;
    padding: 12px 16px !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease !important;
    border: none !important;
    background: none !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: #333333 !important;
    text-align: left !important;
    width: 100% !important;
}

.mobile-device .model-option:hover {
    background-color: #f5f5f5 !important;
}

.mobile-device .model-option.selected {
    background-color: #e3f2fd !important;
    color: #1976d2 !important;
    font-weight: 600 !important;
}

.mobile-device .model-option:first-child {
    border-radius: 12px 12px 0 0 !important;
}

.mobile-device .model-option:last-child {
    border-radius: 0 0 12px 12px !important;
}

/* Popup animation */
@keyframes inputOptionsPopupFadeIn {
    0% {
        opacity: 0;
        transform: translateX(-50%) scale(0.9) translateY(4px);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) scale(1) translateY(0);
    }
}

@keyframes modelPopupFadeIn {
    0% {
        opacity: 0;
        transform: translateX(-50%) scale(0.95) translateY(8px);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) scale(1) translateY(0);
    }
}

/* Input options overlay for closing */
.mobile-device .input-options-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: transparent !important;
    z-index: 999 !important;
    display: none !important;
}

.mobile-device .input-options-overlay.active {
    display: block !important;
}

/* Model selection overlay */
.mobile-device .model-selection-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.3) !important;
    z-index: 1999 !important;
    display: none !important;
}

.mobile-device .model-selection-overlay.active {
    display: block !important;
}

/* ========================================
   IMMEDIATE MOBILE DETECTION STYLES
   Applied to html element before body loads
   ======================================== */

/* Apply mobile styles to html element immediately */
html.mobile-device {
    /* Ensure proper initial scaling */
    -webkit-text-size-adjust: 100% !important;
    -moz-text-size-adjust: 100% !important;
    -ms-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
    
    /* Prevent horizontal scrolling */
    overflow-x: hidden !important;
    
    /* Ensure full height usage */
    height: 100% !important;
}

html.mobile-device body {
    /* Immediate mobile body styles */
    overflow-x: hidden !important;
    min-width: auto !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    
    /* Prevent zoom on double tap */
    touch-action: manipulation !important;
}

/* Hide desktop elements immediately on mobile */
html.mobile-device .sidebar,
html.mobile-device .right-sidebar {
    display: none !important;
}

html.mobile-device .main-content {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Show mobile elements immediately */
html.mobile-device .mobile-header,
html.mobile-device .mobile-bottom-nav {
    display: flex !important;
}

/* ========================================
   MOBILE-SPECIFIC STYLES
   Only applied when .mobile-device class is present
   Desktop styles remain completely unchanged
   ======================================== */

/* Mobile Device Detection Styles - Apply to mobile-device class regardless of screen size */
.mobile-device .sidebar,
.mobile-device .right-sidebar {
    position: fixed !important;
    top: 0 !important;
    height: 100vh !important;
    z-index: 2000 !important;
    transition: transform 0.3s ease !important;
    width: 280px !important;
    max-width: 80vw !important;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1) !important;
    display: flex !important; /* Ensure flex display for proper layout */
    flex-direction: column !important;
}

/* Left sidebar - starts off-screen to the left */
.mobile-device .sidebar {
    left: 0 !important;
    transform: translateX(-100%) !important;
    background-color: #ffffff !important;
    border-right: 1px solid #e0e0e0 !important;
    box-shadow: 2px 0 15px rgba(0,0,0,0.15) !important;
    opacity: 1 !important; /* Ensure opacity is always 1 */
    visibility: visible !important; /* Ensure visibility is always visible */
}

/* Right sidebar - starts off-screen to the right */
.mobile-device .right-sidebar {
    right: 0 !important;
    left: auto !important;
    transform: translateX(100%) !important;
    background-color: #ffffff !important;
    border-left: 1px solid #e0e0e0 !important;
    box-shadow: -2px 0 15px rgba(0,0,0,0.15) !important;
    opacity: 1 !important; /* Ensure opacity is always 1 */
    visibility: visible !important; /* Ensure visibility is always visible */
}

/* Mobile sidebar open states */
.mobile-device .sidebar.mobile-open {
    transform: translateX(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.mobile-device .right-sidebar.mobile-open {
    transform: translateX(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Mobile overlay for when sidebars are open */
.mobile-device .mobile-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    z-index: 1500 !important;
    display: none !important;
    pointer-events: auto !important;
    touch-action: none !important; /* Prevent scrolling behind overlay */
}

.mobile-device .mobile-overlay.active {
    display: block !important;
}

/* Mobile main content - full width */
.mobile-device .main-content {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    height: 100vh !important;
    position: relative !important;
    background-color: #ffffff !important;
    display: block !important; /* Override desktop flex */
    flex: none !important; /* Override desktop flex: 1 */
    flex-direction: initial !important; /* Override desktop flex-direction */
}

/* Mobile chat container */
.mobile-device .chat-container {
    position: fixed !important; /* Use fixed positioning relative to viewport */
    top: 50px !important; /* Below mobile header */
    bottom: 150px !important; /* Above input container + bottom nav */
    left: 0 !important;
    right: 0 !important;
    padding: 10px 15px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    background-color: #ffffff !important;
    display: block !important; /* Override flex display */
    flex: none !important; /* Override desktop flex: 1 */
    width: auto !important; /* Override desktop width */
    height: auto !important; /* Let positioning handle height */
    box-sizing: border-box !important; /* Ensure padding is included in dimensions */
    z-index: 1 !important; /* Ensure it's below input container */
}
/* Mobile messages optimization */
.mobile-device .message {
    max-width: 85% !important;
    margin: 8px 10px !important;
    padding: 12px 15px !important;
    font-size: 16px !important; /* Prevent zoom on iOS */
    line-height: 1.4 !important;
}

.mobile-device .user-message {
    margin-left: 15% !important;
    margin-right: 10px !important;
}

.mobile-device .assistant-message {
    margin-left: 10px !important;
    margin-right: 15% !important;
}

/* Mobile input container */
.mobile-device .input-container {
    position: fixed !important;
    bottom: 60px !important; /* Above mobile bottom nav */
    left: 0 !important;
    right: 0 !important;
    padding: 15px !important;
    background-color: #ffffff !important;
    border-top: 1px solid #e5e5e5 !important;
    z-index: 1000 !important;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1) !important;
    min-height: 80px !important; /* Set minimum height for input container */
    max-height: 200px !important; /* Prevent container from getting too tall */
    display: flex !important;
    align-items: flex-end !important; /* Align to bottom for better button positioning */
    gap: 10px !important; /* Add gap between input box and send button */
    flex-wrap: nowrap !important; /* Prevent wrapping */
}

/* Mobile input box optimization */
.mobile-device .input-box {
    background-color: #f5f5f5 !important;
    border-radius: 25px !important;
    padding: 8px 12px !important;
    min-height: 50px !important;
    gap: 8px !important;
    display: flex !important;
    align-items: center !important;
    flex: 1 !important; /* Take up remaining space */
    flex-wrap: nowrap !important; /* Prevent wrapping */
    overflow: hidden !important; /* Hide overflow */
    transition: all 0.3s ease !important; /* Smooth transitions */
}

/* Mobile typing mode */
.mobile-device .input-box.typing-mode {
    background-color: #e8f4fd !important; /* Subtle background change when typing on mobile */
    border-radius: 20px !important; /* Slightly reduce border radius when typing */
}

.mobile-device .input-box.typing-mode textarea {
    padding-left: 15px !important; /* Give more space when controls are hidden */
}

.mobile-device .input-box textarea {
    font-size: 16px !important; /* Prevent zoom on iOS */
    padding: 8px 12px !important;
    border-radius: 15px !important;
    min-height: 20px !important;
    max-height: 120px !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    resize: none !important;
    flex: 1 !important;
    line-height: 1.4 !important;
    font-family: inherit !important;
}

/* Mobile send button */
.mobile-device .send-button {
    width: 50px !important;
    height: 50px !important;
    border-radius: 25px !important;
    font-size: 18px !important;
    flex-shrink: 0 !important;
    margin-left: 0 !important; /* Remove margin since we have gap on container */
    align-self: flex-end !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: #ff4444 !important;
    color: white !important;
    border: none !important;
    cursor: pointer !important;
    transition: background-color 0.3s ease !important;
}

.mobile-device .send-button:hover {
    background-color: #ff6666 !important;
}

/* Mobile action buttons - larger touch targets */
.mobile-device .message-action-btn {
    width: 36px !important;
    height: 36px !important;
    font-size: 16px !important;
}

.mobile-device .mic-button,
.mobile-device .upload-button {
    padding: 8px !important;
    font-size: 18px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    background: none !important;
    border: none !important;
    color: #666666 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

.mobile-device .mic-button:hover,
.mobile-device .upload-button:hover {
    background-color: #f0f0f0 !important;
    color: #333333 !important;
}

.mobile-device .mic-button.recording {
    color: #ff4444 !important;
    animation: pulse 1.5s infinite !important;
}

/* Mobile upload button label styling */
.mobile-device .upload-button {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 8px !important;
    text-decoration: none !important;
}

.mobile-device .upload-button i {
    font-size: 18px !important;
    pointer-events: none !important;
}

/* Mobile model selector */
.mobile-device .model-selector {
    display: flex !important;
    align-items: center !important;
    flex-shrink: 0 !important;
    margin-right: 5px !important;
}

.mobile-device .model-selector select {
    padding: 6px 10px !important;
    font-size: 12px !important;
    min-height: 32px !important;
    border-radius: 16px !important;
    background-color: #f5f5f5 !important;
    border: 1px solid #ddd !important;
    cursor: pointer !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    background-image: url("data:image/svg+xml;utf8,<svg fill='black' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: right 5px center !important;
    background-size: 12px !important;
    padding-right: 20px !important;
}

.mobile-device .model-selector select:hover {
    background-color: #e9e9e9 !important;
}

/* Mobile image preview */
.mobile-device .image-preview-container {
    bottom: 130px !important; /* Above input and bottom nav */
    left: 10px !important;
    right: 10px !important;
    padding: 10px !important;
}

.mobile-device .image-preview {
    width: 100px !important;
    height: 100px !important;
}

/* Mobile floating buttons */
.mobile-device .floating-button {
    width: 40px !important;
    height: 40px !important;
    font-size: 16px !important;
}

/* Mobile toast notifications */
.mobile-device #toast-notification {
    bottom: 80px !important; /* Above bottom nav */
    left: 20px !important;
    right: 20px !important;
    transform: none !important;
}

/* Hide desktop toggle buttons on mobile */
.mobile-device .toggle-sidebar,
.mobile-device .sidebar-toggle-collapsed,
.mobile-device .toggle-left-sidebar,
.mobile-device .toggle-right-sidebar,
.mobile-device .left-toggle-collapsed,
.mobile-device .right-toggle-collapsed,
.mobile-device #leftSidebarToggleCollapsed,
.mobile-device #rightSidebarToggleCollapsed {
    display: none !important;
    visibility: hidden !important;
}

/* Mobile code blocks */
.mobile-device pre {
    font-size: 14px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

.mobile-device .code-block-copy-btn {
    padding: 8px !important;
    font-size: 14px !important;
}

/* Hide mobile elements on desktop by default */
.mobile-header,
.mobile-bottom-nav,
.mobile-overlay {
    display: none !important;
}

/* Mobile Bottom Navigation - Only show on mobile devices */
.mobile-device .mobile-bottom-nav {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 60px !important;
    background-color: #f5f5f5 !important;
    border-top: 1px solid #e0e0e0 !important;
    display: flex !important;
    justify-content: space-around !important; /* Changed from center to space-around for better distribution */
    align-items: center !important;
    padding: 0 20px !important; /* Added padding for better spacing */
    z-index: 1000 !important;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1) !important;
}

/* Mobile Header - Only show on mobile devices */
.mobile-device .mobile-header {
    display: flex !important;
}

/* Mobile Overlay - Only show on mobile devices when needed */
.mobile-device .mobile-overlay {
    display: none !important;
}

.mobile-device .mobile-overlay.active {
    display: block !important;
}

.mobile-device .mobile-nav-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 4px 8px !important; /* Reduced padding to fit three items */
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    border-radius: 8px !important; /* Reduced border radius */
    min-width: 55px !important; /* Reduced from 65px to fit three items */
    min-height: 40px !important; /* Reduced from 42px */
    text-decoration: none !important;
    color: #666666 !important;
    background-color: transparent !important;
    flex: 1 !important; /* Allow items to grow equally */
    max-width: 100px !important; /* Prevent items from getting too wide */
}

.mobile-device .mobile-nav-item:hover,
.mobile-device .mobile-nav-item.active {
    background-color: #ff4444 !important;
    color: #ffffff !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(255, 68, 68, 0.3) !important;
}

.mobile-device .mobile-nav-item i {
    font-size: 16px !important; /* Reduced from 18px to fit three items */
    margin-bottom: 2px !important; /* Reduced from 3px */
}

.mobile-device .mobile-nav-item span {
    font-size: 10px !important; /* Reduced from 11px to fit three items */
    text-align: center !important;
    font-weight: 500 !important;
    white-space: nowrap !important; /* Prevent text wrapping */
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
}

/* Mobile Header with Menu Button */
.mobile-device .mobile-header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 50px !important;
    background-color: #ffffff !important;
    border-bottom: 1px solid #e0e0e0 !important;
    display: flex !important;
    align-items: center !important;
    padding: 0 15px !important;
    z-index: 2100 !important; /* Higher than sidebars to ensure buttons are clickable */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
}

.mobile-device .mobile-menu-button,
.mobile-device .mobile-nav-button {
    background: none !important;
    border: none !important;
    font-size: 20px !important;
    color: #333333 !important;
    padding: 10px !important;
    cursor: pointer !important;
    border-radius: 5px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 2001 !important; /* Ensure buttons are clickable above everything */
    position: relative !important; /* Ensure proper positioning context */
}

.mobile-device .mobile-menu-button:hover,
.mobile-device .mobile-nav-button:hover {
    background-color: #f0f0f0 !important;
}

.mobile-device .mobile-header-title {
    font-size: 18px !important;
    font-weight: 600 !important;
    color: #333333 !important;
    flex: 1 !important;
    text-align: center !important;
    margin-left: -44px !important; /* Offset the menu button width to center title */
}

/* Mobile-specific user info in sidebar */
.mobile-device .user-info {
    padding: 15px !important;
    border-top: 1px solid #e0e0e0 !important;
    background-color: #fafafa !important;
}

/* Mobile sidebar navigation links */
.mobile-device .nav-links {
    padding: 20px 15px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

.mobile-device .nav-link {
    margin-bottom: 8px !important;
    padding: 15px 12px !important;
    font-size: 16px !important;
    border-radius: 8px !important;
    min-height: 50px !important;
    display: flex !important;
    align-items: center !important;
}

.mobile-device .nav-link i {
    font-size: 18px !important;
    margin-right: 12px !important;
    width: 20px !important;
    text-align: center !important;
}

/* Mobile sidebar logo and header */
.mobile-device .logo {
    padding: 20px 15px 15px !important;
    border-bottom: 1px solid #f0f0f0 !important;
    margin-bottom: 10px !important;
}

.mobile-device .logo h1 {
    font-size: 20px !important;
    margin-left: 10px !important;
}

/* Mobile new chat button */
.mobile-device .new-chat {
    margin: 10px 15px 20px !important;
    padding: 15px !important;
    font-size: 16px !important;
    border-radius: 8px !important;
    min-height: 50px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: #f5f5f5 !important;
    border: 1px solid #e0e0e0 !important;
    color: #333333 !important;
    cursor: pointer !important;
    transition: background-color 0.2s !important;
}

.mobile-device .new-chat:hover {
    background-color: #e8e8e8 !important;
}

/* Mobile chat history container */
.mobile-device .chat-history {
    flex: 1 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 0 15px !important;
    margin: 10px 0 !important;
    max-height: none !important; /* Remove max-height restriction */
}

/* Mobile chat thread styling */
.mobile-device .chat-thread {
    margin: 8px 0 !important;
    padding: 15px !important;
    border-radius: 8px !important;
    background-color: #f5f5f5 !important;
    border: 1px solid #e0e0e0 !important;
    cursor: pointer !important;
    transition: background-color 0.3s !important;
    min-height: 60px !important;
    display: flex !important;
    flex-direction: column !important;
    position: relative !important;
}

.mobile-device .chat-thread:hover {
    background-color: #e8e8e8 !important;
}

.mobile-device .chat-thread.active {
    background-color: #e8e8e8 !important;
    border-color: #ff4444 !important;
    border-left: 4px solid #ff4444 !important;
}

.mobile-device .chat-title {
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #333333 !important;
    margin-bottom: 5px !important;
    line-height: 1.2 !important;
    padding-right: 40px !important; /* Add space for 3-dot button */
}

.mobile-device .chat-timestamp {
    font-size: 12px !important;
    color: #8e8ea0 !important;
    margin-top: 5px !important;
}

/* Hide old thread actions on mobile */
.mobile-device .thread-actions {
    display: none !important;
}

/* New 3-dot menu button for mobile */
.mobile-device .thread-menu-button {
    position: absolute !important;
    right: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 32px !important;
    height: 32px !important;
    border: none !important;
    background: none !important;
    color: #666666 !important;
    font-size: 16px !important;
    cursor: pointer !important;
    border-radius: 6px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
    z-index: 10 !important;
}

.mobile-device .thread-menu-button:hover {
    background-color: #e0e0e0 !important;
    color: #333333 !important;
}

.mobile-device .thread-menu-button:active {
    background-color: #d0d0d0 !important;
    transform: translateY(-50%) scale(0.95) !important;
}

/* Mobile thread popup menu */
.mobile-device .thread-popup-menu {
    position: absolute !important;
    right: 8px !important;
    top: 40px !important;
    background-color: #ffffff !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    z-index: 1000 !important;
    min-width: 120px !important;
    padding: 4px 0 !important;
    display: none !important;
    transform-origin: top right !important;
    animation: popupFadeIn 0.2s ease-out !important;
}

.mobile-device .thread-popup-menu.show {
    display: block !important;
}

.mobile-device .thread-popup-menu-item {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 12px 16px !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease !important;
    font-size: 14px !important;
    color: #333333 !important;
    border: none !important;
    background: none !important;
    width: 100% !important;
    text-align: left !important;
}

.mobile-device .thread-popup-menu-item:hover {
    background-color: #f5f5f5 !important;
}

.mobile-device .thread-popup-menu-item:active {
    background-color: #e8e8e8 !important;
}

.mobile-device .thread-popup-menu-item i {
    font-size: 14px !important;
    width: 16px !important;
    text-align: center !important;
    color: #666666 !important;
}

.mobile-device .thread-popup-menu-item.edit-item i {
    color: #007bff !important;
}

.mobile-device .thread-popup-menu-item.delete-item i {
    color: #dc3545 !important;
}

.mobile-device .thread-popup-menu-item.edit-item:hover i {
    color: #0056b3 !important;
}

.mobile-device .thread-popup-menu-item.delete-item:hover i {
    color: #c82333 !important;
}

/* Popup animation */
@keyframes popupFadeIn {
    0% {
        opacity: 0;
        transform: scale(0.9) translateY(-4px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Mobile popup overlay for closing */
.mobile-device .popup-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: transparent !important;
    z-index: 999 !important;
    display: none !important;
}

.mobile-device .popup-overlay.active {
    display: block !important;
}

/* iOS Safari specific fixes for mobile devices */
.mobile-device {
    -webkit-text-size-adjust: 100% !important;
    -webkit-overflow-scrolling: touch !important;
}

/* Mobile mode indicator removed - functionality confirmed working */

/* Debug indicators removed - functionality confirmed working */

/* Prevent zoom on input focus in iOS */
.mobile-device input,
.mobile-device textarea,
.mobile-device select {
    font-size: 16px !important;
}

/* Safe area support for devices with notches */
@supports (padding: max(0px)) {
    .mobile-device .mobile-header {
        padding-left: max(15px, env(safe-area-inset-left)) !important;
        padding-right: max(15px, env(safe-area-inset-right)) !important;
        padding-top: env(safe-area-inset-top) !important;
        height: calc(50px + env(safe-area-inset-top)) !important;
    }
    
    .mobile-device .mobile-bottom-nav {
        padding-left: max(15px, env(safe-area-inset-left)) !important;
        padding-right: max(15px, env(safe-area-inset-right)) !important;
        padding-bottom: env(safe-area-inset-bottom) !important;
        height: calc(60px + env(safe-area-inset-bottom)) !important;
    }
    
    .mobile-device .input-container {
        bottom: calc(60px + env(safe-area-inset-bottom)) !important;
        padding-left: max(15px, env(safe-area-inset-left)) !important;
        padding-right: max(15px, env(safe-area-inset-right)) !important;
    }
}

/* ===== NEW IMAGE UPLOAD PREVIEW SYSTEM ===== */
/* Modern image preview area above chat input */
.image-upload-preview {
    position: relative;
    margin: 0 20px 15px 20px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    animation: slideDownFadeIn 0.3s ease-out;
}

@keyframes slideDownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 200px;
    }
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.preview-title {
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-title::before {
    content: '🖼️';
    font-size: 16px;
}

.clear-all-btn {
    background: transparent;
    border: 1px solid #dc3545;
    color: #dc3545;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.clear-all-btn:hover {
    background: #dc3545;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.2);
}

.preview-images-container {
    display: flex;
    gap: 12px;
    padding: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #dee2e6 transparent;
}

.preview-images-container::-webkit-scrollbar {
    height: 6px;
}

.preview-images-container::-webkit-scrollbar-track {
    background: transparent;
}

.preview-images-container::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 3px;
}

.preview-images-container::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

.preview-image-item {
    position: relative;
    flex-shrink: 0;
    width: 120px;
    height: 120px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #e9ecef;
    background: #f8f9fa;
    transition: all 0.2s ease;
    cursor: pointer;
}

.preview-image-item:hover {
    border-color: #007bff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
}

.preview-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.preview-image-item:hover img {
    transform: scale(1.05);
}

.preview-image-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

.preview-image-item:hover .preview-image-remove {
    opacity: 1;
    transform: scale(1.1);
}

.preview-image-remove:hover {
    background: #dc3545;
    transform: scale(1.2);
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

.preview-image-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: white;
    padding: 8px 6px 4px;
    font-size: 10px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.preview-image-item:hover .preview-image-info {
    opacity: 1;
}

/* Update input container to work with new preview */
.input-container {
    position: relative;
    padding: 20px;
    background-color: #ffffff;
    border-top: 1px solid #e5e5e5;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

/* Remove old mini-preview styles */
.mini-preview {
    display: none !important;
}

/* ===== TABLE STYLING ===== */
/* Professional table design for chat messages */
.message-content table,
.message table {
    border-collapse: collapse !important;
    width: 100% !important;
    margin: 16px 0 !important;
    background-color: #ffffff !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
}

.message-content table th,
.message-content table td,
.message table th,
.message table td {
    border: 1px solid #e1e5e9;
    padding: 12px 16px;
    text-align: left;
    vertical-align: top;
    word-wrap: break-word;
}

.message-content table th,
.message table th {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    font-weight: 600;
    color: #495057;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #6c757d;
    position: sticky;
    top: 0;
    z-index: 10;
}

.message-content table tbody tr,
.message table tbody tr {
    transition: background-color 0.2s ease;
}

.message-content table tbody tr:nth-child(even),
.message table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.message-content table tbody tr:hover,
.message table tbody tr:hover {
    background-color: #e7f3ff;
    box-shadow: inset 0 0 0 1px #007bff;
}

.message-content table tbody tr:nth-child(even):hover,
.message table tbody tr:nth-child(even):hover {
    background-color: #e7f3ff;
}

/* Math notation styling within tables */
.message-content table td code,
.message-content table th code,
.message table td code,
.message table th code {
    background-color: rgba(0, 123, 255, 0.1);
    border: 1px solid rgba(0, 123, 255, 0.2);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #0056b3;
}

/* First column (headers) styling */
.message-content table td:first-child,
.message table td:first-child {
    font-weight: 600;
    background-color: rgba(0, 123, 255, 0.05);
    border-right: 2px solid #dee2e6;
}

.message-content table tr:nth-child(even) td:first-child,
.message table tr:nth-child(even) td:first-child {
    background-color: rgba(0, 123, 255, 0.08);
}

/* Responsive table design */
@media (max-width: 768px) {
    .message-content table,
    .message table {
        font-size: 12px;
        margin: 12px 0;
    }
    
    .message-content table th,
    .message-content table td,
    .message table th,
    .message table td {
        padding: 8px 10px;
    }
    
    .message-content table th,
    .message table th {
        font-size: 11px;
    }
    
    /* Make table horizontally scrollable on mobile */
    .message-content,
    .message {
        overflow-x: auto;
    }
    
    .message-content table,
    .message table {
        min-width: 600px;
        display: table;
    }
}

/* Table container for better mobile experience */
.message-content table-wrapper,
.message table-wrapper {
    overflow-x: auto;
    margin: 16px 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Enhanced borders for better visual separation */
.message-content table thead th:first-child,
.message table thead th:first-child {
    border-top-left-radius: 8px;
}

.message-content table thead th:last-child,
.message table thead th:last-child {
    border-top-right-radius: 8px;
}

.message-content table tbody tr:last-child td:first-child,
.message table tbody tr:last-child td:first-child {
    border-bottom-left-radius: 8px;
}

.message-content table tbody tr:last-child td:last-child,
.message table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 8px;
}

/* Dark mode support for tables */
.dark-mode .message-content table,
.dark-mode .message table {
    background-color: #2d3748;
    color: #e2e8f0;
}

.dark-mode .message-content table th,
.dark-mode .message table th {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    color: #f7fafc;
    border-bottom-color: #718096;
}

.dark-mode .message-content table th,
.dark-mode .message-content table td,
.dark-mode .message table th,
.dark-mode .message table td {
    border-color: #4a5568;
}

.dark-mode .message-content table tbody tr:nth-child(even),
.dark-mode .message table tbody tr:nth-child(even) {
    background-color: #2d3748;
}

.dark-mode .message-content table tbody tr:hover,
.dark-mode .message table tbody tr:hover {
    background-color: #2a4365;
    box-shadow: inset 0 0 0 1px #3182ce;
}

.dark-mode .message-content table td:first-child,
.dark-mode .message table td:first-child {
    background-color: rgba(49, 130, 206, 0.1);
    border-right-color: #4a5568;
}

.dark-mode .message-content table tr:nth-child(even) td:first-child,
.dark-mode .message table tr:nth-child(even) td:first-child {
    background-color: rgba(49, 130, 206, 0.15);
}

.dark-mode .message-content table td code,
.dark-mode .message-content table th code,
.dark-mode .message table td code,
.dark-mode .message table th code {
    background-color: rgba(49, 130, 206, 0.2);
    border-color: rgba(49, 130, 206, 0.3);
    color: #90cdf4;
}

/* ========================================
   TTS CONTROLS STYLES
   ======================================== */

.tts-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 25px;
    border-radius: 25px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 1000;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: slideUpFadeIn 0.3s ease-out;
}

.tts-controls.active {
    animation: pulse 2s infinite;
}

@keyframes slideUpFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    }
    50% {
        box-shadow: 0 8px 35px rgba(102, 126, 234, 0.4);
    }
    100% {
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    }
}

.tts-status {
    display: flex;
    align-items: center;
    gap: 12px;
}

#ttsStatusText {
    font-weight: 500;
    font-size: 14px;
    min-width: 120px;
}

.tts-audio-indicator {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 20px;
}

.audio-wave {
    width: 3px;
    height: 8px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 2px;
    animation: audioWave 1.5s ease-in-out infinite;
}

.audio-wave:nth-child(2) {
    animation-delay: 0.2s;
}

.audio-wave:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes audioWave {
    0%, 100% {
        height: 8px;
        background: rgba(255, 255, 255, 0.5);
    }
    50% {
        height: 20px;
        background: rgba(255, 255, 255, 1);
    }
}

.tts-stop-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
}

.tts-stop-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.tts-stop-btn:active {
    transform: scale(0.95);
}

/* Enhanced sound button styling when TTS is available */
.message-action-btn.sound-btn {
    position: relative;
}

.message-action-btn.sound-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: scale(1.05);
}

.message-action-btn.sound-btn.tts-active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        box-shadow: 0 0 5px rgba(102, 126, 234, 0.5);
    }
    to {
        box-shadow: 0 0 15px rgba(102, 126, 234, 0.8);
    }
}

/* Mobile responsive adjustments for TTS controls */
@media (max-width: 768px) {
    .tts-controls {
        bottom: 80px; /* Above mobile bottom nav */
        left: 10px;
        right: 10px;
        transform: none;
        padding: 12px 20px;
        border-radius: 20px;
    }
    
    #ttsStatusText {
        font-size: 12px;
        min-width: 100px;
    }
    
    .tts-stop-btn {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }
    
    .audio-wave {
        width: 2px;
        height: 6px;
    }
    
    @keyframes audioWave {
        0%, 100% {
            height: 6px;
        }
        50% {
            height: 16px;
        }
    }
}

@media (prefers-color-scheme: dark) {
    .tts-controls {
        background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
        border-color: rgba(255, 255, 255, 0.2);
    }
}
