:root {
    --bg-main: #202123;
    --bg-secondary: #2a2b2e;
    --bg-user-message: #3a3f47;
    --bg-hover: #3a3b3e;
    --bg-hover-2: #4a4b4e;

    --text-primary: #ececf1;
    --text-secondary: #d1d5db;
    --text-muted: #b0b1b6;
    --text-placeholder: #7a7b7e;
    --text-inverse: white;

    --border-color: #3a3b3e;
    --border-color-hover: #4a4b4e;

    --accent-primary: #34c759;
    --accent-primary-hover: #2aa34a;

    --backdrop-bg: rgba(0, 0, 0, 0.6);

    --scrollbar-track-bg: #2a2b2e;
    --scrollbar-thumb-bg: #4a4b4e;
    --scrollbar-thumb-hover-bg: #5a5b5e;
}

/* Top buttons container */
.top-buttons {
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    display: flex;
    gap: 10px;
}

/* Toggle Button Styling */
#toggle-sidebar-btn {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color-hover);
    border-radius: 5px;
    padding: 8px 12px;
    font-size: 1.2em;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

#toggle-sidebar-btn:hover {
    background-color: var(--bg-hover-2);
}

/* New Chat Button Styling */
#new-chat-btn {
    background-color: var(--accent-primary);
    color: var(--text-inverse);
    border: none;
    border-radius: 5px;
    padding: 8px 12px;
    font-size: 1.2em;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

#new-chat-btn:hover {
    background-color: var(--accent-primary-hover);
}

#new-chat-btn:active {
    transform: scale(0.95);
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    margin: 0;
    overflow: hidden; /* Prevent body scrollbars */
}

.container {
    display: flex;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-main);
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    padding: 20px;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    border-right: 1px solid var(--border-color);
    height: 100vh; /* Make sidebar full-height */
}

.sidebar.collapsed {
    width: 0;
    padding: 0; /* Adjusted padding as content is hidden */
    overflow: hidden;
    border-right: none; /* Hide border when fully collapsed */
}

.sidebar-header {
    /* display: flex; removed as button is external */
    /* justify-content: space-between; removed */
    align-items: center; /* Keep for h2 alignment */
    margin-bottom: 20px;
    padding-top: 20px; /* Adjust top padding for the header */
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.2em;
    white-space: nowrap;
}

/* Old .toggle-btn styles removed as button is now #toggle-sidebar-btn with new global styling */

.sidebar-nav {
    padding: 15px 0;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-section-title {
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-muted);
    padding: 8px 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.experts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toggle-experts-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 10px;
    padding: 2px 5px;
    transition: transform 0.3s ease, color 0.3s ease;
}

.toggle-experts-btn:hover {
    color: var(--text-primary);
}

.toggle-experts-btn.collapsed {
    transform: rotate(-90deg);
}

.sidebar-experts-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, auto));
    column-gap: 2px;
    row-gap: 2px;
    padding: 2px;
    margin-top: 3px;
    justify-content: start;
}

.sidebar-expert-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    border-radius: 0px;
    padding: 1px;
}

.sidebar-expert-item:hover {
    background-color: var(--bg-hover);
}

.sidebar-expert-img {
    width: 56px;
    height: 56px;
    border-radius: 3px;
    object-fit: cover;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    margin: 0;
    filter: grayscale(100%);
}

.sidebar-expert-img.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 1px rgba(52, 199, 89, 0.3);
    filter: grayscale(0%);
}

.sidebar-expert-name {
    display: none;
}

.selected-expert-name {
    font-size: 0.8rem;
    margin-top: 8px;
    text-align: center;
    padding: 4px;
    color: var(--text-primary);
    font-weight: 500;
    background-color: var(--bg-hover);
    border-radius: 3px;
    margin: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Add notification dot for experts */
.sidebar-expert-item .notification-dot {
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-primary);
    display: none;
}

.sidebar-expert-item .notification-dot.show {
    display: block;
}

