/* Ultra-wide Chat App Layout - Clean & Minimalist */

/* Import modern font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* User Dropdown Styles */
.user-avatar-btn:hover {
    transform: scale(1.05);
}

.user-dropdown-item:hover {
    background-color: var(--bg-secondary) !important;
}

.user-dropdown-item.logout-dropdown-item:hover {
    background-color: rgba(220, 53, 69, 0.1) !important;
    color: #dc3545 !important;
}

/* CSS Variables for Theming */
:root {
    /* Light Theme (Default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f0f0f0;
    --bg-hover: #e0e0e0;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --border-color: #e9ecef;
    --border-hover: #dee2e6;
    --accent-color: #4285f4;
    --accent-hover: #3367d6;
    --message-user-bg: #f0f0f0;
    --message-assistant-bg: #ffffff;
    --message-assistant-border: #e9ecef;
    --input-bg: #f8f9fa;
    --sidebar-bg: #ffffff;
    --header-bg: #f8f9fa;
    --shadow: rgba(0, 0, 0, 0.1);
    /* Scrollbar colors for light theme */
    --scrollbar-track: #f8f9fa;
    --scrollbar-thumb: #d0d0d0;
    --scrollbar-thumb-hover: #b0b0b0;
}

[data-theme="dark"] {
    /* Dark Theme */
    --bg-primary: #1a1a1a;
    --bg-secondary: #252525;
    --bg-tertiary: #2d2d2d;
    --bg-hover: #3a3a3a;
    --text-primary: #d4d4d4;
    --text-secondary: #b3b3b3;
    --text-tertiary: #808080;
    --border-color: #333333;
    --border-hover: #404040;
    --accent-color: #5a9cff;
    --accent-hover: #4285f4;
    --message-user-bg: #2d2d2d;
    --message-assistant-bg: #252525;
    --message-assistant-border: #333333;
    --input-bg: #252525;
    --sidebar-bg: #1f1f1f;
    --header-bg: #252525;
    --shadow: rgba(0, 0, 0, 0.3);
    /* Scrollbar colors for dark theme */
    --scrollbar-track: #252525;
    --scrollbar-thumb: #404040;
    --scrollbar-thumb-hover: #505050;
}

/* Webkit Scrollbar (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 5px;
    border: 2px solid var(--scrollbar-track);
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

::-webkit-scrollbar-corner {
    background: var(--scrollbar-track);
}

/* Firefox Scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    overflow-y: hidden;
    height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Header */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    width: 42px;
    height: 32px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s;
}

.header-logo:hover {
    transform: scale(1.05);
}

.menu-icon {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
    line-height: 1;
    letter-spacing: -2px;
}

.menu-icon:hover {
    background-color: var(--bg-tertiary);
}

/* Hide mobile model button on desktop */
@media (min-width: 769px) {
    .mobile-model-btn,
    .mobile-model-dropdown {
        display: none !important;
    }
}

/* Hide menu icon on desktop */
@media (min-width: 769px) {
    .menu-icon {
        display: none;
    }
}

.header-center {
    flex: 1;
    text-align: center;
}

.chat-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

body.chat-interface .chat-title {
    display: none;
}

.header-right {
    display: flex;
    align-items: center;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.2s;
}

.new-chat-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.plus-icon {
    font-size: 16px;
    font-weight: 600;
}

/* Main Layout */
.app-layout {
    display: flex;
    margin-top: 50px;
    height: calc(100vh - 50px);
    overflow: hidden;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.sidebar-nav {
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    transition: border-color 0.3s ease;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.nav-item:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    color: var(--text-primary);
    filter: grayscale(100%);
    -webkit-filter: grayscale(100%);
    transition: color 0.3s ease;
}

.nav-text {
    flex: 1;
}

.nav-expand-icon {
    font-size: 10px;
    color: var(--text-tertiary);
    transition: transform 0.3s ease, color 0.2s ease;
    margin-left: auto;
}

.nav-item-expandable.expanded .nav-expand-icon {
    transform: rotate(180deg);
}

.nav-item-expandable.expanded {
    color: var(--text-primary);
}

.nav-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.nav-submenu.expanded {
    max-height: 500px;
    padding: 8px 0;
}

.nav-submenu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px 10px 52px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 400;
}