.sidebar-nav li a {
    display: block;
    color: var(--text-muted);
    text-decoration: none;
    padding: 10px 0;
    border-radius: 5px;
    transition: background-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.sidebar-nav li a:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
    background-color: var(--bg-main);
}

.welcome-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1;
    transition: opacity 0.3s ease;
}

.welcome-state.hidden {
    opacity: 0;
    pointer-events: none;
}

.welcome-message {
    color: var(--text-primary);
    font-size: 2em;
    font-weight: 300;
    margin: 0 0 20px 0;
    opacity: 0.8;
}

.welcome-instructions {
    color: var(--text-secondary);
    background-color: var(--bg-secondary);
    border-radius: 8px;
    padding: 15px 20px;
    max-width: 500px;
    margin: 0 auto;
    text-align: left;
}

.welcome-instructions p {
    margin-top: 0;
    font-weight: 500;
}

.welcome-instructions ul {
    margin-bottom: 0;
    padding-left: 20px;
}

.welcome-instructions li {
    margin-bottom: 8px;
    line-height: 1.4;
}

.welcome-instructions li:last-child {
    margin-bottom: 0;
}

/* Inline Context Container */
.inline-context-container {
    width: 100%;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.inline-context-header {
    padding: 8px 15px;
    display: flex;
    justify-content: flex-start;
}

.inline-context-toggle {
    background-color: transparent;
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.inline-context-toggle:hover {
    background-color: var(--accent-primary);
    color: var(--text-inverse);
}

.inline-context-toggle.active {
    background-color: var(--accent-primary);
    color: var(--text-inverse);
}

.inline-context-toggle.has-context::after {
    content: '';
    position: absolute;
    top: -5px;
    right: -5px;
    width: 10px;
    height: 10px;
    background-color: var(--accent-primary);
    border-radius: 50%;
    border: 2px solid var(--bg-main);
}

.inline-context-input-area {
    padding: 10px 15px;
    display: none;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.inline-context-input-area.open {
    display: block;
}

.inline-context-input-area textarea {
    width: 100%;
    min-height: 100px;
    padding: 10px;
    margin-bottom: 10px;
    background-color: var(--bg-main);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    resize: vertical;
    font-family: inherit;
    font-size: 14px;
}

.inline-context-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.inline-context-controls input {
    flex: 1;
    padding: 8px 10px;
    background-color: var(--bg-main);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
}

.inline-context-controls button {
    padding: 8px 15px;
    background-color: var(--accent-primary);
    color: var(--text-inverse);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.inline-context-controls button:hover {
    background-color: var(--accent-primary-hover);
}

/* Context Display Area */
#context-display-area {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 10px 15px;
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.active-context-items h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.active-context-item {
    background-color: var(--bg-main);
    border-left: 4px solid var(--accent-primary);
    border-radius: 4px;
    padding: 8px 10px;
    margin-bottom: 8px;
    font-size: 13px;
}

.active-context-item.bug {
    border-left-color: #e74c3c;
}

.active-context-item.test {
    border-left-color: #3498db;
}

.active-context-item.adhoc {
    border-left-color: #9b59b6;
}

.context-item-header {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.context-item-type {
    background-color: var(--bg-hover);
    color: var(--text-muted);
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 8px;
    font-weight: bold;
}

.bug .context-item-type {
    background-color: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
}

.test .context-item-type {
    background-color: rgba(52, 152, 219, 0.2);
    color: #3498db;
}

.context-item-title {
    flex-grow: 1;
    font-weight: 500;
}

.remove-context-item {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
}

.remove-context-item:hover {
    color: var(--text-primary);
}

.context-item-definition {
    margin: 0;
    padding: 8px;
    background-color: var(--bg-hover);
    border-radius: 4px;
    font-size: 0.85rem;
    white-space: pre-wrap;
    max-height: 150px;
    overflow-y: auto;
}

/* Sidebar context items */
.sidebar-nav .context-item.active-context-item {
    color: var(--accent-primary);
    font-weight: 500;
}

.sub-items {
    display: none;
    padding-left: 15px;
}

.sub-items.open {
    display: block;
}

#context-display-area pre {
    margin: 0;
    font-family: 'Courier New', Courier, monospace;
    white-space: pre-wrap;
    max-height: 150px;
    overflow-y: auto;
    color: var(--text-secondary);
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.chat-header h1 {
    margin: 0;
    font-size: 1.5em;
}

.chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.message {
    max-width: 70%;
    padding: 10px 15px;
    border-radius: 15px;
    margin-bottom: 10px;
    line-height: 1.4;
}

.user-message {
    background-color: var(--bg-user-message);
    color: var(--text-primary);
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

.bot-message {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.message.thinking .message-content::after {
    display: inline-block;
    content: '...';
    animation: thinking 1.5s infinite;
    width: 1.2em;
    text-align: left;
}

@keyframes thinking {
    0%   { content: '.'; }
    33%  { content: '..'; }
    66%  { content: '...'; }
    100% { content: '.'; }
}

.message.error-message .message-content {
    color: #ff8a8a; /* A noticeable error color */
}

.message .message-content {
    margin: 0;
}

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

.shortcut-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.shortcut-btn {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color-hover);
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.shortcut-btn:hover {
    background-color: var(--bg-hover-2);
}

.input-wrapper {
    display: flex;
    gap: 10px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    padding: 5px;
    border: 1px solid var(--border-color);
}

#chat-input {
    flex-grow: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1em;
    padding: 10px;
    outline: none;
}

#chat-input::placeholder {
    color: var(--text-placeholder);
}

#image-btn {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.2em;
    transition: background-color 0.2s ease, transform 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
}

#image-btn:hover {
    background-color: var(--bg-hover-2);
    transform: scale(1.05);
}

#image-btn:active {
    transform: scale(0.95);
}

#send-btn {
    background-color: var(--accent-primary);
    color: var(--text-inverse);
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.2s ease;
}

#send-btn:hover {
background-color: var(--accent-primary-hover);
}

/* Modal styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--backdrop-bg);
    z-index: 2000;
    overflow-y: auto;
    padding: 20px 0;
}

.api-key-modal .modal-content {
    max-width: 500px;
}

.api-key-missing-alert {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 20px;
    margin-bottom: 15px;
    border-radius: 8px;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
}

.api-key-missing-alert .alert-heading {
    font-size: 18px;
    font-weight: bold;
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.alert-section {
    margin-bottom: 20px;
    padding-left: 10px;
    border-left: 3px solid var(--accent-primary);
}

.alert-title {
    font-weight: bold;
    margin-bottom: 8px;
    color: var(--accent-primary);
}

.api-key-missing-alert p {
    margin: 5px 0;
    color: var(--text-secondary);
}

.alert-link {
    color: var(--accent-primary);
    text-decoration: underline;
    transition: color 0.2s;
}

.alert-link:hover {
    color: var(--accent-primary-hover);
}

.api-key-modal .modal-body {
    padding: 20px;
    line-height: 1.5;
}

.api-key-modal .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
}

.highlight-setting {
    animation: highlight-pulse 2s ease-in-out;
    border-radius: 4px;
}

.input-error {
    border-color: var(--error-color) !important;
    animation: shake 0.5s ease-in-out;
    background-color: rgba(255, 0, 0, 0.05);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

@keyframes highlight-pulse {
    0% { background-color: transparent; }
    25% { background-color: rgba(var(--primary-rgb), 0.1); }
    75% { background-color: rgba(var(--primary-rgb), 0.1); }
    100% { background-color: transparent; }
}

.modal-content {
background-color: var(--bg-secondary);
margin: 0 auto;
padding: 0;
border-radius: 8px;
box-shadow: 0 5px 15px rgba(0,0,0,0.3);
width: 90%;
max-width: 700px;
max-height: 90vh;
overflow-y: auto;
position: relative;
animation: modalopen 0.3s;
color: var(--text-primary);
    margin: 0 auto;
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalopen 0.3s;
    color: var(--text-primary);
}

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

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-title-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.modal-header h2 {
    margin: 0;
    color: var(--text-primary);
}

.close-modal {
    color: var(--text-muted);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
}

.close-modal:hover {
    color: var(--text-primary);
}

.modal-content {
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    color: var(--text-primary);
}

.modal-body {
    padding: 30px;
    max-height: 70vh;
    overflow-y: auto;
}

.settings-modal-body {
    padding: 30px 40px;
}

/* Notification */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--accent-primary);
    color: white;
    padding: 10px 15px;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 3000;
    animation: fadeIn 0.3s ease;
    font-size: 0.9em;
}