.nav-submenu-item:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-submenu-icon {
    font-size: 14px;
    width: 20px;
    text-align: center;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.nav-submenu-item:hover .nav-submenu-icon {
    color: var(--text-primary);
}

.nav-submenu-text {
    flex: 1;
}

.integrations-submenu {
    padding-bottom: 6px;
}

.integrations-submenu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px 4px;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.integrations-inline-add-btn {
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.integrations-inline-add-btn:hover {
    background: var(--bg-hover);
}

.integrations-list {
    display: flex;
    flex-direction: column;
    padding: 4px 0 12px;
    max-height: 500px;
    overflow-y: auto;
}

.integrations-empty-state {
    padding: 10px 20px;
    font-size: 13px;
    color: var(--text-secondary);
}

.integration-item {
    padding: 10px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.integration-item:first-child {
    border-top: none;
}

.integration-item-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

.integration-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.integration-item-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.integration-item-info {
    flex: 1;
    min-width: 0;
}

.integration-item-name {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 600;
}

.integration-item-meta {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.integration-item-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.integration-item-meta-source {
    font-size: 12px;
    color: var(--text-secondary);
}

.integration-item-actions {
    display: flex;
    gap: 6px;
}

.integration-status-check {
    color: #1a73e8;
    font-weight: 700;
    font-size: 16px;
}

.integration-remove-btn {
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s ease, color 0.2s ease;
}

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

.integration-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.integration-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.integration-item-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.integration-item-name {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.integration-item-meta {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.integration-item-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.integration-pill {
    border-radius: 999px;
    background: rgba(66, 133, 244, 0.15);
    color: var(--accent-color);
    font-size: 11px;
    padding: 2px 10px;
}

.integration-status-check {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-color);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.integration-remove-btn {
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s ease, color 0.2s ease;
}

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

/* Recents Section */
.recents-section {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.recents-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 20px 12px;
    transition: color 0.3s ease;
}

.recent-item {
    padding: 5px 10px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 0;
    position: relative;
    margin: 2px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.recent-item:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.recent-item:hover .thread-menu-btn {
    opacity: 1;
}

.recent-item.active {
    background-color: var(--bg-tertiary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    margin: 2px 12px;
    padding: 5px 10px;
    color: var(--text-primary);
}

.recent-item.active .thread-menu-btn {
    opacity: 1;
}

.recent-text {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    transition: color 0.3s ease;
    min-width: 0;
}

.thread-menu-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 16px;
    line-height: 1;
    opacity: 0;
    transition: all 0.2s;
    flex-shrink: 0;
}

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

.thread-menu-dropdown {
    position: absolute;
    right: 8px;
    top: 100%;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px var(--shadow);
    transition: background-color 0.3s ease, border-color 0.3s ease;
    z-index: 1000;
    min-width: 140px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all 0.2s ease-out;
}

.thread-menu-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.thread-menu-item {
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.thread-menu-item:first-child {
    border-radius: 6px 6px 0 0;
}

.thread-menu-item:last-child {
    border-radius: 0 0 6px 6px;
}

.thread-menu-item:hover {
    background-color: var(--bg-secondary);
}

.thread-menu-item[data-action="delete"]:hover {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background-color: var(--sidebar-bg);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.invite-section {
    background-color: var(--bg-secondary);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    transition: background-color 0.3s ease;
}

.invite-content {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.invite-icon {
    font-size: 14px;
}

.invite-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.pro-text {
    font-size: 12px;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.user-section {
    margin-top: 16px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background-color: #ff6b35;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.user-details {
    flex: 1;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
    transition: color 0.3s ease;
}

.user-email {
    font-size: 12px;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

/* Main Content */
.main-content {
    flex: 1;
    background-color: var(--bg-primary);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    align-items: center;
    transition: background-color 0.3s ease;
    position: relative;
    min-height: 0;
    padding-bottom: 100px;
    /* Space for fixed input bar - prevents content overlap */
}

/* Chat Messages */
.chat-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    padding-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
    min-height: 0;
    /* Important for flex scrolling - allows container to shrink */
}

/* Ensure messages in chat container can expand fully */
.chat-container .message {
    flex-shrink: 0;
    flex-grow: 0;
    flex-basis: auto;
}

.message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    overflow-wrap: break-word;
    word-wrap: break-word;
    overflow-x: auto !important;
    overflow-y: visible !important;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    display: block !important;
}

/* Force all message variants to expand */
.message.assistant,
.message.user {
    overflow-x: auto !important;
    overflow-y: visible !important;
    height: auto !important;
    max-height: none !important;
    min-height: auto !important;
}

/* Message content container - ensure it expands fully, allow horizontal scroll */
.message-content {
    overflow-y: visible !important;
    overflow-x: auto !important;
    height: auto !important;
    max-height: none !important;
    min-height: auto !important;
}

.message-content p {
    margin-top: 0.6em;
    margin-bottom: 0.6em;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.7;
    word-break: break-word;
    font-family: inherit;
    font-weight: 400;
    letter-spacing: 0.01em;
}

.message-content h2 {
    margin-top: 0.8em;
}

/* Ensure all content within messages can expand fully - no height restrictions, no vertical scrolling */
.message * {
    overflow-y: visible !important;
    height: auto !important;
    max-height: none !important;
    min-height: auto !important;
}

/* Block-level elements only */
.message p,
.message div,
.message h1,
.message h2,
.message h3,
.message h4,
.message h5,
.message h6,
.message ul,
.message blockquote {
    overflow: visible !important;
    display: block;
}

/* Ordered and unordered lists must remain block-level list containers */
.message ol,
.message ul {
    overflow: visible !important;
    display: block;
}

/* Pre-formatted text must remain block to preserve whitespace */
.message pre {
    display: block;
    overflow-x: auto;
    overflow-y: visible;
    margin: 16px 0;
    padding: 16px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Courier New', Courier, 'Liberation Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre !important;
    word-wrap: normal;
    word-break: normal;
    tab-size: 4;
    -webkit-overflow-scrolling: touch;
}

/* Code blocks should be block and preserve whitespace */
.message pre code {
    display: block;
    white-space: pre !important;
    word-wrap: normal;
    word-break: normal;
    background: transparent;
    padding: 0;
    border: none;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

/* Prism.js syntax highlighting integration */
.message pre[class*="language-"] {
    background-color: var(--bg-secondary);
}

.message pre code[class*="language-"] {
    background: transparent;
}

/* Ensure Prism styling works within our custom containers */
.message pre code {
    text-shadow: none;
}

/* Inline code styling */
.message code:not(pre code) {
    display: inline;
    padding: 2px 6px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: 'Courier New', Courier, 'Liberation Mono', monospace;
    font-size: 0.9em;
    white-space: normal;
}

/* List items must remain list-item to show markers */
.message li {
    overflow: visible !important;
    display: list-item;
}

.message>* {
    max-width: 100%;
}

/* Only apply horizontal scroll to wide content elements */
/* Table overflow handled by .message table rule above */

/* Override any inline styles that might restrict height */
.message[style*="height"],
.message[style*="max-height"],
.message[style*="overflow"] {
    height: auto !important;
    max-height: none !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
}

/* Prevent text truncation - ensure all text is visible */
.message {
    text-overflow: clip !important;
    -webkit-line-clamp: none !important;
    line-clamp: none !important;
    white-space: normal !important;
}

.message * {
    text-overflow: clip !important;
    -webkit-line-clamp: none !important;
    line-clamp: none !important;
    white-space: normal !important;
}

/* Override white-space for code blocks to preserve formatting */
.message pre,
.message pre * {
    white-space: pre !important;
    word-wrap: normal !important;
    word-break: normal !important;
}

.message span {
    display: inline !important;
    white-space: normal !important;
    word-break: break-word !important;
}

/* Keep inline markdown elements inline */
.message strong,
.message em,
.message a,
.message code:not(pre code),
.message mark {
    display: inline;
}

.message p,
.message div,
.message h1,
.message h2,
.message h3,
.message h4,
.message h5,
.message h6 {
    display: block !important;
    white-space: normal !important;
    word-break: break-word !important;
}

/* Tables within messages - make scrollable */
.message table {
    width: 100%;
    max-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 16px 0;
    display: table;
    table-layout: auto;
    min-width: 0;
    background-color: var(--message-assistant-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.message table thead {
    background-color: var(--bg-secondary);
}

.message table th {
    padding: 12px 16px;
    text-align: left;
    vertical-align: top;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    word-wrap: break-word;
    white-space: normal;
}

.message table th:last-child {
    border-right: none;
}

.message table td {
    padding: 12px 16px;
    text-align: left;
    vertical-align: top;
    overflow-wrap: break-word;
    word-wrap: break-word;
    white-space: normal;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
}

.message table td:last-child {
    border-right: none;
}

/* Ensure inline elements in table cells align properly */
.message table td *,
.message table th * {
    text-align: inherit;
    vertical-align: inherit;
}

.message table tbody tr:last-child td {
    border-bottom: none;
}

.message table tbody tr:nth-child(even) {
    background-color: var(--bg-secondary);
}

.message table tbody tr:hover {
    background-color: var(--bg-hover);
}

/* Wrap wide content in scrollable containers - horizontal only, vertical expands naturally */
.message>div {
    overflow-x: auto !important;
    overflow-y: visible !important;
    background-color: var(--message-user-bg);
    color: var(--text-primary);
    margin-left: auto;
}

.message.assistant {
    align-self: flex-start;
    background-color: var(--message-assistant-bg);
    color: var(--text-primary);
    border: 1px solid var(--message-assistant-border);
    margin-right: auto;
}

/* Markdown list styling within messages */
.message ul,
.message ol {
    margin: 12px 0;
    padding-left: 24px;
    list-style-position: outside;
}

.message li {
    margin: 6px 0;
    padding-left: 8px;
    line-height: 1.6;
}

.message ul {
    list-style-type: disc;
}

.message ol {
    list-style-type: decimal;
}

.message ul ul,
.message ol ol,
.message ul ol,
.message ol ul {
    margin-top: 6px;
    margin-bottom: 6px;
    padding-left: 20px;
}

/* Message Input */
.message-input-container {
    position: fixed;
    bottom: 0;
    left: 280px;
    /* Account for sidebar width on desktop */
    right: 0;
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    width: calc(100% - 280px);
    /* Account for sidebar width */
    max-width: none;
    transition: background-color 0.3s ease, border-color 0.3s ease, left 0.3s ease, width 0.3s ease;
    z-index: 1000;
    box-shadow: 0 -2px 10px var(--shadow);
}

@media (max-width: 768px) {
    .message-input-container {
        left: 0;
        width: 100%;
    }
}

.message-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--input-bg);
    transition: background-color 0.3s ease;
    border: 1px solid #e9ecef;
    border-radius: 24px;
    padding: 8px 16px;
    transition: border-color 0.2s;
}

.message-input-wrapper:focus-within {
    border-color: var(--accent-color);
}

.message-input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-size: 14px;
    color: var(--text-primary);
    padding: 8px 0;
    transition: color 0.3s ease;
}

.message-input::placeholder {
    color: var(--text-tertiary);
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: transparent;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
    border: 1px solid #666;
}

.input-icon:hover {
    background-color: #f0f0f0;
    border-color: #333;
}

.send-icon {
    background-color: #007bff;
    color: white;
    border: 1px solid #007bff;
}

.send-icon:hover {
    background-color: #0056b3;
    border-color: #0056b3;
}

/* Status indicators */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: #e8f5e8;
    color: #2d5a2d;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    margin: 8px 0;
}

.status-check {
    color: #28a745;
}

/* Integration cards */
.integration-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin: 12px 0;
}

.integration-logo {
    width: 24px;
    height: 24px;
    background-color: #ea4335;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
}

.integration-content {
    flex: 1;
}

.integration-title {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
}

.connect-btn {
    background-color: #f0f0f0;
    color: #333;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.connect-btn:hover {
    background-color: #e0e0e0;
}

/* Success messages */
.success-message {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #28a745;
    font-size: 14px;
    font-weight: 500;
    margin: 8px 0;
}

.success-check {
    color: #28a745;
}

/* Links */
.link {
    color: #007bff;
    text-decoration: underline;
    cursor: pointer;
    font-size: 14px;
}

.link:hover {
    color: #0056b3;
}

[data-theme="dark"] .link {
    color: #cc5500;
}

[data-theme="dark"] .link:hover {
    color: #e66a1a;
}

/* Links in messages */
.message a {
    color: #007bff;
    text-decoration: underline;
}

.message a:hover {
    color: #0056b3;
}

[data-theme="dark"] .message a {
    color: #cc5500;
}

[data-theme="dark"] .message a:hover {
    color: #e66a1a;
}

/* Buttons */
.btn {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

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

/* Desktop close button - hidden on desktop */
.sidebar-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 18px;
    color: #666;
    cursor: pointer;
    z-index: 1002;
    width: 24px;
    height: 24px;
    padding: 0;
    line-height: 1;
    display: none;
    transition: color 0.2s;
}

.sidebar-close:hover {
    color: #333;
}

/* Hide close button on desktop */
@media (min-width: 769px) {
    .sidebar-close {
        display: none;
    }
}

/* Responsive design */
@media (max-width: 1200px) {
    .sidebar {
        width: 240px;
    }
}

@media (max-width: 768px) {

    /* Simplified single-row header */
    .app-header {
        height: 56px;
        flex-direction: row;
        align-items: center;
        padding: 0 12px;
    }

    .app-header::before {
        display: none;
    }

    .app-header>.header-left,
    .app-header>.header-right {
        position: static;
        padding: 0;
        min-height: auto;
        width: auto;
        z-index: 2;
    }

    .app-header>.header-right {
        gap: 8px;
        position: relative;
    }

    .header-center {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 12px;
        gap: 8px;
        min-width: 0;
    }

    body.chat-interface .header-center {
        display: none;
    }

    body.chat-interface .model-selector-container {
        display: none !important;
    }

    /* Mobile Model Button */
    .mobile-model-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border-radius: 8px;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        color: var(--text-primary);
        font-weight: 600;
        font-size: 14px;
        cursor: pointer;
        transition: all 0.2s ease;
        margin-right: 8px;
    }

    .mobile-model-btn:hover {
        background: var(--bg-hover);
        border-color: var(--accent-color);
    }

    .mobile-model-btn.active {
        background: var(--accent-color);
        color: white;
        border-color: var(--accent-color);
    }

    /* Mobile Model Dropdown */
    .mobile-model-dropdown {
        position: absolute;
        top: calc(100% + 8px);
        right: 0;
        background: var(--bg-primary);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        box-shadow: 0 8px 24px var(--shadow);
        min-width: 280px;
        max-width: calc(100vw - 24px);
        max-height: 60vh;
        overflow: hidden;
        z-index: 1001;
        display: flex;
        flex-direction: column;
    }

    .mobile-model-dropdown-header {
        padding: 12px 16px;
        border-bottom: 1px solid var(--border-color);
        font-weight: 600;
        font-size: 14px;
        color: var(--text-primary);
        background: var(--bg-secondary);
    }

    .mobile-model-dropdown-list {
        max-height: calc(60vh - 50px);
        overflow-y: auto;
        padding: 8px 0;
    }

    .mobile-model-item {
        padding: 12px 16px;
        cursor: pointer;
        transition: background-color 0.2s ease;
        border-bottom: 1px solid var(--border-color);
    }

    .mobile-model-item:last-child {
        border-bottom: none;
    }

    .mobile-model-item:hover {
        background: var(--bg-secondary);
    }

    .mobile-model-item.active {
        background: var(--bg-secondary);
        border-left: 3px solid var(--accent-color);
    }

    .mobile-model-item-name {
        font-weight: 500;
        font-size: 14px;
        color: var(--text-primary);
        margin-bottom: 2px;
    }

    .mobile-model-item-provider {
        font-size: 12px;
        color: var(--text-secondary);
    }

    .mobile-model-loading {
        padding: 20px;
        text-align: center;
        color: var(--text-secondary);
        font-size: 14px;
    }

    .app-header>.header-right>.new-chat-btn {
        display: flex;
        padding: 6px 10px;
        font-size: 13px;
    }

    .sidebar {
        width: 280px;
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        transition: left 0.3s ease-in-out;
        z-index: 1001;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar.open {
        left: 0;
    }

    .app-layout {
        margin-top: 56px;
        height: calc(100vh - 56px);
    }

    .main-content {
        width: 100%;
        padding-bottom: 0;
    }

    .chat-container {
        padding-bottom: 20px;
    }

    .chat-container::after {
        content: '';
        display: block;
        min-height: 150px;
        flex-shrink: 0;
        width: 100%;
    }

    .message {
        max-width: 85%;
    }

    /* Overlay for mobile sidebar */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease-in-out,
            visibility 0.3s ease-in-out;
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Close button for mobile sidebar - override desktop styles */
    .sidebar-close {
        display: none;
        position: absolute;
        top: 12px;
        right: 16px;
        font-size: 20px;
        width: 20px;
        height: 20px;
        padding: 0;
        line-height: 1;
    }

    .sidebar.open .sidebar-close {
        display: block;
    }

    /* Adjust sidebar nav to give space for close button */
    .sidebar-nav {
        padding: 40px 0 20px 0;
    }
}

/* Utility classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-4 {
    margin-bottom: 16px;
}

.mt-4 {
    margin-top: 16px;
}

/* Settings Gear Button */
.settings-gear-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-gear-btn:hover {
    background-color: #f0f0f0;
    color: #333;
}

.settings-gear-btn svg {
    transition: transform 0.3s ease;
}

.settings-gear-btn:hover svg {
    transform: rotate(45deg);
}

/* Settings Modal */
.settings-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    animation: fadeIn 0.2s ease-out;
}

.settings-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-modal-content {
    background-color: var(--bg-primary);
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px var(--shadow);
    animation: slideUp 0.3s ease-out;
    transition: background-color 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.settings-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.settings-modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    transition: color 0.3s ease;
}

.settings-close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.2s, color 0.3s ease;
}

.settings-close-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.settings-modal-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.settings-sidebar {
    width: 220px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 16px 0;
    overflow-y: auto;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.settings-tab {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    border-left: 3px solid transparent;
}

.settings-tab:hover {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.settings-tab.active {
    background-color: var(--bg-primary);
    color: var(--accent-color);
    border-left-color: var(--accent-color);
}

.settings-tab svg {
    flex-shrink: 0;
}

.settings-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background-color: var(--bg-primary);
    transition: background-color 0.3s ease;
}

.settings-panel {
    display: none;
}

.settings-panel.active {
    display: block;
}

.settings-panel-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 24px 0;
    transition: color 0.3s ease;
}

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

.settings-form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
    transition: color 0.3s ease;
}

.settings-input,
.settings-select,
.settings-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: border-color 0.2s, background-color 0.3s ease, color 0.3s ease;
}

.settings-input:focus,
.settings-select:focus,
.settings-textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

.settings-textarea {
    resize: vertical;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.settings-range {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    transition: background 0.3s ease;
}

.settings-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    transition: all 0.2s;
}

.settings-range::-webkit-slider-thumb:hover {
    background: var(--accent-hover);
    transform: scale(1.1);
}

.settings-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.settings-range::-moz-range-thumb:hover {
    background: var(--accent-hover);
    transform: scale(1.1);
}

.param-value {
    float: right;
    color: var(--accent-color);
    font-weight: 600;
    transition: color 0.3s ease;
}

.settings-help {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
    transition: color 0.3s ease;
}

.settings-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.settings-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-color);
}

.settings-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    border-radius: 0 0 12px 12px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.settings-footer-right {
    display: flex;
    gap: 12px;
}

/* Integration Modal */
.integration-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2050;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.integration-modal.active {
    display: flex;
}

.integration-modal-content {
    background: var(--bg-primary);
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    border: 1px solid var(--border-color);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.integration-modal-body {
    padding: 20px 24px 30px;
    overflow-y: auto;
    flex: 1;
}

.integrations-management-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.integrations-management-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.integration-modal-close {
    border: none;
    background: transparent;
    font-size: 26px;
    cursor: pointer;
    color: var(--text-secondary);
}

.integration-step-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.integration-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.integration-type-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.integration-type-card:hover {
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.integration-type-card.disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.integration-type-card.disabled:hover {
    border-color: var(--border-color);
    transform: none;
}

.integration-type-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.integration-type-card-text h4 {
    margin: 0;
    font-size: 14px;
}

.integration-type-card-text p {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-secondary);
}

.integration-type-card-footer {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

.integration-disabled-label {
    color: #c53929;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
}

.integration-type-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.integration-type-icon-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.integration-type-icon-letter {
    font-size: 18px;
}

.integration-step.hidden {
    display: none;
}

.integration-selected-summary {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text-primary);
}

.integration-label {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
}

.integration-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.integration-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 8px 0 18px;
}

.integration-config-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.integration-success-icon {
    font-size: 40px;
    margin-bottom: 12px;
    text-align: center;
}

.integration-step h3 {
    margin-top: 0;
}

.integration-step button {
    min-width: 120px;
}

/* Responsive Settings Modal */
@media (max-width: 768px) {
    .settings-modal-content {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .settings-modal-body {
        flex-direction: column;
    }

    .settings-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e9ecef;
        display: flex;
        overflow-x: auto;
        overflow-y: visible;
        padding: 8px 0;
    }

    .settings-tab {
        flex-direction: column;
        gap: 4px;
        padding: 10px 16px;
        min-width: 80px;
        text-align: center;
        border-left: none;
        border-bottom: 3px solid transparent;
    }

    .settings-tab.active {
        border-left: none;
        border-bottom-color: #007bff;
    }

    .settings-tab span {
        font-size: 12px;
    }

    .settings-content {
        padding: 16px;
    }

    .settings-modal-footer {
        flex-direction: column;
        gap: 12px;
    }

    .settings-footer-right {
        width: 100%;
        justify-content: space-between;
    }
}

/* Animation for page load */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.main-content {
    animation: fadeIn 0.3s ease-out;
}

/* Model Aggregator */
.model-aggregator-view {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 24px 32px 40px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    align-self: stretch;
}

.aggregator-hero {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    padding: 24px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--bg-secondary);
}

.aggregator-hero-text h2 {
    margin-bottom: 8px;
    font-size: 24px;
}

.aggregator-hero-text p {
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.aggregator-hero-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hero-pill {
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(66, 133, 244, 0.12);
    color: var(--accent-color);
    font-size: 12px;
    font-weight: 500;
}

.aggregator-hero-status {
    min-width: 160px;
    border-left: 1px solid var(--border-color);
    padding-left: 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.aggregator-hero-status .status-label {
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.aggregator-hero-status .status-value {
    font-size: 18px;
    font-weight: 600;
    margin-top: 4px;
}

.aggregator-layout {
    display: grid;
    grid-template-columns: minmax(320px, 360px) 1fr;
    gap: 24px;
    min-height: 0;
}

.aggregator-config-card,
.aggregator-results-card {
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--bg-primary);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.config-section label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
}

.config-section textarea {
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    padding: 12px;
    color: var(--text-primary);
    resize: vertical;
}

.config-section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.aggregator-counter {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
}

.aggregator-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.aggregator-chip {
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.aggregator-chip:hover {
    background: var(--bg-tertiary);
}

.aggregator-model-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 360px;
    overflow-y: auto;
}

.aggregator-list-placeholder {
    padding: 16px;
    border-radius: 12px;
    border: 1px dashed var(--border-color);
    color: var(--text-secondary);
    text-align: center;
}

.aggregator-model-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.aggregator-model-card.selected {
    border-color: var(--accent-color);
    background: rgba(66, 133, 244, 0.08);
}

.aggregator-model-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.aggregator-model-card input[type="checkbox"] {
    margin: 0;
}

.aggregator-model-card__content {
    flex: 1;
    min-width: 0;
}

.aggregator-model-card__content .model-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.param-control {
    margin-bottom: 12px;
}

.param-control input[type="range"] {
    width: 100%;
}

.config-hint {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
}

.aggregator-alerts {
    min-height: 20px;
}

.aggregator-alert {
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
}

.aggregator-alert.error {
    background: rgba(220, 53, 69, 0.12);
    color: #dc3545;
}

.aggregator-alert.success {
    background: rgba(25, 135, 84, 0.12);
    color: #198754;
}

.aggregator-alert.info {
    background: rgba(66, 133, 244, 0.12);
    color: var(--accent-color);
}

.aggregator-actions {
    display: flex;
    gap: 12px;
}

.aggregator-btn-secondary {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.aggregator-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.aggregator-tab {
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 6px 14px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
}

.aggregator-tab.active {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

.aggregator-panels-wrapper {
    min-height: 400px;
    position: relative;
}

.aggregator-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.aggregator-panel.active {
    display: block;
}

.aggregator-overview-card {
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    background: var(--bg-secondary);
    margin-bottom: 16px;
}

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

.overview-progress .progress-track {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: var(--bg-tertiary);
    overflow: hidden;
    margin-bottom: 8px;
}

.overview-progress .progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: var(--accent-color);
    transition: width 0.3s ease;
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

.overview-log {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.log-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 6px 8px;
    border-radius: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
}

.log-row.running {
    border-color: var(--accent-color);
}

.log-row.error {
    border-color: #dc3545;
    color: #dc3545;
}

.log-time {
    font-weight: 600;
}

.aggregator-empty-state {
    border: 1px dashed var(--border-color);
    border-radius: 16px;
    padding: 32px;
    text-align: center;
    color: var(--text-secondary);
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.aggregator-model-panel {
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    background: var(--bg-primary);
    margin-bottom: 16px;
}

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

.status-chip {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.status-chip.status-completed {
    background: rgba(25, 135, 84, 0.15);
    color: #198754;
}

.status-chip.status-running {
    background: rgba(66, 133, 244, 0.15);
    color: var(--accent-color);
}

.status-chip.status-error {
    background: rgba(220, 53, 69, 0.15);
    color: #dc3545;
}

.status-chip.status-pending {
    background: rgba(108, 117, 125, 0.15);
    color: #6c757d;
}

.model-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px;
    border-radius: 12px;
    background: var(--bg-secondary);
}

.summary-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-value {
    font-size: 14px;
    font-weight: 600;
}

.aggregator-response-body {
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 16px;
    background: var(--bg-secondary);
    white-space: pre-wrap;
    font-size: 14px;
    margin-bottom: 16px;
}

.aggregator-response-body.error {
    border-color: #dc3545;
    color: #dc3545;
}

.aggregator-critique {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
}

.critique-summary {
    font-weight: 600;
    margin-bottom: 12px;
}

.critique-notes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.critique-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.critique-column ul {
    margin-top: 6px;
    padding-left: 16px;
}

.aggregator-tabs-container[data-layout="grid"] .aggregator-tabs {
    display: none;
}

.aggregator-tabs-container[data-layout="grid"] .aggregator-panel {
    display: block !important;
}

@media (max-width: 1200px) {
    .aggregator-layout {
        grid-template-columns: 1fr;
    }

    .aggregator-config-card {
        order: 2;
    }

    .aggregator-results-card {
        order: 1;
    }
}

@media (max-width: 768px) {
    .model-aggregator-view {
        padding: 16px;
    }

    .aggregator-hero {
        flex-direction: column;
    }

    .aggregator-hero-status {
        border-left: none;
        border-top: 1px solid var(--border-color);
        padding-left: 0;
        padding-top: 16px;
    }

    .aggregator-actions {
        flex-direction: column;
    }
}

/* ============================================================
   Toast Notifications
   ============================================================ */

.toast-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 400px;
    min-width: 280px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: 0 8px 32px var(--shadow);
    z-index: 10000;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast-notification.toast-visible {
    opacity: 1;
    transform: translateX(0);
}

.toast-notification.toast-hiding {
    opacity: 0;
    transform: translateX(100%);
}

.toast-message {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

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

/* Toast Types */
.toast-success {
    border-left: 4px solid #10b981;
}

.toast-success .toast-message {
    color: #10b981;
}

.toast-error {
    border-left: 4px solid #ef4444;
}

.toast-error .toast-message {
    color: #ef4444;
}

.toast-warning {
    border-left: 4px solid #f59e0b;
}

.toast-info {
    border-left: 4px solid var(--accent-color);
}

/* Mobile Toast */
@media (max-width: 768px) {
    .toast-notification {
        top: auto;
        bottom: 20px;
        left: 20px;
        right: 20px;
        max-width: none;
        min-width: auto;
    }
}

/* ============================================================
   Integration Email Display
   ============================================================ */

.integration-item-email {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 2px;
    font-family: 'Inter', system-ui, sans-serif;
    letter-spacing: 0.01em;
}

.integration-status-check.status-connected {
    color: #10b981;
}

.integration-status-check.status-disconnected {
    color: #f59e0b;
}

/* Integration card enhancements for multi-account display */
.integration-type-card .integration-account-count {
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}