.notification.fade-out {
    animation: fadeOut 0.5s ease forwards;
}

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

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

/* About Modal Styles */
.about-content {
    text-align: center;
    padding: 10px;
}

.about-logo {
    width: 120px;
    height: auto;
    margin-bottom: 20px;
}

.about-content p {
    margin-bottom: 15px;
    line-height: 1.5;
    text-align: left;
}

.about-links {
    margin-top: 25px;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.github-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background-color: #24292e;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.github-link:hover {
    background-color: #2f363d;
}

.testers-ai-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background-color: #0078d7;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.testers-ai-link:hover {
    background-color: #0063b1;
}

.settings-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
}

.settings-panel-header h2 {
    margin: 0;
    font-size: 1.6em;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 2em;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-primary);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    width: 36px;
    height: 36px;
}

.sidebar-header h1 {
    font-size: 1.25em;
    margin: 0;
    line-height: 1;
}

.settings-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.settings-header-with-button {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.settings-hint {
    font-size: 0.8em;
    color: var(--text-muted);
    margin-top: 5px;
    font-style: italic;
}

.secondary-button {
    background-color: transparent;
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s ease;
}

.secondary-button:hover {
    background-color: var(--accent-primary);
    color: white;
}

.settings-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.settings-section h3 {
    font-size: 1.3em;
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--accent-primary);
}

.settings-section label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.95em;
    color: var(--text-muted);
}

.settings-section input[type="text"],
.settings-section input[type="password"],
.settings-section textarea {
    width: calc(100% - 20px); /* Full width minus padding */
    padding: 10px;
    margin-bottom: 15px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    color: var(--text-primary);
    font-size: 1em;
}

.settings-section input[type="text"]:focus,
.settings-section input[type="password"]:focus,
.settings-section textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.settings-section textarea {
    min-height: 80px;
    resize: vertical;
}

.settings-section select.settings-dropdown {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    color: var(--text-primary);
    font-size: 1em;
    -webkit-appearance: none; /* Removes default browser styling */
    -moz-appearance: none;
    appearance: none;
    /* Custom arrow using an inline SVG, colored with a CSS variable */
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23b0b1b6%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.4-5.4-13z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 15px top 50%;
    background-size: 10px auto;
}

.settings-section select.settings-dropdown:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.settings-section button,
.save-settings-btn {
    background-color: var(--accent-primary);
    color: var(--text-inverse);
    border: none;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    transition: background-color 0.2s ease;
    margin: 0;
    white-space: nowrap;
    font-weight: 500;
}

.settings-section button:hover,
.save-settings-btn:hover {
    background-color: var(--accent-primary-hover);
}

.settings-note {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-top: -10px;
    margin-bottom: 15px;
}

/* Experts List Styling */
#experts-list .expert-item {
    background-color: var(--bg-main);
    padding: 10px 15px;
    border-radius: 5px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    display: flex;
    /* justify-content: space-between; Let natural flow handle for now */
    align-items: flex-start; /* Changed from center to flex-start for better layout with image */
}

#experts-list .expert-item .expert-details {
    flex-grow: 1; /* Allow details to take up remaining space */
}

#experts-list .expert-details p {
    margin: 2px 0;
    font-size: 0.9em;
}

#experts-list .expert-details p strong {
    color: var(--text-muted);
}

#experts-list .expert-details a {
    color: var(--accent-primary);
    text-decoration: none;
}

/* Model Selection Styling */
.model-selection-container {
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

.model-selection-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.model-option {
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-model-option {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

#custom-model-name {
    flex: 1;
    min-width: 180px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 0.9em;
    margin-left: 5px;
}

#custom-model-name:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#experts-list .expert-details a:hover {
    text-decoration: underline;
}

#experts-list .delete-expert-btn {
    background-color: transparent;
    color: var(--text-muted); /* Muted text color */
    border: 1px solid var(--border-color-hover); /* Subtle border */
    padding: 4px 6px; /* Adjusted padding for icon */
    border-radius: 5px;
    font-size: 1.3em; /* Increased font size for icon */
    line-height: 1; /* Helps center icon vertically */
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease; /* Smooth transition */
}

#experts-list .delete-expert-btn:hover {
    background-color: var(--bg-hover); /* Darker background on hover */
    color: var(--text-primary); /* Lighter text on hover */
    border-color: var(--border-color); /* Match background or slightly darker */
}

.expert-profile-img {
    width: 50px;
    height: 50px;
    border-radius: 4px; /* Square images with slight rounding */
    object-fit: cover; /* Crop image to fit */
    margin-bottom: 5px;
    border: 1px solid var(--border-color-hover);
}

.expert-profile-img-placeholder {
    width: 50px;
    height: 50px;
    border-radius: 4px;
    background-color: #3a3b3e; /* Placeholder background */
    display: flex; /* For centering text if we add it */
    align-items: center;
    justify-content: center;
    color: #7a7b7e;
    font-size: 0.8em;
    text-align: center;
    margin-right: 15px; /* Consistent with image margin */
    border: 1px solid #4a4b4e;
}

.expert-social-links {
    margin-top: 8px;
}

.social-link {
    text-decoration: none;
    color: var(--accent-primary);
    font-size: 0.9em;
    margin-right: 10px;
}

.social-link:hover {
    text-decoration: underline;
}

/* .social-link.linkedin-link { */
    /* Specific styles for LinkedIn if needed */
/* } */

/* .social-link.twitter-link { */
    /* Specific styles for Twitter if needed */
/* } */

#experts-list .expert-item {
    /* Ensure items align nicely with the image */
    align-items: flex-start; /* Align items to the top if details wrap */
    position: relative; /* For absolute positioning of delete button */
    padding: 15px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-secondary);
}

.settings-section h4 {
    font-size: 1.1em;
    margin-top: 20px;
    margin-bottom: 10px;
    color: var(--text-muted);
}

.save-settings-btn {
    display: block;
    width: auto;
    margin: 20px auto 0 auto; /* Center the save button */
}

/* Add any new global styles or utility classes here */

/* Expert Info Styling */
.expert-info {
    margin-top: 15px;
    padding: 12px;
    background-color: var(--bg-hover);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.expert-description {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9em;
    line-height: 1.4;
}

.expert-specialization {
    margin: 8px 0 0 0;
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 0.85em;
}

/* Combined Expert & User Section Styling */
#expert-persona-settings {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

#expert-persona-settings label {
    margin-bottom: 8px;
    display: block;
}

/* Sidebar Context Navigation */
.sidebar-nav .context-category {
    font-weight: bold;
    padding-left: 0; /* Left align context header */
    text-align: left;
}

.sidebar-nav .sub-items {
    list-style: none;
    padding-left: 20px; /* Increase indent for sub-items */
    max-height: 0; /* Initially hidden */
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.sidebar-nav .sub-items.open {
    max-height: 500px; /* Adjust as needed to show all items */
    transition: max-height 0.3s ease-in;
}

.sidebar-nav .sub-items li a.context-item {
    padding: 8px 0 8px 5px; /* Adjust padding for sub-items */
    font-size: 0.9em;
    white-space: normal; /* Allow text wrapping for long titles */
    line-height: 1.3;
    display: block; /* Ensure block display for proper alignment */
}

.sidebar-nav .separator-nav-item hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 10px 0;
}

/* Context Display Area */
.context-display-area {
    background-color: var(--bg-secondary); /* Slightly lighter dark background */
    border: 1px solid var(--border-color); /* Subtle border */
    border-radius: 8px;
    padding: 15px;
    margin: 0 20px 15px 20px; /* Margin: 0 top/bottom (for now), 20px sides, 15px bottom */
    min-height: 50px; /* Minimum height */
    max-height: 150px; /* Maximum height before scroll */
    overflow-y: auto;
    color: var(--text-secondary); /* Light text color */
    font-size: 0.9em;
    line-height: 1.5;
}

.context-display-area h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--accent-primary); /* Accent color for title */
    font-size: 1.1em;
}

.context-display-area pre {
    white-space: pre-wrap; /* Wrap text, preserve line breaks */
    word-wrap: break-word; /* Break long words */
    margin: 0;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
}

/* Scrollbar for context display area */
.context-display-area::-webkit-scrollbar {
    width: 8px;
}

.context-display-area::-webkit-scrollbar-track {
    background: var(--bg-main);
    border-radius: 4px;
}

.context-display-area::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb-bg);
    border-radius: 4px;
}

.context-display-area::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover-bg);
}

/* Scrollbar styling for webkit browsers */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--scrollbar-track-bg);
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: var(--bg-hover);
    border: 1px solid var(--border-color-hover);
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover-bg);
}

/* Responsive adjustments */
/* Sidebar overlay for mobile */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999; /* Just below sidebar */
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: auto;
}

/* Responsive Styles */
@media (max-width: 768px) {
    body {
        font-size: 16px; /* Base font size for mobile */
    }
    
    .sidebar {
        position: fixed; /* Changed from absolute to fixed */
        left: -100%; /* Use percentage to ensure it's fully off-screen */
        z-index: 1000;
        height: 100%;
        transition: left 0.3s ease;
        width: 280px; /* Slightly wider for better touch targets */
        box-shadow: 0 0 15px rgba(0, 0, 0, 0.3); /* Shadow when open */
        top: 0; /* Ensure it starts from the top */
        overflow-x: hidden; /* Prevent horizontal scrolling */
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar.collapsed {
        left: -100%; /* Ensure it's completely off-screen */
        visibility: hidden; /* Hide it completely when collapsed */
    }
    
    .sidebar-nav {
        padding: 15px 10px; /* More padding for better touch targets */
    }
    
    .sidebar-nav li a {
        padding: 12px 15px; /* Larger touch targets */
    }

    .toggle-btn {
        display: block; /* Ensure toggle button is always visible on mobile */
        padding: 12px; /* Larger touch target */
        font-size: 1.2em;
    }

    .chat-area {
        width: 100%;
        padding-left: 0;
        padding-right: 0;
    }
    
    .chat-messages {
        padding: 15px 10px; /* Reduce side padding on mobile */
    }
    
    .message {
        padding: 12px;
        margin-bottom: 15px;
    }

    .shortcut-buttons {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px;
    }

    .shortcut-btn {
        font-size: 0.85em;
        padding: 8px 12px;
        flex-grow: 0;
        flex-shrink: 0;
        white-space: nowrap;
    }
    
    .chat-input-container {
        padding: 10px;
    }
    
    .chat-input {
        padding: 12px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .send-btn {
        width: 44px;
        height: 44px;
    }
    
    /* Modal adjustments for mobile */
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 10px auto;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .settings-modal-body {
        padding: 15px;
    }
    
    /* Experts grid for mobile */
    .sidebar-experts-grid {
        grid-template-columns: repeat(3, 1fr); /* 3 columns on mobile */
        gap: 5px;
    }
    
    .expert-img {
        width: 40px;
        height: 40px;
    }
}

/* iPhone SE and other small devices */
@media (max-width: 375px) {
    body {
        font-size: 15px;
    }
    
    .sidebar {
        width: 260px;
        left: -100%;
    }
    
    .sidebar.collapsed {
        left: -100%;
        visibility: hidden;
    }
    
    .shortcut-btn {
        min-width: 100%; /* Full width on very small screens */
        max-width: 100%;
    }
    
    .sidebar-experts-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 columns on very small screens */
    }
    
    .modal-content {
        width: 98%;
    }
    
    .modal-body {
        padding: 10px;
    }
}

/* Fix for iPhone notch and safe areas */
@supports (padding-top: env(safe-area-inset-top)) {
    .sidebar {
        padding-top: env(safe-area-inset-top);
        height: calc(100% - env(safe-area-inset-top));
    }
    
    .chat-header {
        padding-top: calc(10px + env(safe-area-inset-top));
    }
    
    .notification {
        bottom: calc(20px + env(safe-area-inset-bottom));
    }
}

/* Bot Message User Info */
.bot-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.bot-user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.bot-user-name {
    font-size: 0.85em;
    color: var(--text-muted);
    font-weight: 500;
}

.settings-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

/* User Role Selection */
.role-selection {
    margin: 15px 0;
    padding: 15px;
    background-color: var(--bg-hover);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.role-option {
    margin: 5px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.role-option input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
}

.role-option label {
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.95em;
    margin: 0;
}

.role-option label:hover {
    color: var(--accent-primary);
}

.settings-description {
    color: var(--text-secondary);
    font-size: 0.9em;
    margin: 5px 0 10px 0;
}

/* Expert Selection Radio Buttons */
.expert-selection {
    margin: 15px 0;
    padding: 15px;
    background-color: var(--bg-hover);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.expert-option {
    margin: 8px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.expert-option input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
}

.expert-option label {
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.95em;
    margin: 0;
}

.expert-option label:hover {
    color: var(--accent-primary);
}

#expert-info-display {
    margin-top: 15px;
    padding: 12px;
    background-color: var(--bg-hover);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

#expert-info-display .expert-description {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9em;
    line-height: 1.4;
}

#expert-info-display .expert-specialization {
    margin: 8px 0 0 0;
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 0.85em;
}

/* Expert Info Styling */

/* Expert Actions Styling */
.expert-profile-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-right: 15px;
    float: left;
    width: 60px;
}

.make-active-btn {
    background-color: #e0e0e0; /* Grey background by default */
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s ease;
}

.make-active-btn.small {
    font-size: 0.7em;
    padding: 3px 6px;
    width: 100%;
    margin-top: 3px;
}

.make-active-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.make-active-btn.active {
    background-color: var(--accent-primary);
    color: white;
}

.delete-expert-btn {
    background-color: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: 4px;
    padding: 3px 5px;
    cursor: pointer;
    font-size: 0.75em;
    transition: all 0.2s ease;
    position: absolute;
    top: 8px;
    right: 8px;
}

.delete-expert-btn:hover {
    background-color: #ff4d4d;
    color: white;
}

/* Bot profile image styling */
.bot-user-info {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.bot-profile-image {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    margin-right: 8px;
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.bot-user-name {
    font-size: 0.85em;
    font-weight: 600;
    color: var(--accent-primary);
}

/* Message content formatting */
.message-content {
    line-height: 1.5;
    white-space: pre-wrap;
}

.message-content code {
    background-color: rgba(0, 0, 0, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
}

/* Enhanced message formatting */
.message-content pre {
    background-color: rgba(0, 0, 0, 0.1);
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 12px 0;
}

/* Paragraph styling for bot messages */
.bot-paragraph {
    margin: 0 0 12px 0;
    line-height: 1.5;
}

/* List styling for bot messages */
.bot-message ul, .bot-message ol {
    margin: 8px 0 12px 0;
    padding-left: 20px;
}

.bot-message li {
    margin-bottom: 6px;
    line-height: 1.5;
}

/* Code block styling */
.bot-message code {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

.bot-message pre code {
    background-color: transparent;
    padding: 0;
}

/* Headings in bot messages */
.bot-message strong {
    display: block;
    margin: 16px 0 8px 0;
    font-size: 1.1em;
}

/* Add more space between message content and user info */
.bot-user-info {
    margin-bottom: 8px;
}

.message-content pre code {
    background-color: transparent;
    padding: 0;
    display: block;
}

.message-content strong {
    font-weight: bold;
}

.message-content em {
    font-style: italic;
}
