/* =================================================================
   SparkAI Sidebar - Extracted from Pages Template
   Only includes sidebar, header, footer styles
   ================================================================= */

/* Font Face - Pages Icon */
@font-face {
    font-family: "pages-icon";
    src: url("../fonts/pages-icon/pages-icon.eot");
    src: url("../fonts/pages-icon/pages-icon.eot?#iefix") format("embedded-opentype"), url("../fonts/pages-icon/pages-icon.woff") format("woff"), url("../fonts/pages-icon/pages-icon.ttf") format("truetype"), url("../fonts/pages-icon/pages-icon.svg#pages-icon") format("svg");
    font-weight: normal;
    font-style: normal;
    font-display: block;
}

/* Base Styles */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Inter UI", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #212121;
    background: #f5f7fa;
    min-height: 100vh;
}

    body.fixed-header {
        padding-top: 45px;
    }

    /* Home page uses all fixed-position elements — body scroll is unnecessary.
       Must target BOTH html and body: Chrome's viewport scrollbar comes from html,
       not body. overflow:hidden on body alone does not kill the scrollbar gutter. */
    body.home-body {
        overflow: hidden;
    }

    html:has(.home-body) {
        overflow: hidden;
        scrollbar-width: none;
    }

    html:has(.home-body)::-webkit-scrollbar {
        display: none;
    }

/* =================================================================
   SIDEBAR
   ================================================================= */
.page-sidebar {
    width: 280px;
    background-color: var(--s-sidebar-bg, #f0ebe4);
    z-index: 1000;
    left: -210px;
    position: fixed;
    bottom: 0;
    top: 0;
    transition: left 0.4s cubic-bezier(0.05, 0.74, 0.27, 0.99);
}

    .page-sidebar a,
    .page-sidebar button {
        text-decoration: none;
        outline: none;
    }

/* Sidebar Header */
.sidebar-header {
    height: 45px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

    .sidebar-header .brand {
        max-height: 22px;
        color: #ffffff;
        font-weight: 700;
        font-size: 16px;
    }

.sidebar-header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.4s cubic-bezier(0.05, 0.74, 0.27, 0.99);
}

.btn-icon-link {
    background: none;
    border: none;
    color: #929aac;
    cursor: pointer;
    padding: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

    .btn-icon-link:hover {
        color: #fff;
    }

/* Pin Button Icon */
[data-toggle-pin="sidebar"] > i:before {
    content: "\e98c";
}

body.menu-pin [data-toggle-pin="sidebar"] > i:before {
    content: "\e9a2";
}

/* Sidebar Menu */
.sidebar-menu {
    padding: 0 0 40px;
    overflow-y: auto;
    height: calc(100vh - 45px);
}

.menu-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-title {
    padding: 20px 32px 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #e1e1e1;
    margin: 0;
}

/* Menu Items */
.menu-items > li {
    display: block;
    padding: 0;
    clear: right;
    position: relative;
}

    .menu-items > li:after,
    .menu-items > li:before {
        display: table;
        content: " ";
        clear: both;
    }

    /* Link Styling */
    .menu-items > li > a {
        font-family: "Inter UI", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
        display: inline-block;
        padding-left: 32px;
        min-height: 40px;
        line-height: 40px;
        font-size: 13px;
        font-weight: 500;
        letter-spacing: 0.14px;
        color: #929aac;
        clear: both;
        transition: color 0.2s;
    }

.menu-items li > a {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 65%;
}

/* Title inside link */
.menu-items > li > a > .title {
    float: left;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    width: 65%;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Hide title in collapsed sidebar */
.page-sidebar:not(:hover) .menu-items > li > a > .title {
    opacity: 0;
    transform: translateX(-8px);
}

/* Detailed Links */
.menu-items > li > a.detailed {
    min-height: auto;
    line-height: normal;
    padding-top: 8px;
    padding-bottom: 8px;
    display: inline-block;
}

    .menu-items > li > a.detailed > .title {
        display: block;
        line-height: 28px;
        font-weight: 500;
        float: left;
        width: 65%;
    }

    .menu-items > li > a.detailed > .details {
        display: block;
        line-height: 16px;
        font-size: 11px;
        color: rgba(146, 154, 172, 0.7);
        clear: both;
    }

/* Icon Thumbnail */
.icon-thumbnail {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    height: 40px;
    width: 40px;
    line-height: 40px;
    text-align: center;
    position: relative;
    float: right;
    margin-right: 14px;
    color: #929aac;
    transition: transform 0.4s cubic-bezier(0.05, 0.74, 0.27, 0.99), color 0.2s;
    font-weight: bold;
    font-family: "Inter UI", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.pg-icon {
    font-family: "pages-icon" !important;
    speak: never;
    font-size: 20px;
    font-style: normal;
    font-weight: normal;
    font-variant: normal;
    text-transform: none;
    line-height: 1;
    direction: ltr;
    word-wrap: normal;
    white-space: nowrap;
    letter-spacing: 0;
    -webkit-font-feature-settings: "liga";
    -moz-font-feature-settings: "liga=1";
    -moz-font-feature-settings: "liga";
    -ms-font-feature-settings: "liga" 1;
    font-feature-settings: "liga";
    -webkit-font-variant-ligatures: discretionary-ligatures;
    font-variant-ligatures: discretionary-ligatures;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.icon-thumbnail > i {
    font-size: 20px;
}

.icon-thumbnail svg {
    width: 20px;
    height: 20px;
    stroke-width: 1.5;
}

.menu-items > li > .icon-thumbnail:first-letter {
    text-transform: uppercase;
}

/* Hover States */
.menu-items li:hover > a,
.menu-items li.active > a,
.menu-items li.open > a {
    color: #fff;
    background: linear-gradient(90deg, rgba(146, 154, 172, 0.1) 0%, transparent 100%);
}

.menu-items li:hover > .icon-thumbnail,
.menu-items li.active > .icon-thumbnail,
.menu-items li.open > .icon-thumbnail {
    color: #E7DFF3;
}

/* Arrow for Submenu */
.menu-items > li > a > .arrow {
    float: right;
    padding-right: 25px;
}

    .menu-items > li > a > .arrow:before {
        float: right;
        display: inline;
        font-size: 16px;
        font-family: "pages-icon";
        height: auto;
        content: "\e989";
        font-weight: 300;
        text-shadow: none;
        transition: all 0.12s ease;
    }

    .menu-items > li > a > .arrow.open:before,
    .menu-items > li.open > a > .arrow:before {
        transform: rotate(-90deg);
    }

/* Submenu */
.menu-items > li > ul.sub-menu {
    display: none;
    list-style: none;
    clear: both;
    margin: 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.15);
}

.menu-items > li.open > ul.sub-menu {
    display: block;
}

.menu-items > li > ul.sub-menu > li {
    position: relative;
    padding-left: 20px;
    clear: right;
}

    .menu-items > li > ul.sub-menu > li:after,
    .menu-items > li > ul.sub-menu > li:before {
        display: table;
        content: " ";
        clear: both;
    }

    .menu-items > li > ul.sub-menu > li > a {
        display: inline-block;
        padding-left: 32px;
        padding-right: 20px;
        min-height: 35px;
        line-height: 35px;
        font-size: 13px;
        color: rgba(146, 154, 172, 0.9);
    }

    .menu-items > li > ul.sub-menu > li > .icon-thumbnail {
        height: 35px;
        width: 35px;
        line-height: 35px;
        font-size: 10px;
        margin-right: 10px;
    }

/* Sidebar Visible State (Hover) */
body.sidebar-visible .page-sidebar {
    left: 0;
    overflow: visible;
}

    body.sidebar-visible .page-sidebar .menu-items .icon-thumbnail {
        transform: translate3d(-14px, 0, 0);
    }

    body.sidebar-visible .page-sidebar .menu-items > li > a > .title {
        opacity: 1;
        transform: translateX(0);
    }

    body.sidebar-visible .page-sidebar .sidebar-header-controls {
        transform: translate3d(10px, 0, 0);
    }

/* Sidebar Pinned State */
body.menu-pin .page-sidebar {
    left: 0;
    width: 250px;
    transform: translate3d(0, 0, 0);
    overflow: visible;
}

    body.menu-pin .page-sidebar .menu-items .icon-thumbnail {
        transform: translate3d(-14px, 0, 0);
    }

    body.menu-pin .page-sidebar .menu-items > li > a > .title {
        opacity: 1 !important;
        transform: translateX(0) !important;
    }

    body.menu-pin .page-sidebar .sidebar-header-controls {
        transform: translate3d(10px, 0, 0);
    }

/* Spacing Utilities */
.m-t-20 {
    margin-top: 20px;
}

.m-b-40 {
    margin-bottom: 40px;
}

/* =================================================================
   PAGE CONTAINER
   ================================================================= */
.page-container {
    margin-left: 70px;
    transition: margin-left 0.4s cubic-bezier(0.05, 0.74, 0.27, 0.99);
}

body.menu-pin .page-container {
    margin-left: 250px;
}

/* =================================================================
   HEADER
   ================================================================= */
.header {
    position: fixed;
    top: 0;
    left: 70px;
    right: 0;
    height: 45px;
    background: #fff;
    border-bottom: 1px solid #e6e6e6;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    transition: left 0.4s cubic-bezier(0.05, 0.74, 0.27, 0.99);
}

body.menu-pin .header {
    left: 250px;
}

.header .brand {
    max-height: 22px;
    transition: opacity 0.3s;
}

/* Hide logo when main sidebar is visible or pinned */
body.sidebar-visible .header .brand,
body.menu-pin .header .brand {
    opacity: 0;
    pointer-events: none;
}

/* =================================================================
   HEADER — breadcrumb back-link (Products, Output, Publish pages)
   ================================================================= */
.header-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0;
    overflow: hidden;
    min-width: 0;
}

.header-back-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
    color: #7c3aed;
    text-decoration: none;
    white-space: nowrap;
    padding: 4px 6px 4px 2px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

    .header-back-btn:hover {
        background: #ede9fe;
        color: #6d28d9;
        text-decoration: none;
    }

    .header-back-btn svg {
        width: 14px;
        height: 14px;
        stroke-width: 2;
        flex-shrink: 0;
    }

.header-breadcrumb-divider {
    width: 1px;
    height: 14px;
    background: #d1d5db;
    margin: 0 8px;
    flex-shrink: 0;
}

.header-breadcrumb-title {
    font-size: 13px;
    font-weight: 600;
    color: #1a1628;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-link {
    font-size: 12px;
    color: #929aac;
    cursor: pointer;
}

    .search-link i {
        margin-right: 5px;
    }

/* Profile Dropdown */
.profile-dropdown-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.thumbnail-wrapper {
    display: inline-block;
    border-radius: 50%;
    overflow: hidden;
}

    .thumbnail-wrapper img {
        display: block;
    }

.d32 {
    width: 32px;
    height: 32px;
}

/* =================================================================
   CONTENT
   ================================================================= */
.page-content-wrapper {
    padding-top: 45px;
}

.content {
    padding: 20px;
    min-height: calc(100vh - 105px);
    background: #f6f7fa;
    position: relative;
    display: none;
}

/* =================================================================
   FEATHER ICONS (Thin style)
   ================================================================= */
svg.feather {
    stroke-width: 1.3px;
}

/* Header toolbar icons */
.secondary-toolbar-btn svg {
    width: 18px;
    height: 18px;
    margin-right: 4px;
}

/* Dropdown menu icons */
.dropdown-item svg {
    width: 16px;
    height: 16px;
    margin-right: 8px;
}

/* Chat action button icons */
.chat-action-btn svg {
    width: 14px;
    height: 14px;
}

/* Menu dropdown toggle */
.menu-dropdown-toggle svg {
    width: 20px;
    height: 20px;
}

/* Toggle sidebar icon */
.toggle-sidebar svg {
    width: 24px;
    height: 24px;
}

/* Pin/unpin icon */
.btn-icon-link img,
.btn-icon-link svg {
    width: 18px;
    height: 18px;
}

.pin-icon {
    transition: opacity 0.3s ease;
}

[data-feather] {
    width: 16px !important;
    height: 16px !important;
}

/* Or target specific sizes */
.feather-small {
    width: 16px !important;
    height: 16px !important;
}

.feather-large {
    width: 32px !important;
    height: 32px !important;
}

.sidebar-view [data-feather] {
    width: 16px !important;
    height: 16px !important;
}

/* Button icons medium */
.btn [data-feather] {
    width: 18px !important;
    height: 18px !important;
}

/* Header icons larger */
.header [data-feather] {
    width: 20px !important;
    height: 20px !important;
}

svg[data-feather],
.feather,
svg.feather {
    width: 16px !important;
    height: 16px !important;
}

#mcpHeaders {
    width: 100% !important;
}

#mcpTools {
    width: 100% !important;
}

/* =================================================================
   CENTERED WELCOME SCREEN
   ================================================================= */
.chat-welcome-container {
    position: fixed;
    top: 45px;
    left: 365px;
    right: 20px;
    bottom: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f6f7fa;
    opacity: 1;
    transition: all 0.3s ease;
    pointer-events: auto;
}

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

/* Adjust for pinned sidebar */
body.menu-pin .chat-welcome-container {
    left: 545px;
}

.chat-welcome-content {
    width: 100%;
    max-width: 900px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

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

    .welcome-greeting h1 {
        font-size: 32px;
        font-weight: 600;
        margin: 0;
        color: #2b303b;
    }

/* Welcome Suggestions */
.welcome-suggestions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
}

.suggestion-card {
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

    .suggestion-card:hover {
        border-color: #E7DFF3;
        background: #fafafa;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    }

    .suggestion-card i {
        width: 20px;
        height: 20px;
        color: #E7DFF3;
        flex-shrink: 0;
    }

    .suggestion-card span {
        font-size: 13px;
        color: #2b303b;
        line-height: 1.4;
    }

/* Responsive - Tablet */
@media (max-width: 991px) {
    .chat-welcome-container {
        left: 20px;
    }

    .chat-messages-area {
        left: 20px;
    }

    .chat-container.bottom-mode {
        left: 20px;
        right: 20px;
    }

    body.menu-pin .chat-container.bottom-mode {
        left: 20px;
    }

    body.menu-pin .chat-welcome-container {
        left: 20px;
    }

    body.menu-pin .chat-messages-area {
        left: 20px;
    }

    .welcome-suggestions {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .chat-welcome-container {
        left: 10px;
        right: 10px;
        bottom: 56px; /* clear mobile-bottom-bar (56px high) — was 0 */
    }

    .chat-messages-area {
        left: 10px;
        right: 10px;
    }

    .chat-container.bottom-mode {
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

    body.menu-pin .chat-container.bottom-mode {
        left: 10px;
    }

    body.menu-pin .chat-welcome-container {
        left: 10px;
    }

    body.menu-pin .chat-messages-area {
        left: 10px;
    }

    .chat-welcome-content {
        max-width: 100%;
        gap: 20px;
    }

    .welcome-greeting h1 {
        font-size: 28px;
    }

    .welcome-suggestions {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .suggestion-card {
        padding: 14px;
    }
}

/* Touch tablets in portrait (iPad, Surface): mobile-bottom-bar is visible
   here too (see rule at line ~8268), so the chat overlays need the same
   56px lift. Mirrors the (max-width: 768px) rules above. */
@media (pointer: coarse) and (min-width: 769px) and (max-width: 1024px) {
    .chat-welcome-container {
        bottom: 56px; /* clear mobile-bottom-bar (56px high) */
    }
    .chat-container.bottom-mode {
        bottom: calc(10px + 56px);
    }
    .chat-messages-area {
        bottom: calc(130px + 56px);
    }
}

/* =================================================================
   CHAT MESSAGES AREA
   ================================================================= */

.chat-messages-area {
    position: fixed;
    top: 45px;
    left: 365px;
    right: 20px;
    bottom: 130px;
    z-index: 800;
    background: #f6f7fa;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

    .chat-messages-area.visible {
        opacity: 1;
        pointer-events: auto;
    }
/* Adjust for pinned sidebar */
body.menu-pin .chat-messages-area {
    left: 545px;
}
/* Center messages with same width as chatbox */
.chat-messages-wrapper {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100%;
}

overflow: hidden;
transition: left 0.4s cubic-bezier(0.05, 0.74, 0.27, 0.99);
}

body.menu-pin .chat-messages-area {
    left: 545px;
}

.chat-messages-wrapper {
    max-width: 900px;
    height: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 20px;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    padding: 20px 0;
}

/* Load older messages button */
.load-older-messages {
    padding: 10px 20px;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    cursor: pointer;
    color: #E7DFF3;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    margin: 0 auto 16px auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

    .load-older-messages:hover {
        background: #E7DFF3;
        color: #fff;
        border-color: #E7DFF3;
    }

    .load-older-messages i {
        width: 16px;
        height: 16px;
    }

/* Message item */
.message-item {
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

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

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

.user-message {
    align-self: flex-end;
    max-width: 70%;
}

.assistant-message {
    align-self: stretch;
    width: 100%;
    background: #f6f7fa;
    padding: 20px 0;
    margin-left: -20px; /* Extend to wrapper edges */
    margin-right: -20px;
    padding-left: 20px;
    padding-right: 20px;
}

/* Message bubble */
.message-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    position: relative;
    padding-bottom: 40px;
    max-width: 900px;
}

.user-message .message-bubble {
    background: #DBF6F7;
    padding-bottom: 10px;
}

.assistant-message .message-bubble {
    background: transparent;
}

/* Agent Indicator */
.agent-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    padding: 4px 8px;
    background: rgba(114, 82, 211, 0.1);
    border-radius: 6px;
    font-size: 12px;
    width: fit-content;
}

    .agent-indicator .agent-icon i {
        width: 14px;
        height: 14px;
        color: #7252D3;
    }

    .agent-indicator .agent-name {
        font-weight: 600;
        color: #7252D3;
    }

.message-text {
    font-size: 14px;
    line-height: 1.5;
    color: #212121;
    word-wrap: break-word;
}

    /* =================================================================
   MARKDOWN STYLING IN MESSAGES
   ================================================================= */

    /* Headings */
    .message-text h1,
    .message-text h2,
    .message-text h3,
    .message-text h4,
    .message-text h5,
    .message-text h6 {
        margin: 16px 0 8px 0;
        font-weight: 600;
        line-height: 1.3;
        color: #2b303b;
    }

    .message-text h1 {
        font-size: 24px;
        border-bottom: 2px solid #e6e6e6;
        padding-bottom: 8px;
    }

    .message-text h2 {
        font-size: 20px;
        border-bottom: 1px solid #e6e6e6;
        padding-bottom: 6px;
    }

    .message-text h3 {
        font-size: 18px;
    }

    .message-text h4 {
        font-size: 16px;
    }

    .message-text h5,
    .message-text h6 {
        font-size: 14px;
    }

    /* First heading no top margin */
    .message-text h1:first-child,
    .message-text h2:first-child,
    .message-text h3:first-child,
    .message-text h4:first-child {
        margin-top: 0;
    }

    /* Paragraphs */
    .message-text p {
        margin: 8px 0;
    }

        .message-text p:first-child {
            margin-top: 0;
        }

        .message-text p:last-child {
            margin-bottom: 0;
        }

    /* Lists */
    .message-text ul,
    .message-text ol {
        margin: 8px 0;
        padding-left: 24px;
    }

    .message-text li {
        margin: 4px 0;
        line-height: 1.6;
    }

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

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

    .message-text ul ul {
        list-style-type: circle;
    }

        .message-text ul ul ul {
            list-style-type: square;
        }

    /* Inline code */
    .message-text code {
        background: rgba(0, 0, 0, 0.05);
        padding: 2px 6px;
        border-radius: 3px;
        font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
        font-size: 13px;
        color: #c7254e;
    }

    /* Code blocks */
    .message-text pre {
        background: #2b303b;
        color: #f8f8f2;
        padding: 16px;
        border-radius: 6px;
        overflow-x: auto;
        margin: 12px 0;
        border: 1px solid #1d2026;
    }

        .message-text pre code {
            background: none;
            padding: 0;
            color: inherit;
            font-size: 13px;
            line-height: 1.5;
        }

    /* Blockquotes */
    .message-text blockquote {
        border-left: 4px solid #E7DFF3;
        margin: 12px 0;
        padding: 8px 0 8px 16px;
        background: rgba(231, 223, 243, 0.1);
        color: #5a5a5a;
        font-style: italic;
    }

        .message-text blockquote p {
            margin: 4px 0;
        }

    /* Horizontal rule */
    .message-text hr {
        border: none;
        border-top: 1px solid #e6e6e6;
        margin: 16px 0;
    }

    /* Links */
    .message-text a {
        color: #E7DFF3;
        text-decoration: none;
        border-bottom: 1px solid transparent;
        transition: border-color 0.2s;
    }

        .message-text a:hover {
            border-bottom-color: #E7DFF3;
        }

    /* Tables */
    .message-text table {
        border-collapse: collapse;
        width: 100%;
        margin: 12px 0;
        font-size: 13px;
    }

    .message-text th,
    .message-text td {
        border: 1px solid #e6e6e6;
        padding: 8px 12px;
        text-align: left;
    }

    .message-text th {
        background: rgba(231, 223, 243, 0.2);
        font-weight: 600;
        color: #2b303b;
    }

    .message-text tr:nth-child(even) {
        background: rgba(0, 0, 0, 0.02);
    }

    /* Strong/Bold */
    .message-text strong,
    .message-text b {
        font-weight: 600;
        color: #2b303b;
    }

    /* Emphasis/Italic */
    .message-text em,
    .message-text i {
        font-style: italic;
    }

    /* Strikethrough */
    .message-text del,
    .message-text s {
        text-decoration: line-through;
        opacity: 0.7;
    }

    /* Checkboxes (task lists) */
    .message-text input[type="checkbox"] {
        margin-right: 8px;
    }

    /* Image styling */
    .message-text img {
        max-width: 100%;
        height: auto;
        border-radius: 6px;
        margin: 8px 0;
    }

    /* Dividers */
    .message-text .divider {
        margin: 16px 0;
        text-align: center;
        color: #9a9a9a;
        font-size: 12px;
    }

    /* Emoji */
    .message-text .emoji {
        font-size: 18px;
        vertical-align: middle;
    }

    /* Highlight/Mark */
    .message-text mark {
        background: rgba(255, 235, 59, 0.4);
        padding: 2px 4px;
        border-radius: 2px;
    }

    /* Keyboard keys */
    .message-text kbd {
        background: #2b303b;
        color: #fff;
        padding: 2px 6px;
        border-radius: 3px;
        font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
        font-size: 12px;
        border: 1px solid #1d2026;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    }

    /* Abbreviations */
    .message-text abbr {
        border-bottom: 1px dotted #E7DFF3;
        cursor: help;
    }

    /* Subscript and superscript */
    .message-text sub,
    .message-text sup {
        font-size: 75%;
        line-height: 0;
        position: relative;
        vertical-align: baseline;
    }

    .message-text sup {
        top: -0.5em;
    }

    .message-text sub {
        bottom: -0.25em;
    }

    /* Definition lists */
    .message-text dl {
        margin: 12px 0;
    }

    .message-text dt {
        font-weight: 600;
        color: #2b303b;
        margin-top: 8px;
    }

    .message-text dd {
        margin: 4px 0 4px 24px;
        color: #5a5a5a;
    }

    /* Badges/Pills */
    .message-text .badge {
        display: inline-block;
        padding: 2px 8px;
        font-size: 11px;
        font-weight: 600;
        line-height: 1;
        color: #fff;
        background: #E7DFF3;
        border-radius: 12px;
        margin: 0 4px;
        vertical-align: middle;
    }

    /* Info boxes */
    .message-text .info-box {
        background: rgba(231, 223, 243, 0.15);
        border-left: 4px solid #E7DFF3;
        padding: 12px 16px;
        margin: 12px 0;
        border-radius: 4px;
    }

        .message-text .info-box.warning {
            background: rgba(255, 193, 7, 0.15);
            border-left-color: #ffc107;
        }

        .message-text .info-box.error {
            background: rgba(244, 67, 54, 0.15);
            border-left-color: #f44336;
        }

        .message-text .info-box.success {
            background: rgba(76, 175, 80, 0.15);
            border-left-color: #4caf50;
        }

    /* Code language badge */
    .message-text pre[class*="language-"]::before {
        content: attr(class);
        position: absolute;
        top: 8px;
        right: 8px;
        font-size: 10px;
        text-transform: uppercase;
        color: rgba(255, 255, 255, 0.5);
        background: rgba(255, 255, 255, 0.1);
        padding: 2px 6px;
        border-radius: 3px;
    }

    .message-text pre {
        position: relative;
    }

    /* Footnotes */
    .message-text .footnote {
        font-size: 12px;
        color: #9a9a9a;
        vertical-align: super;
    }

    /* Details/Summary (collapsible) */
    .message-text details {
        margin: 12px 0;
        padding: 12px;
        background: rgba(0, 0, 0, 0.02);
        border-radius: 6px;
        border: 1px solid #e6e6e6;
    }

    .message-text summary {
        cursor: pointer;
        font-weight: 600;
        color: #2b303b;
        user-select: none;
    }

        .message-text summary:hover {
            color: #E7DFF3;
        }

    .message-text details[open] summary {
        margin-bottom: 8px;
        padding-bottom: 8px;
        border-bottom: 1px solid #e6e6e6;
    }

    /* Enhanced list styling */
    .message-text li::marker {
        color: #E7DFF3;
    }

    /* Nested lists */
    .message-text ul ul,
    .message-text ol ol,
    .message-text ul ol,
    .message-text ol ul {
        margin: 4px 0;
    }

    /* Better spacing for consecutive elements */
    .message-text h1 + p,
    .message-text h2 + p,
    .message-text h3 + p,
    .message-text h4 + p {
        margin-top: 8px;
    }

    .message-text p + h1,
    .message-text p + h2,
    .message-text p + h3,
    .message-text p + h4 {
        margin-top: 20px;
    }

    /* Code copy button styling (if added via JS) */
    .message-text .code-copy-btn {
        position: absolute;
        top: 8px;
        right: 8px;
        padding: 4px 8px;
        font-size: 11px;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        color: #fff;
        border-radius: 4px;
        cursor: pointer;
        opacity: 0.6;
        transition: opacity 0.2s;
    }

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

/* Message actions */
.message-actions {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

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

/* Hide actions on user messages - only show on assistant messages */
.user-message .message-actions {
    display: none;
}

.message-action-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5a5a5a;
    transition: all 0.2s;
    padding: 0;
}

    .message-action-btn:hover {
        background: rgba(255, 255, 255, 0.9);
    }

    .message-action-btn.active {
        background: #E7DFF3;
        color: #fff;
    }

    .message-action-btn svg {
        width: 12px;
        height: 12px;
        stroke-width: 1.3px;
    }

/* =================================================================
   THINKING/LOADING ANIMATION
   ================================================================= */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    margin-bottom: 16px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    max-width: 200px;
}

.thinking-logo {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thinking-emoji {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

    .thinking-emoji i {
        width: 20px;
        height: 20px;
        color: #7252D3;
        animation: thinking-pulse 1.5s ease-in-out infinite;
    }

@keyframes thinking-pulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.thinking-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}

.thinking-dot {
    width: 8px;
    height: 8px;
    background: #E7DFF3;
    border-radius: 50%;
    animation: thinking-bounce 1.4s infinite ease-in-out both;
}

    .thinking-dot:nth-child(1) {
        animation-delay: -0.32s;
    }

    .thinking-dot:nth-child(2) {
        animation-delay: -0.16s;
    }

@keyframes thinking-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* =================================================================
   CHAT BOX
   ================================================================= */
.chat-container {
    width: 100%;
    position: relative;
    z-index: 1;
    transition: all 0.4s cubic-bezier(0.05, 0.74, 0.27, 0.99);
}

    /* After first message - move to bottom */
    .chat-container.bottom-mode {
        position: fixed;
        bottom: 20px;
        left: 365px;
        right: 20px;
        width: auto;
        z-index: 900;
    }

body.menu-pin .chat-container.bottom-mode {
    left: 545px;
}

/* Wrapper - contains shadow for both boxes */
.chat-wrapper {
    max-width: 900px;
    margin: 0 auto;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Base chat box styles - no shadow */
.chat-box {
    background: #fff;
    padding: 20px;
}

/* Top box - Input (rounded top, square bottom) */
.chat-box-input {
    border-radius: 20px 20px 0 0;
    padding-bottom: 16px;
}

/* Bottom box - Buttons (square top, rounded bottom) */
.chat-box-actions {
    border-radius: 0 0 20px 20px;
    padding-top: 16px;
}

/* Input container - wraps textarea */
.chat-input-container {
    display: flex;
    width: 100%;
}

/* Input textarea */
.chat-input {
    flex: 1;
    width: 100%;
    height: auto;
    border: none;
    outline: none;
    font-size: 14px;
    color: #212121;
    background: transparent;
    resize: none;
    font-family: inherit;
    line-height: 1.5;
    min-height: 21px;
    max-height: 150px;
    overflow-y: auto;
    padding: 0;
}

    .chat-input::-webkit-scrollbar {
        width: 6px;
    }

    .chat-input::-webkit-scrollbar-track {
        background: transparent;
    }

    .chat-input::-webkit-scrollbar-thumb {
        background: #d0d0d0;
        border-radius: 3px;
    }

        .chat-input::-webkit-scrollbar-thumb:hover {
            background: #b0b0b0;
        }

    .chat-input:focus {
        outline: none;
    }

    .chat-input::placeholder {
        color: #929aac;
    }

/* Buttons row */
.chat-actions {
    display: block;
    overflow: hidden;
}

.chat-actions-left {
    float: left;
    display: inline-block;
}

.chat-actions-right {
    float: right;
    display: inline-block;
}

/* Button styles */
.chat-add-btn,
.chat-voice-btn,
.chat-waveform-btn,
.chat-send-btn {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: #5a5a5a;
    transition: all 0.2s;
    vertical-align: middle;
    text-align: center;
    line-height: 32px;
    margin-left: 4px;
}

    .chat-add-btn:first-child {
        margin-left: 0;
    }

    .chat-add-btn:hover,
    .chat-voice-btn:hover,
    .chat-waveform-btn:hover {
        background: #f0f0f0;
    }

.chat-send-btn {
    background: #fff;
    color: #5a5a5a;
    border: 1px solid #e6e6e6;
}

    .chat-send-btn:hover {
        background: #f5f5f5;
        border-color: #d0d0d0;
    }

    .chat-add-btn .material-icons,
    .chat-voice-btn .material-icons,
    .chat-waveform-btn .material-icons,
    .chat-send-btn .material-icons {
        font-size: 20px;
        vertical-align: middle;
        line-height: 32px;
    }

    /* Feather icons in buttons */
    .chat-add-btn svg,
    .chat-voice-btn svg,
    .chat-waveform-btn svg,
    .chat-send-btn svg {
        width: 18px;
        height: 18px;
        vertical-align: middle;
        display: block;
    }

/* Voice recording states */
.chat-voice-btn.recording {
    background: #eb4a4a !important;
    color: #fff !important;
    animation: voice-pulse 1s ease-in-out infinite;
}
.chat-voice-btn.recording svg { color: #fff; stroke: #fff; }

.chat-voice-btn.transcribing {
    background: var(--s-accent, #6d5eac) !important;
    color: #fff !important;
    opacity: 0.7;
    animation: voice-pulse 0.6s ease-in-out infinite;
}
.chat-voice-btn.transcribing svg { color: #fff; stroke: #fff; }

@keyframes voice-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ══════════════════════════════════════════════════════
   VOICE OVERLAY
   ══════════════════════════════════════════════════════ */
.voice-overlay {
    position: fixed;
    inset: 0;
    z-index: 8000;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
.voice-overlay.active { display: flex; }

.vo-close {
    position: absolute;
    top: 20px;
    right: 24px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    padding: 8px;
    transition: color 0.15s;
}
.vo-close:hover { color: #fff; }
.vo-close svg { width: 24px; height: 24px; }

.vo-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    max-width: 500px;
    width: 90%;
}

.vo-status {
    font-family: 'Sora', sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: rgba(255,255,255,0.7);
    letter-spacing: 0.02em;
}

/* Mic button */
.vo-mic-ring {
    position: relative;
    width: 96px;
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vo-mic-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    background: var(--s-accent, #6d5eac);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, background 0.2s;
    z-index: 2;
    position: relative;
}
.vo-mic-btn:hover { transform: scale(1.05); }
.vo-mic-btn svg { width: 32px; height: 32px; }

.vo-mic-btn.recording {
    background: #eb4a4a;
}
.vo-mic-btn.speaking {
    background: #4caf50;
}

/* Pulse ring animation */
.vo-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--s-accent, #6d5eac);
    opacity: 0;
    z-index: 1;
}
.vo-mic-btn.recording ~ .vo-pulse {
    animation: vo-ring-pulse 1.5s ease-out infinite;
    border-color: #eb4a4a;
}
.vo-mic-btn.speaking ~ .vo-pulse {
    animation: vo-ring-pulse 2s ease-out infinite;
    border-color: #4caf50;
}

@keyframes vo-ring-pulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.8); opacity: 0; }
}

/* Transcript */
.vo-transcript {
    min-height: 60px;
    max-height: 180px;
    overflow-y: auto;
    width: 100%;
    text-align: center;
    font-family: 'DM Sans', sans-serif;
    font-size: 18px;
    line-height: 1.6;
    color: #fff;
    padding: 12px 20px;
    border-radius: 14px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    word-break: break-word;
}
.vo-transcript:empty { display: none; }
.vo-transcript .vo-partial {
    color: rgba(255,255,255,0.4);
    font-style: italic;
}

/* Speaking wave animation */
.vo-speaking-wave {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    height: 40px;
}
.vo-speaking-wave span {
    display: block;
    width: 4px;
    border-radius: 2px;
    background: var(--s-accent, #6d5eac);
    animation: vo-wave 1s ease-in-out infinite;
}
.vo-speaking-wave span:nth-child(1) { height: 12px; animation-delay: 0s; }
.vo-speaking-wave span:nth-child(2) { height: 20px; animation-delay: 0.15s; }
.vo-speaking-wave span:nth-child(3) { height: 28px; animation-delay: 0.3s; }
.vo-speaking-wave span:nth-child(4) { height: 20px; animation-delay: 0.45s; }
.vo-speaking-wave span:nth-child(5) { height: 12px; animation-delay: 0.6s; }

@keyframes vo-wave {
    0%, 100% { transform: scaleY(0.4); }
    50% { transform: scaleY(1); }
}

.vo-hint {
    font-size: 13px;
    color: rgba(255,255,255,0.35);
}

/* ── File attachment preview ──────────── */
.chat-attach-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px 4px;
}
.attach-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: var(--s-surface-2, #f0eff4);
    border-radius: 10px;
    font-size: 11px;
    color: var(--s-text-mid);
    position: relative;
}
.attach-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
}
.attach-file { display: flex; align-items: center; }
.attach-file svg { width: 16px; height: 16px; }
.attach-name { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-remove {
    border: none;
    background: none;
    cursor: pointer;
    color: var(--s-text-muted);
    padding: 0 2px;
    display: flex;
}
.attach-remove svg { width: 14px; height: 14px; }
.attach-remove:hover { color: #e44; }

/* Message attachment thumbnails */
.msg-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}
.msg-attach-thumb {
    max-width: 200px;
    max-height: 150px;
    border-radius: 8px;
    object-fit: cover;
}
.msg-attach-file {
    display: inline-block;
    padding: 3px 8px;
    background: rgba(255,255,255,.15);
    border-radius: 6px;
    font-size: 11px;
}

/* Voice feedback toast */
.voice-feedback {
    position: absolute;
    bottom: 42px;
    right: 0;
    background: rgba(30, 28, 45, 0.92);
    color: #e8e6ef;
    font-size: 11px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 8px;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.voice-feedback.error { background: rgba(200, 50, 50, 0.9); }

/* Live partial transcription text */
.voice-partial {
    position: absolute;
    bottom: 60px;
    left: 12px;
    right: 12px;
    background: rgba(30, 28, 45, 0.95);
    color: #e8e6ef;
    font-size: 14px;
    font-weight: 500;
    padding: 10px 16px;
    border-radius: 12px;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
    animation: voice-partial-in 0.2s ease;
}
@keyframes voice-partial-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Waveform button speaking state */
.chat-waveform-btn.speaking {
    background: var(--s-accent, #6d5eac) !important;
    color: #fff !important;
    animation: voice-pulse 1.2s ease-in-out infinite;
}
.chat-waveform-btn.speaking svg { color: #fff; stroke: #fff; }

/* TTS muted state */
.chat-waveform-btn.tts-off {
    opacity: 0.35;
}

/* Workspace voice states (same) */
#wsVoiceBtn.recording {
    background: #eb4a4a !important;
    color: #fff !important;
    animation: voice-pulse 1s ease-in-out infinite;
}
#wsVoiceBtn.transcribing {
    background: var(--s-accent, #6d5eac) !important;
    color: #fff !important;
    animation: voice-pulse 0.6s ease-in-out infinite;
}

.chat-tools-btn {
    display: inline-block;
    padding: 6px 12px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: #5a5a5a;
    font-size: 13px;
    transition: all 0.2s;
    vertical-align: middle;
    line-height: 20px;
    margin-left: 4px;
}

    .chat-tools-btn:hover {
        background: #f0f0f0;
    }

    .chat-tools-btn .material-icons {
        font-size: 18px;
        vertical-align: middle;
        margin-right: 4px;
    }

    .chat-tools-btn svg {
        width: 16px;
        height: 16px;
        vertical-align: middle;
        margin-right: 6px;
    }

/* =================================================================
   FOOTER
   ================================================================= */
.footer {
    padding: 20px;
    border-top: 1px solid #e6e6e6;
    background: #fff;
}

    .footer .copyright {
        margin: 0;
    }

    .footer .small {
        font-size: 12px;
        color: #929aac;
    }

.no-margin {
    margin: 0;
}

/* =================================================================
   SECONDARY SIDEBAR (Chat History)
   ================================================================= */
.secondary-sidebar {
    background: #fff;
    width: 295px;
    height: 100%;
    position: fixed;
    top: 45px;
    left: 70px;
    bottom: 0;
    padding: 0;
    border-right: 1px solid #e6e6e6;
    transition: left 0.4s cubic-bezier(0.05, 0.74, 0.27, 0.99);
    z-index: 998;
}

body.menu-pin .secondary-sidebar {
    left: 250px;
}

/* Sidebar Views */
.secondary-sidebar-content {
    padding: 0;
    overflow-y: auto;
    height: calc(100vh - 45px);
}

.sidebar-view {
    display: none;
    padding: 20px;
}

    .sidebar-view.active {
        display: block;
    }

.sidebar-view-header {
    padding-bottom: 15px;
    border-bottom: 1px solid #e6e6e6;
    margin-bottom: 15px;
}

.sidebar-view-title {
    font-size: 13px;
    font-weight: 600;
    color: #212121;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

/* Secondary Sidebar Overlay (Mobile) */
.secondary-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 997;
    opacity: 0;
    transition: opacity 0.3s ease;
}

@media (max-width: 991px) {
    body.secondary-sidebar-visible .secondary-sidebar-overlay {
        display: block;
        opacity: 1;
    }
}

.chat-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chat-list-empty {
    padding: 40px 20px;
    text-align: center;
    color: #929aac;
}

    .chat-list-empty i {
        width: 48px;
        height: 48px;
        color: #d0d0d0;
        margin-bottom: 12px;
    }

    .chat-list-empty p {
        font-size: 14px;
        margin: 0;
    }

.chat-item {
    padding: 12px 15px;
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

    .chat-item:hover {
        background: #f5f7fa;
    }

    .chat-item.active {
        background: #e8ecf1;
    }

.chat-item-title {
    font-size: 14px;
    font-weight: 500;
    color: #212121;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 60px;
}

.chat-item-preview {
    font-size: 12px;
    color: #929aac;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-time {
    font-size: 11px;
    color: #929aac;
    margin-top: 4px;
}

.chat-item-actions {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: none;
    gap: 4px;
}

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

.chat-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    color: #5a5a5a;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

    .chat-action-btn:hover {
        background: #f0f0f0;
        color: #212121;
    }

    .chat-action-btn .material-icons {
        font-size: 14px;
    }

/* Update page container for secondary sidebar — CHAT PAGE ONLY */
.home-body .page-container {
    margin-left: 365px;
    transition: margin-left 0.4s cubic-bezier(0.05, 0.74, 0.27, 0.99);
}

.home-body.menu-pin .page-container {
    margin-left: 545px;
}

/* Update header for secondary sidebar — CHAT PAGE ONLY */
.home-body .header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 45px;
    background: #fff;
    border-bottom: 1px solid #e6e6e6;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    transition: left 0.4s cubic-bezier(0.05, 0.74, 0.27, 0.99);
}

.home-body.menu-pin .header {
    left: 233px;
}

/* Secondary Toolbar in Header */
.header .secondary-toolbar {
    display: flex;
    align-items: center;
    background: transparent;
    border: none;
    padding: 0;
    gap: 4px;
    margin-left: 70px;
    transition: margin-left 0.4s cubic-bezier(0.05, 0.74, 0.27, 0.99);
}

/* When main sidebar is expanded on hover */
body.sidebar-visible .header .secondary-toolbar {
    margin-left: 280px;
}

/* When main sidebar is pinned */
body.menu-pin .header .secondary-toolbar {
    margin-left: 0px;
}

.secondary-toolbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #5a5a5a;
    transition: all 0.2s;
    white-space: nowrap;
}

    .secondary-toolbar-btn svg {
        width: 18px;
        height: 18px;
        stroke: currentColor;
    }

    .secondary-toolbar-btn .material-icons {
        font-size: 18px;
    }

    .secondary-toolbar-btn:hover {
        background: #f0f0f0;
        color: #212121;
    }

    .secondary-toolbar-btn.active {
        background: #e8ecf1;
        color: #212121;
        font-weight: 600;
    }

/* New Chat Button */
.new-chat-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: #212121;
    transition: all 0.2s;
}

    .new-chat-btn svg {
        width: 16px;
        height: 16px;
        stroke: currentColor;
    }

    .new-chat-btn:hover {
        background: #f5f7fa;
    }

/* Dropdown Menu */
.dropdown {
    position: relative;
}

.menu-dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: #5a5a5a;
    transition: all 0.2s;
}

    .menu-dropdown-toggle:hover {
        background: #f0f0f0;
        color: #212121;
    }

    .menu-dropdown-toggle .material-icons {
        font-size: 20px;
    }

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    min-width: 180px;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    padding: 8px 0;
}

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: #212121;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
}

    .dropdown-item:hover {
        background: #f5f7fa;
    }

    .dropdown-item .material-icons {
        font-size: 18px;
        color: #5a5a5a;
    }

.dropdown-divider {
    height: 1px;
    background: #e6e6e6;
    margin: 8px 0;
}

.gap-3 {
    gap: 12px;
}

/* =================================================================
   RESPONSIVE
   ================================================================= */
@media (max-width: 991px) {
    body.fixed-header {
        padding-top: 45px;
    }

    .page-sidebar {
        left: -280px;
    }

    body.sidebar-visible .page-sidebar {
        left: 0;
    }

    .secondary-sidebar {
        left: -295px;
        transition: left 0.3s ease;
    }

    body.secondary-sidebar-visible .secondary-sidebar {
        left: 0;
    }

    .page-container {
        margin-left: 0;
    }

    .content {
        padding-bottom: 120px;
    }

    .header {
        left: 0 !important;
    }

    body.menu-pin .header {
        left: 0 !important;
    }

    .header .secondary-toolbar {
        margin-left: 70px;
    }

    body.sidebar-visible .header .secondary-toolbar {
        margin-left: 280px;
    }

    body.menu-pin .header .secondary-toolbar {
        margin-left: 0;
    }

    .chat-container.bottom-mode {
        left: 20px;
        right: 20px;
    }

    .chat-messages-area {
        left: 20px;
        right: 20px;
    }

    .toggle-sidebar {
        display: block !important;
    }
}

@media (min-width: 992px) {
    .toggle-sidebar {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .chat-container.bottom-mode {
        left: 10px;
        right: 10px;
        bottom: calc(10px + 56px); /* clear mobile-bottom-bar (56px high) */
    }

    .chat-messages-area {
        left: 10px;
        right: 10px;
        bottom: calc(130px + 56px); /* matches chat input lift so message area still clears it */
    }

    .chat-messages-wrapper {
        padding: 10px;
    }

    .message-item.user-message {
        max-width: 85%;
    }

    .message-item.assistant-message {
        max-width: 100%;
    }

    .chat-box {
        padding: 16px;
        gap: 12px;
    }

    .chat-tools-btn span:last-child {
        display: none;
    }

    .chat-actions {
        gap: 6px;
    }

    .chat-actions-left,
    .chat-actions-right {
        gap: 4px;
    }

    .chat-add-btn,
    .chat-voice-btn,
    .chat-waveform-btn,
    .chat-send-btn {
        width: 28px;
        height: 28px;
    }

        .chat-add-btn svg,
        .chat-voice-btn svg,
        .chat-waveform-btn svg,
        .chat-send-btn svg {
            width: 16px;
            height: 16px;
        }

    .header .secondary-toolbar {
        margin-left: 10px;
    }

    .new-chat-btn {
        padding: 6px 12px;
        font-size: 11px;
    }

        .new-chat-btn svg {
            width: 14px;
            height: 14px;
        }

    .menu-dropdown-toggle {
        width: 32px;
        height: 32px;
    }
}

/* Mobile Sidebar Toggle */
.toggle-sidebar {
    background: none;
    border: none;
    font-size: 24px;
    color: #212121;
    cursor: pointer;
    padding: 8px;
}

/* Hide on desktop, show on mobile */
.d-lg-none {
    display: none;
}

@media (max-width: 991px) {
    .d-lg-none {
        display: block;
    }

    .d-lg-inline-block {
        display: none !important;
    }
}

@media (min-width: 992px) {
    .d-lg-inline-block {
        display: inline-block;
    }
}

/* Desktop - Icon transform when pinned */
@media only screen and (min-width: 980px) {
    body.menu-pin .page-sidebar {
        width: 250px;
        transform: translate3d(0, 0, 0);
    }

        body.menu-pin .page-sidebar .menu-items .icon-thumbnail {
            transform: translate3d(-14px, 0, 0);
        }

        body.menu-pin .page-sidebar .sidebar-header-controls {
            transform: translate3d(10px, 0, 0);
        }
}

/* =================================================================
   DELETE CONFIRMATION MODAL
   ================================================================= */
.delete-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    align-items: center;
    justify-content: center;
}

/* =================================================================
   SETTINGS PANEL - Beautiful Card Design (RESTORED!)
   ================================================================= */

/* Settings Panel Body Override */
.settings-panel-body {
    padding: 0;
    background: #f8f9fa; /* Use existing background color */
    min-height: 100%;
}

/* Settings Navigation - Clean Tab Design */
.settings-nav {
    display: flex;
    background: #fff;
    border-bottom: 1px solid #e6e6e6; /* Use existing border color */
    margin: 0;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.settings-nav-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px; /* Use existing gap size */
    padding: 16px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 13px; /* Use existing font size */
    font-weight: 500;
    color: #5a5a5a; /* Use existing color */
    transition: all 0.2s ease;
    position: relative;
    border-bottom: 3px solid transparent;
    height: 20px; /* As requested */
}

    .settings-nav-btn:hover {
        color: #212121; /* Use existing color */
        background: rgba(114, 82, 211, 0.05);
    }

    .settings-nav-btn.active {
        color: #7252D3; /* Use existing purple */
        background: rgba(114, 82, 211, 0.08);
        border-bottom-color: #7252D3;
    }

    .settings-nav-btn i {
        width: 18px; /* Use existing icon size */
        height: 18px;
        stroke-width: 1.3; /* Use existing stroke width */
    }

/* Settings Content */
.settings-content {
    display: none;
    padding: 24px; /* Use existing padding */
}

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

/* Settings Cards - Beautiful Design */
.settings-card {
    background: #fff;
    border: 1px solid #e6e6e6; /* Use existing border color */
    border-radius: 6px; /* Use existing border radius */
    margin-bottom: 20px; /* Use existing margin */
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

    .settings-card:hover {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        border-color: #d0d0d0; /* Use existing hover color */
    }

/* Settings Card Header */
.settings-card-header {
    padding: 20px 20px 16px 20px; /* Use existing padding */
    display: flex;
    align-items: flex-start;
    gap: 16px;
    border-bottom: 1px solid #f0f0f0; /* Use existing border color */
}

.settings-card-icon {
    width: 35px; /* As requested */
    height: 35px; /* As requested */
    background: #E7DFF3; /* Use existing purple background */
    border-radius: 6px; /* Use existing border radius */
    display: flex;
    align-items: center;
    justify-content: center;
    color: #7252D3; /* Use existing purple */
    flex-shrink: 0;
}

.settings-card-title {
    flex: 1;
}

    .settings-card-title h4 {
        font-size: 16px; /* Use existing font size */
        font-weight: 600;
        color: #212121; /* Use existing color */
        margin: 0 0 4px 0;
    }

    .settings-card-title p {
        font-size: 13px; /* Use existing font size */
        color: #666; /* Use existing color */
        margin: 0;
        line-height: 1.4;
    }

.settings-card-actions {
    display: flex;
    gap: 8px;
}

/* Settings Card Body */
.settings-card-body {
    padding: 20px; /* Use existing padding */
}

    .settings-card-body.no-padding {
        padding: 0;
    }

/* Settings Card Footer */
.settings-card-footer {
    padding: 16px 20px 20px 20px; /* Use existing padding */
    border-top: 1px solid #f0f0f0; /* Use existing border color */
    background: #f8f9fa; /* Use existing background color */
}

/* Terminology Grid - Beautiful Card Selection */
.terminology-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px; /* Use existing gap */
}

.terminology-card {
    position: relative;
}

    .terminology-card input[type="radio"] {
        position: absolute;
        opacity: 0;
        pointer-events: none;
    }

    .terminology-card label {
        display: block;
        background: #fff;
        border: 1px solid #e6e6e6; /* Use existing border */
        border-radius: 6px; /* Use existing border radius */
        padding: 16px; /* Use existing padding */
        cursor: pointer;
        transition: all 0.2s ease;
        height: 100%;
        position: relative;
        overflow: hidden;
    }

    .terminology-card:hover label {
        border-color: #d0d0d0; /* Use existing hover color */
        background: #f5f7fa; /* Use existing hover background */
    }

    .terminology-card input:checked + label {
        border-color: #E7DFF3; /* Use existing selected border */
        background: #e8ecf1; /* Use existing selected background */
    }

.terminology-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px; /* Use existing margin */
}

.terminology-card-icon {
    font-size: 18px; /* Use existing font size */
    margin-right: 8px; /* Use existing margin */
}

.terminology-card-title {
    font-size: 14px; /* Use existing font size */
    font-weight: 500;
    color: #212121; /* Use existing color */
    flex: 1;
}

.terminology-card-check {
    width: 18px; /* Use existing size */
    height: 18px;
    border: 1px solid #e6e6e6; /* Use existing border */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    transition: all 0.2s ease;
    opacity: 0;
}

.terminology-card input:checked + label .terminology-card-check {
    border-color: #7252D3; /* Use existing purple */
    background: #7252D3;
    opacity: 1;
}

.terminology-card-check i {
    width: 10px; /* Use existing icon size */
    height: 10px;
    color: white;
    stroke-width: 2; /* Use existing stroke width */
}

.terminology-card-desc {
    font-size: 12px; /* Use existing font size */
    color: #666; /* Use existing color */
    line-height: 1.4;
    margin-bottom: 12px; /* Use existing margin */
}

.terminology-card-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

    .terminology-card-examples span {
        padding: 2px 6px; /* Use existing padding */
        background: rgba(231, 223, 243, 0.2); /* Use existing background */
        color: #7252D3; /* Use existing color */
        border: 1px solid rgba(231, 223, 243, 0.4);
        border-radius: 3px; /* Use existing border radius */
        font-size: 10px; /* Use existing font size */
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 0.3px;
    }

/* Archive Stats Grid */
.archive-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px; /* Use existing gap */
}

.archive-stat-item {
    background: #fff;
    border: 1px solid #e6e6e6; /* Use existing border */
    border-radius: 6px; /* Use existing border radius */
    padding: 16px; /* Use existing padding */
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}

    .archive-stat-item:hover {
        border-color: #d0d0d0; /* Use existing hover color */
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }

.archive-stat-value {
    font-size: 20px; /* Use existing large font size */
    font-weight: 600;
    color: #7252D3; /* Use existing purple color */
    margin-bottom: 4px; /* Use existing margin */
    line-height: 1;
}

.archive-stat-label {
    font-size: 11px; /* Use existing small font size */
    color: #666; /* Use existing color */
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px; /* Use existing margin */
}

.archive-stat-icon {
    position: absolute;
    top: 12px; /* Use existing positioning */
    right: 12px;
    width: 24px; /* Use existing icon size */
    height: 24px;
    color: rgba(231, 223, 243, 0.4); /* Use existing faded purple */
}

    .archive-stat-icon i {
        width: 24px; /* Use existing icon size */
        height: 24px;
        stroke-width: 1.3; /* Use existing stroke width */
    }

/* Archived Conversations List */
.archived-conversations-list {
    max-height: 300px; /* Use existing max height */
    overflow-y: auto;
}

/* Archive Empty State */
.archive-empty-state {
    padding: 40px 20px; /* Use existing padding */
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.archive-empty-icon {
    width: 48px; /* Use existing icon container size */
    height: 48px;
    background: #f8f9fa; /* Use existing background */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px; /* Use existing margin */
}

    .archive-empty-icon i {
        width: 24px; /* Use existing icon size */
        height: 24px;
        color: #929aac; /* Use existing muted color */
        stroke-width: 1.3; /* Use existing stroke width */
    }

.archive-empty-content h5 {
    font-size: 14px; /* Use existing font size */
    font-weight: 500;
    color: #212121; /* Use existing color */
    margin: 0 0 4px 0;
}

.archive-empty-content p {
    font-size: 12px; /* Use existing font size */
    color: #666; /* Use existing color */
    line-height: 1.4;
    margin: 0;
    max-width: 280px; /* Use existing max width */
}

/* Settings Buttons - Clean Design */
.settings-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px; /* Use existing gap */
    padding: 8px 12px; /* Use existing padding */
    border: 1px solid transparent;
    border-radius: 4px; /* Use existing border radius */
    font-size: 12px; /* Use existing font size */
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    height: 20px; /* As requested */
}

    .settings-btn i {
        width: 14px; /* Use existing icon size */
        height: 14px;
        stroke-width: 1.3; /* Use existing stroke width */
    }

.settings-btn-primary {
    background: #7252D3; /* Use existing purple */
    color: white;
    border-color: #7252D3;
}

    .settings-btn-primary:hover {
        background: #6345c4; /* Use existing darker purple */
        border-color: #6345c4;
    }

.settings-btn-secondary {
    background: #f8f9fa; /* Use existing background */
    color: #5a5a5a; /* Use existing color */
    border-color: #e6e6e6; /* Use existing border */
}

    .settings-btn-secondary:hover {
        background: #f0f0f0; /* Use existing hover background */
        border-color: #d0d0d0; /* Use existing hover border */
    }

.settings-btn-danger {
    background: #dc3545; /* Use Bootstrap danger color */
    color: white;
    border-color: #dc3545;
}

    .settings-btn-danger:hover {
        background: #c82333; /* Use Bootstrap danger hover */
        border-color: #c82333;
    }

/* =================================================================
   ARCHIVED CHAT ITEMS - Chat History Style (Good!)
   ================================================================= */

.archived-chat-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 16px; /* Use existing chat-item padding */
    border-bottom: 1px solid #f0f0f0; /* Use existing border */
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    background: #fff;
}

    .archived-chat-item:hover {
        background: #f5f7fa; /* Use existing hover background */
    }

    .archived-chat-item:last-child {
        border-bottom: none;
    }

.archived-chat-info {
    flex: 1;
    min-width: 0;
    padding-right: 12px; /* Use existing padding */
}

.archived-chat-title {
    font-size: 14px; /* Use existing font size */
    font-weight: 500;
    color: #212121; /* Use existing color */
    margin-bottom: 4px; /* Use existing margin */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.archived-chat-preview {
    font-size: 12px; /* Use existing font size */
    color: #929aac; /* Use existing muted color */
    line-height: 1.4;
    margin-bottom: 4px; /* Use existing margin */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.archived-chat-date {
    font-size: 10px; /* Use existing small font size */
    color: #929aac; /* Use existing muted color */
    font-weight: 500;
}

.archived-chat-actions {
    display: flex;
    gap: 4px; /* Use existing gap */
    opacity: 0;
    transition: opacity 0.2s ease;
}

.archived-chat-item:hover .archived-chat-actions {
    opacity: 1;
}

.archived-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px; /* Use existing action button size */
    height: 24px;
    border: none;
    background: #fff;
    border: 1px solid #e6e6e6; /* Use existing border */
    border-radius: 4px; /* Use existing border radius */
    cursor: pointer;
    color: #5a5a5a; /* Use existing color */
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

    .archived-action-btn:hover {
        background: #f0f0f0; /* Use existing hover background */
        border-color: #d0d0d0; /* Use existing hover border */
        color: #212121; /* Use existing hover color */
    }

    .archived-action-btn.delete:hover {
        background: #ffeef0; /* Use existing error background */
        border-color: #ffc1cc;
        color: #d73a49; /* Use existing error color */
    }

/* Responsive Design */
@media (max-width: 768px) {
    .settings-content {
        padding: 16px; /* Use existing mobile padding */
    }

    .settings-nav-btn {
        padding: 12px 16px; /* Use existing mobile padding */
        font-size: 12px; /* Use existing mobile font size */
    }

    .archive-stats-grid {
        grid-template-columns: 1fr;
    }

    .terminology-grid {
        grid-template-columns: 1fr;
    }

    .archived-chat-item {
        padding: 12px;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .archived-chat-actions {
        opacity: 1;
        justify-content: flex-end;
        margin-top: 8px;
    }
}


/* ================================================================
   MODAL OVERLAY SYSTEM (Archive, Clear Archive, etc.)
   ================================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

.modal-content-wrapper {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.2s ease-out;
}

    .modal-content-wrapper.modal-sm {
        width: 100%;
        max-width: 440px;
    }

    .modal-content-wrapper.modal-md {
        width: 100%;
        max-width: 560px;
    }

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-16px) scale(0.97);
    }

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

.modal-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 24px 24px 16px;
}

.modal-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .modal-icon.warning {
        background: rgba(245, 158, 11, 0.12);
        color: #d97706;
    }

    .modal-icon.danger {
        background: rgba(239, 68, 68, 0.12);
        color: #dc2626;
    }

    .modal-icon.info {
        background: rgba(114, 82, 211, 0.12);
        color: #7252D3;
    }

    .modal-icon i {
        width: 20px;
        height: 20px;
    }

.modal-header-content {
    flex: 1;
    min-width: 0;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 4px;
    line-height: 1.3;
}

.modal-subtitle {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

    .modal-close:hover {
        background: #f3f4f6;
        color: #374151;
    }

    .modal-close i {
        width: 16px;
        height: 16px;
    }

.modal-body {
    padding: 0 24px 20px;
}

.modal-text {
    font-size: 14px;
    color: #4b5563;
    line-height: 1.6;
    margin: 0;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px 24px 20px;
    border-top: 1px solid #f0f0f0;
}

.modal-btn {
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    line-height: 1.4;
}

.modal-btn-secondary {
    background: #f9fafb;
    color: #374151;
    border-color: #e5e7eb;
}

    .modal-btn-secondary:hover {
        background: #f3f4f6;
        border-color: #d1d5db;
    }

.modal-btn-primary {
    background: #7252D3;
    color: #fff;
    border-color: #6345c4;
}

    .modal-btn-primary:hover {
        background: #6345c4;
    }

.modal-btn-danger {
    background: #dc2626;
    color: #fff;
    border-color: #b91c1c;
}

    .modal-btn-danger:hover {
        background: #b91c1c;
    }

.delete-modal-overlay.active {
    display: flex;
    opacity: 1;
}

.delete-modal {
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-align: center;
}

.delete-modal-overlay.active .delete-modal {
    transform: scale(1);
}

.delete-modal-icon {
    width: 64px;
    height: 64px;
    background: #fee;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

    .delete-modal-icon i {
        width: 32px;
        height: 32px;
        color: #e74c3c;
    }

.delete-modal-title {
    font-size: 22px;
    font-weight: 600;
    color: #212121;
    margin: 0 0 12px 0;
}

.delete-modal-text {
    font-size: 14px;
    color: #666;
    margin: 0 0 24px 0;
    line-height: 1.5;
}

.delete-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.delete-modal-btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-family: -apple-system, BlinkMacSystemFont, "Inter UI", "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
    font-weight: 500;
    font-size: 14px;
    letter-spacing: -0.006em;
    text-align: center;
    cursor: pointer;
    white-space: nowrap;
    border-radius: 3px;
    line-height: 14px;
    min-height: 28px;
    min-width: 100px;
    position: relative;
    transition: background 120ms ease-in 0s, box-shadow 120ms ease-in 0s;
    padding: 0px 16px;
}

.delete-modal-btn-cancel,
.delete-modal-btn-cancel:focus {
    color: #4b4b4b;
    background-color: #fff;
    border: 1px solid rgba(33, 33, 33, 0.17);
    border-bottom: 1px solid rgba(33, 33, 33, 0.24);
}

    .delete-modal-btn-cancel:hover {
        background-color: #f5f5f5;
        border: 1px solid rgba(33, 33, 33, 0.24);
    }

.delete-modal-btn-confirm,
.delete-modal-btn-confirm:focus {
    color: #fff;
    background-color: #e74c3c;
    border: 1px solid rgba(192, 57, 43, 0.5);
    border-bottom: 1px solid rgba(33, 33, 33, 0.22);
}

    .delete-modal-btn-confirm:hover {
        background-color: #c0392b;
        border: 1px solid rgba(192, 57, 43, 0.6);
    }

/* =================================================================
   AGENTS SYSTEM
   ================================================================= */

/* Create Agent Button in Header */
.sidebar-view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 1px solid #e6e6e6;
    margin-bottom: 15px;
}

.create-agent-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: #5a5a5a;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .create-agent-btn:hover {
        background: #f0f0f0;
    }

    .create-agent-btn i {
        width: 18px;
        height: 18px;
    }

/* Agent Mode Selector */
.agent-mode-selector {
    padding: 5px;
    background: transparent;
    border-radius: 8px;
    margin: 0px 0px 0px 0px;
}

.mode-label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 10px;
}

.mode-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mode-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid transparent;
}

    .mode-option:hover {
        background: #fff;
    }

    .mode-option input[type="radio"] {
        margin-top: 2px;
        cursor: pointer;
    }

        .mode-option input[type="radio"]:checked + .mode-option-text {
            color: #7252D3;
        }

        .mode-option input[type="radio"]:checked ~ .mode-option-text strong {
            color: #7252D3;
        }

.mode-option-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

    .mode-option-text strong {
        font-size: 13px;
        font-weight: 600;
        color: #333;
    }

    .mode-option-text small {
        font-size: 11px;
        color: #666;
        line-height: 1.3;
    }

/* Agent Groups */
.agent-group {
    margin-bottom: 20px;
}

.agent-group-header {
    font-size: 11px;
    font-weight: 600;
    color: #929aac;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 15px;
    margin-bottom: 8px;
}

.agent-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.agent-list-empty {
    padding: 30px 20px;
    text-align: center;
    color: #929aac;
}

    .agent-list-empty i {
        width: 40px;
        height: 40px;
        color: #d0d0d0;
        margin-bottom: 10px;
    }

    .agent-list-empty p {
        font-size: 13px;
        margin: 0;
    }

/* Agent Item */
.agent-item {
    padding: 12px 15px;
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

    .agent-item:hover {
        background: #f5f7fa;
    }

    .agent-item.active-agent {
        background: #e8ecf1;
    }

/* Agent Checkbox */
.agent-checkbox {
    width: 13px;
    height: 13px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Agent Info */
.agent-info {
    flex: 1;
    min-width: 0;
}

.agent-name {
    font-size: 14px;
    font-weight: 500;
    color: #212121;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-type-badge {
    font-size: 10px;
    color: #929aac;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Agent Status Badge */
.agent-status {
    flex-shrink: 0;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 4px;
}

    .agent-status.status-active {
        background: #d4f4dd;
        color: #22863a;
        border: 1px solid #a2d9b1;
    }

    .agent-status.status-inactive {
        background: #ffeef0;
        color: #d73a49;
        border: 1px solid #ffc1cc;
    }

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* Agent Actions */
.agent-actions {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: none;
    gap: 4px;
}

.agent-item:hover .agent-actions {
    display: flex;
}

.agent-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    color: #5a5a5a;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

    .agent-action-btn:hover {
        background: #f0f0f0;
        color: #212121;
    }

    .agent-action-btn i {
        width: 14px;
        height: 14px;
    }

/* =================================================================
   SLIDE-OUT PANEL
   ================================================================= */
.slide-out-panel {
    position: fixed;
    top: 0;
    right: -600px;
    width: 600px;
    height: 100vh;
    background: #fff;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

    .slide-out-panel.active {
        right: 0;
    }

.slide-out-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

    .slide-out-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

.slide-out-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.slide-out-header {
    padding: 24px;
    border-bottom: 1px solid #e6e6e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.slide-out-title {
    font-size: 20px;
    font-weight: 600;
    color: #212121;
    margin: 0;
}

.slide-out-close {
    width: 36px;
    height: 36px;
    border: none;
    background: #f5f7fa;
    border-radius: 8px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .slide-out-close:hover {
        background: #e8ecf1;
        color: #212121;
    }

    .slide-out-close i {
        width: 20px;
        height: 20px;
    }

.slide-out-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.slide-out-footer {
    padding: 20px 24px;
    border-top: 1px solid #e6e6e6;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-shrink: 0;
}

/* Agent Detail Panel */
.agent-detail-section {
    margin-bottom: 24px;
}

.agent-detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.agent-detail-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(114, 82, 211, 0.1) 0%, rgba(114, 82, 211, 0.05) 100%);
    border: 2px solid rgba(114, 82, 211, 0.2);
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(114, 82, 211, 0.15);
}

    .agent-detail-icon i {
        width: 28px;
        height: 28px;
        color: #7252D3;
    }

.agent-detail-title h4 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #212121;
}

.agent-detail-badge {
    display: inline-block;
    padding: 4px 8px;
    background: #f0f0f0;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.detail-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.agent-detail-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    width: fit-content;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

    .agent-detail-status .status-dot {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background: #4caf50;
        box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
    }

    .agent-detail-status.inactive .status-dot {
        background: #999;
        box-shadow: 0 0 0 3px rgba(153, 153, 153, 0.2);
    }

    .agent-detail-status .status-text {
        font-size: 14px;
        font-weight: 600;
        color: #212121;
    }

.agent-detail-text {
    padding: 16px;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
    color: #212121;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.agent-detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.agent-detail-tag {
    padding: 8px 14px;
    background: rgba(114, 82, 211, 0.08);
    border: 1px solid rgba(114, 82, 211, 0.25);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: #7252D3;
    box-shadow: 0 1px 2px rgba(114, 82, 211, 0.1);
}

.agent-detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.agent-detail-item {
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.detail-item-label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-item-value {
    font-size: 15px;
    font-weight: 600;
    color: #212121;
}

.detail-item-code {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #7252D3;
    background: rgba(114, 82, 211, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
}

.detail-action-buttons {
    display: flex;
    gap: 8px;
}

    .detail-action-buttons .btn {
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

        .detail-action-buttons .btn i {
            width: 16px;
            height: 16px;
        }

/* Form Elements */
.form-group {
    margin-bottom: 24px;
}

    .form-group label {
        display: block;
        font-size: 14px;
        font-weight: 500;
        color: #212121;
        margin-bottom: 8px;
    }

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    font-size: 14px;
    color: #212121;
    transition: all 0.2s;
    font-family: inherit;
}

    .form-control:focus {
        outline: none;
        border-color: #E7DFF3;
        box-shadow: 0 0 0 3px rgba(231, 223, 243, 0.2);
    }

    .form-control::placeholder {
        color: #929aac;
    }

textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

.form-text {
    display: block;
    font-size: 12px;
    color: #929aac;
    margin-top: 6px;
}

/* Parameter Value Display */
.param-value {
    float: right;
    font-weight: 600;
    color: #E7DFF3;
}

/* Range Slider */
.form-range {
    width: 100%;
    height: 6px;
    background: #e6e6e6;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

    .form-range::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 18px;
        height: 18px;
        background: #E7DFF3;
        border-radius: 50%;
        cursor: pointer;
        transition: all 0.2s;
    }

        .form-range::-webkit-slider-thumb:hover {
            background: #d4c5e8;
            transform: scale(1.1);
        }

    .form-range::-moz-range-thumb {
        width: 18px;
        height: 18px;
        background: #E7DFF3;
        border-radius: 50%;
        cursor: pointer;
        border: none;
        transition: all 0.2s;
    }

        .form-range::-moz-range-thumb:hover {
            background: #d4c5e8;
            transform: scale(1.1);
        }

/* Agent Type Selector */
.agent-type-selector {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.agent-type-option {
    padding: 16px;
    border: 2px solid #e6e6e6;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

    .agent-type-option:hover:not(.disabled) {
        border-color: #E7DFF3;
        background: #fafbfc;
    }

    .agent-type-option.active {
        border-color: #E7DFF3;
        background: rgba(231, 223, 243, 0.1);
    }

    .agent-type-option.disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .agent-type-option i {
        width: 24px;
        height: 24px;
        color: #E7DFF3;
        flex-shrink: 0;
    }

.agent-type-info {
    flex: 1;
}

.agent-type-name {
    font-size: 14px;
    font-weight: 600;
    color: #212121;
    margin-bottom: 2px;
}

.agent-type-desc {
    font-size: 12px;
    color: #929aac;
}

/* Advanced Settings Toggle */
.advanced-settings {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #e6e6e6;
}

.advanced-toggle {
    width: 100%;
    padding: 12px 0;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    transition: all 0.2s;
}

    .advanced-toggle:hover {
        color: #212121;
    }

    .advanced-toggle i {
        width: 16px;
        height: 16px;
        transition: transform 0.2s;
    }

    .advanced-toggle.expanded i {
        transform: rotate(90deg);
    }

.advanced-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

    .advanced-content.expanded {
        max-height: 1000px;
    }

/* Buttons */
.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-family: -apple-system, BlinkMacSystemFont, "Inter UI", "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
    font-weight: 500;
    font-size: 13px;
    letter-spacing: -0.006em;
    margin-bottom: 0;
    text-align: center;
    cursor: pointer;
    white-space: nowrap;
    border-radius: 3px;
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    background-image: none !important;
    text-shadow: none;
    box-shadow: none;
    line-height: 14px;
    min-height: 28px;
    min-width: 28px;
    position: relative;
    transition: background 120ms ease-in 0s, box-shadow 120ms ease-in 0s, opacity 0.12s cubic-bezier(0.4, 0, 0.6, 1) 0ms, transform 0.12s cubic-bezier(0.4, 0, 0.6, 1) 0ms, -webkit-transform 0.12s cubic-bezier(0.4, 0, 0.6, 1) !important;
    padding: 0px 16px;
}

.btn-primary,
.btn-primary:focus {
    color: #fff;
    background-color: #7252D3;
    border: 1px solid rgba(78, 55, 182, 0.5);
    border-bottom: 1px solid rgba(33, 33, 33, 0.22);
}

    .btn-primary:hover {
        background-color: #6345c4;
        border: 1px solid rgba(78, 55, 182, 0.6);
    }

.btn-secondary,
.btn-secondary:focus {
    color: #4b4b4b;
    background-color: #fff;
    border: 1px solid rgba(33, 33, 33, 0.17);
    border-bottom: 1px solid rgba(33, 33, 33, 0.24);
}

    .btn-secondary:hover {
        background-color: #f5f5f5;
        border: 1px solid rgba(33, 33, 33, 0.24);
    }

/* Responsive */
@media (max-width: 768px) {
    .slide-out-panel {
        width: 100%;
        right: -100%;
    }
}

/* =================================================================
   AGENT SELECTOR DROPDOWN (Tools Menu)
   ================================================================= */
.agent-selector-dropdown {
    display: none;
    position: fixed;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    min-width: 280px;
    max-width: 320px;
    z-index: 1000;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

    .agent-selector-dropdown.active {
        display: block;
        opacity: 1;
        transform: translateY(0);
    }

.agent-selector-header {
    padding: 12px 16px 8px 16px;
    font-size: 12px;
    font-weight: 600;
    color: #666;
}

    .agent-selector-header h4 {
        margin: 0;
        font-size: 14px;
        font-weight: 600;
        color: #212121;
    }

.agent-selector-list {
    padding: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.agent-selector-item {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

    .agent-selector-item:hover {
        background: #f5f7fa;
    }

    .agent-selector-item.selected {
        background: rgba(231, 223, 243, 0.2);
        border: 1px solid #E7DFF3;
    }

.agent-selector-item-info {
    cursor: default !important;
}

    .agent-selector-item-info:hover {
        background: transparent !important;
    }

.agent-selector-radio {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.agent-selector-info {
    flex: 1;
    min-width: 0;
}

.agent-selector-name {
    font-size: 14px;
    font-weight: 500;
    color: #212121;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-selector-type {
    font-size: 11px;
    color: #929aac;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.agent-selector-footer {
    padding: 12px 16px;
    border-top: 1px solid #e6e6e6;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
    font-size: 11px;
    color: #666;
    line-height: 1.4;
}

.agent-selector-empty {
    padding: 24px;
    text-align: center;
    color: #929aac;
}

    .agent-selector-empty i {
        width: 32px;
        height: 32px;
        margin-bottom: 8px;
        color: #d0d0d0;
    }

    .agent-selector-empty p {
        font-size: 13px;
        margin: 0;
    }

/* Material Icons */
.material-icons {
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
}
/* Tools Dropdown */
.tools-dropdown {
    position: absolute;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: 280px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    min-width: 350px;
    max-width: 400px;
}

    .tools-dropdown.active {
        display: block;
    }

.tools-dropdown-header {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

    .tools-dropdown-header h4 {
        margin: 0;
        font-size: 16px;
        color: #333;
    }

.tools-dropdown-close {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    color: #666;
}

.tools-section {
    padding: 15px;
}

.tools-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-weight: 600;
    color: #555;
}

.tools-item {
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 5px;
    background: #f8f9fa;
}

.tools-item-name {
    font-weight: 500;
    margin-bottom: 2px;
}

.tools-item-desc {
    font-size: 12px;
    color: #666;
}

.tools-empty {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 20px;
}


/* Tools dropdown specific agent actions */
#toolsAgentsList .agent-item .agent-actions {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    padding: 4px;
}

    #toolsAgentsList .agent-item .agent-actions i {
        width: 16px;
        height: 16px;
    }


/* Agent Selection Slider */
.agent-selection-slider {
    width: 400px;
}

.slide-out-back {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .slide-out-back:hover {
        background: #f0f0f0;
        color: #333;
    }

    .slide-out-back i {
        width: 18px;
        height: 18px;
    }

.agent-selection-info {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
}

    .agent-selection-info p {
        margin: 0;
        color: #666;
        font-size: 14px;
    }


/* ADD THESE STYLES TO YOUR CSS */

/* Test Results Styling */
.test-result {
    padding: 0.75rem;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    border: 1px solid;
}

    .test-result.testing {
        background: rgba(59, 130, 246, 0.1);
        border-color: rgba(59, 130, 246, 0.3);
        color: #3b82f6;
    }

    .test-result.success {
        background: rgba(34, 197, 94, 0.1);
        border-color: rgba(34, 197, 94, 0.3);
        color: #22c55e;
    }

    .test-result.error {
        background: rgba(239, 68, 68, 0.1);
        border-color: rgba(239, 68, 68, 0.3);
        color: #ef4444;
    }

.tools-list {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 0px;
    padding-left: 3px !important;
}

    .tools-list ul {
        margin: 0.5rem 0 0 0;
        padding-left: 1.5rem;
        list-style: none;
    }

    .tools-list li {
        padding: 0.25rem 0;
        position: relative;
        list-style-type: none;
    }

/* MCP Item Status Colors */
.mcp-item.connected .chat-item-time {
    color: #22c55e;
    font-weight: 600;
}

.mcp-item.error .chat-item-time {
    color: #ef4444;
    font-weight: 600;
}

.mcp-item.untested .chat-item-time {
    color: #f59e0b;
    font-weight: 600;
}

.mcp-item.inactive .chat-item-time {
    color: #9ca3af;
}

/* Detail Tag for Configuration vs Real Tools */
.detail-tag-config {
    opacity: 0.6;
    border-style: dashed !important;
}
/* Make agent-select-item look identical to agent-item */
.agent-select-item {
    /* Copy all styles from .agent-item */
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

    .agent-select-item:hover {
        background-color: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.1);
    }

    .agent-select-item.active-agent {
        background-color: rgba(59, 130, 246, 0.1);
        border-color: rgba(59, 130, 246, 0.3);
        color: #60a5fa;
    }

    .agent-select-item .agent-status {
        margin-right: 0.75rem;
        color: #9ca3af;
    }

    .agent-select-item.active-agent .agent-status {
        color: #60a5fa;
    }

    .agent-select-item .agent-info {
        flex: 1;
    }

    .agent-select-item .agent-name {
        font-weight: 500;
        font-size: 0.875rem;
        margin-bottom: 0.25rem;
    }

    .agent-select-item .agent-type-badge {
        font-size: 0.75rem;
        color: #9ca3af;
    }

    .agent-select-item.available-agent {
        opacity: 0.7;
        cursor: default;
        background: rgba(255, 255, 255, 0.02);
    }

        .agent-select-item.available-agent:hover {
            background: rgba(255, 255, 255, 0.02);
            border-color: transparent;
        }

    .agent-select-item .agent-status.available {
        color: #10b981;
    }

/* MCP Toggle Switch Styling */
.mcp-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.mcp-toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
    margin-left: 0.5rem;
}

    .mcp-toggle-switch input {
        opacity: 0;
        width: 0;
        height: 0;
    }

.mcp-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #374151;
    border: 1px solid #4b5563;
    transition: 0.3s;
    border-radius: 20px;
}

    .mcp-toggle-slider:before {
        position: absolute;
        content: "";
        height: 14px;
        width: 14px;
        left: 2px;
        bottom: 2px;
        background-color: #9ca3af;
        transition: 0.3s;
        border-radius: 50%;
    }

input:checked + .mcp-toggle-slider {
    background-color: #10b981;
    border-color: #059669;
}

    input:checked + .mcp-toggle-slider:before {
        transform: translateX(20px);
        background-color: white;
    }

/* MCP Toggle Switch - Compact Size */
.mcp-toggle-switch {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
    margin-right: 0.5rem;
}

    .mcp-toggle-switch input {
        opacity: 0;
        width: 0;
        height: 0;
    }

.mcp-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #374151;
    border: 1px solid #4b5563;
    transition: 0.3s;
    border-radius: 12px;
}

    .mcp-toggle-slider:before {
        position: absolute;
        content: "";
        height: 12px;
        width: 12px;
        left: 2px;
        bottom: 2px;
        background-color: #9ca3af;
        transition: 0.3s;
        border-radius: 50%;
    }

input:checked + .mcp-toggle-slider {
    background-color: #10b981;
    border-color: #059669;
}

    input:checked + .mcp-toggle-slider:before {
        transform: translateX(14px);
        background-color: white;
    }

/* MCP Selection Items (Tools Dropdown) */
.mcp-select-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

    .mcp-select-item:hover {
        background-color: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.1);
    }

.mcp-checkbox {
    margin-right: 0.75rem;
    width: 16px;
    height: 16px;
}

.mcp-select-item .mcp-info {
    flex: 1;
}

.mcp-select-item .mcp-name {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    color: #6c6c6c;
}

.mcp-select-item .mcp-type-badge {
    font-size: 0.75rem;
    color: #9ca3af;
}


/* Error details styling */
.test-result.error {
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.error-details {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    opacity: 0.8;
    font-style: italic;
}

.chat-item-time.error {
    cursor: help;
}

    .chat-item-time.error:hover {
        background-color: rgba(239, 68, 68, 0.1);
        border-radius: 4px;
        padding: 2px 4px;
    }

/* Testing status styling */
.chat-item-time.testing {
    color: #fbbf24;
    background-color: rgba(251, 191, 36, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(251, 191, 36, 0.3);
    animation: pulse-testing 1.5s ease-in-out infinite;
}

@keyframes pulse-testing {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}


/* ==================================================================================
 * MCP STATUS INTEGRATION CSS - Add to your sparkai.css file
 * ==================================================================================
 * These styles integrate with your existing design system
 */

/* MCP Status Indicators in Sidebar */
.mcp-item.status-connected {
    border-left: 3px solid #28a745;
}

.mcp-item.status-cached {
    border-left: 3px solid #17a2b8;
    background: linear-gradient(90deg, rgba(23, 162, 184, 0.1) 0%, transparent 100%);
}

.mcp-item.status-disconnected {
    border-left: 3px solid #ffc107;
}

.mcp-item.status-error {
    border-left: 3px solid #dc3545;
}

.mcp-item.status-inactive {
    border-left: 3px solid #6c757d;
    opacity: 0.6;
}

/* Pre-warm indicator */
.prewarm-indicator {
    color: #17a2b8;
    font-size: 12px;
    margin-left: 6px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }

    100% {
        opacity: 1;
    }
}

/* Status text colors in sidebar */
.chat-item-time.connected {
    color: #28a745;
    font-weight: 500;
}

.chat-item-time.cached {
    color: #17a2b8;
    font-weight: 500;
}

.chat-item-time.disconnected {
    color: #ffc107;
}

.chat-item-time.error {
    color: #dc3545;
}

.chat-item-time.inactive {
    color: #6c757d;
}

.chat-item-time.testing {
    color: #007bff;
    animation: pulse 1.5s infinite;
}

/* MCP Status Summary in Tools Dropdown */
.mcp-status-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 15px;
    font-size: 12px;
}

    .mcp-status-summary .status-info {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .mcp-status-summary .status-label {
        color: #ccc;
    }

    .mcp-status-summary .status-value {
        color: #17a2b8;
        font-weight: 600;
    }

    .mcp-status-summary .status-actions {
        display: flex;
        gap: 6px;
    }

.status-action-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #fff;
    padding: 6px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

    .status-action-btn:hover {
        background: rgba(255, 255, 255, 0.15);
        border-color: rgba(255, 255, 255, 0.3);
        transform: translateY(-1px);
    }

    .status-action-btn i {
        width: 14px;
        height: 14px;
    }

/* MCP Selection Status in Tools Dropdown */
.mcp-select-item {
    position: relative;
    transition: all 0.2s ease;
}

    .mcp-select-item.mcp-connected {
        border-left: 2px solid #28a745;
        padding: 10px;
    }

    .mcp-select-item.mcp-cached {
        border-left: 2px solid #17a2b8;
        background: linear-gradient(90deg, rgba(23, 162, 184, 0.08) 0%, transparent 100%);
        padding: 10px;
    }

    .mcp-select-item.mcp-disconnected {
        border-left: 2px solid #ffc107;
        padding: 10px;
    }

    .mcp-select-item.mcp-inactive {
        border-left: 2px solid #6c757d;
        opacity: 0.6;
        padding: 10px;
    }

    .mcp-select-item .mcp-status-indicator {
        position: absolute;
        top: 8px;
        right: 8px;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #6c757d;
    }

    .mcp-select-item.mcp-connected .mcp-status-indicator {
        background: #28a745;
    }

    .mcp-select-item.mcp-cached .mcp-status-indicator {
        background: #17a2b8;
        animation: pulse 2s infinite;
    }

    .mcp-select-item.mcp-disconnected .mcp-status-indicator {
        background: #ffc107;
    }

    .mcp-select-item.mcp-inactive .mcp-status-indicator {
        background: #6c757d;
    }

/* Pre-warm Selected Button */
.mcp-control-item {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mcp-control-btn {
    width: 100%;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #fff;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

    .mcp-control-btn:hover {
        background: linear-gradient(135deg, #0056b3 0%, #004494 100%);
        border-color: rgba(255, 255, 255, 0.3);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
    }

    .mcp-control-btn:active {
        transform: translateY(0);
    }

    .mcp-control-btn i {
        width: 16px;
        height: 16px;
    }

/* Enhanced MCP Type Badge with Status */
.mcp-select-item .mcp-type-badge {
    font-size: 11px;
    color: #ccc;
    transition: color 0.2s ease;
}

.mcp-select-item.mcp-connected .mcp-type-badge {
    color: #28a745;
}

.mcp-select-item.mcp-cached .mcp-type-badge {
    color: #17a2b8;
    font-weight: 600;
}

.mcp-select-item.mcp-disconnected .mcp-type-badge {
    color: #ffc107;
}

.mcp-select-item.mcp-inactive .mcp-type-badge {
    color: #6c757d;
}

/* Status Notifications */
.status-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.9);
    border-radius: 8px;
    padding: 12px 16px;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: slideInFromRight 0.3s ease-out;
}

@keyframes slideInFromRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

.status-notification.status-success {
    border-left: 4px solid #28a745;
}

.status-notification.status-error {
    border-left: 4px solid #dc3545;
}

.status-notification.status-warning {
    border-left: 4px solid #ffc107;
}

.status-notification i {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.status-notification.status-success i {
    color: #28a745;
}

.status-notification.status-error i {
    color: #dc3545;
}

.status-notification.status-warning i {
    color: #ffc107;
}

/* Enhanced MCP Count Display */
.tools-section-count {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    color: #17a2b8;
    margin-left: 8px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .mcp-status-summary {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .status-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        font-size: 12px;
    }
}

/* Enhanced hover effects for MCP items */
.mcp-item:hover.status-cached {
    background: linear-gradient(90deg, rgba(23, 162, 184, 0.15) 0%, transparent 100%);
}

.mcp-item:hover.status-connected {
    background: linear-gradient(90deg, rgba(40, 167, 69, 0.1) 0%, transparent 100%);
}

/* Loading states for status updates */
.mcp-item.status-loading {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0.05) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* Tooltips enhancement for better status display */
.mcp-item[title]:hover::after,
.mcp-select-item[title]:hover::after {
    content: attr(title);
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    white-space: pre-line;
    z-index: 1000;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
/* ==================================================================================
 * MCP LOADING STATES & PROGRESS INDICATORS - Add to your sparkai.css
 * ==================================================================================
 * Enhanced animations and loading states for better user feedback
 */

/* Spinning loader animation */
.spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Loading state for server items */
.mcp-item.status-loading {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.03) 100%);
    background-size: 200% 100%;
    animation: shimmer 2s ease-in-out infinite;
    border-left: 3px solid #007bff;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* Loading state for status text */
.chat-item-time.loading {
    color: #007bff;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

    .chat-item-time.loading i {
        width: 12px;
        height: 12px;
    }

/* New server caching animation */
.new-server-caching {
    animation: slideInFromTop 0.5s ease-out, pulse 2s ease-in-out infinite;
    border-left: 3px solid #17a2b8;
    background: linear-gradient(90deg, rgba(23, 162, 184, 0.1) 0%, transparent 100%);
}

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

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

/* Caching progress animation for bulk operations */
.caching-progress {
    position: relative;
    overflow: hidden;
}

    .caching-progress::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent 0%, rgba(23, 162, 184, 0.2) 50%, transparent 100%);
        animation: cachingWave 2s ease-in-out;
    }

@keyframes cachingWave {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

/* Button loading states */
.btn.btn-loading {
    position: relative;
    pointer-events: none;
}

    .btn.btn-loading i {
        margin-right: 6px;
    }

.btn.btn-error {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
}

/* Enhanced pre-warm button states */
.mcp-control-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
}

.mcp-control-btn.success {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
}

.mcp-control-btn.error {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}

/* Status action button loading states */
.status-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.status-action-btn.loading {
    background: rgba(0, 123, 255, 0.2);
    border-color: rgba(0, 123, 255, 0.4);
}

.status-action-btn.success {
    background: rgba(40, 167, 69, 0.2);
    border-color: rgba(40, 167, 69, 0.4);
    color: #28a745;
}

.status-action-btn.error {
    background: rgba(220, 53, 69, 0.2);
    border-color: rgba(220, 53, 69, 0.4);
    color: #dc3545;
}

/* Loading spinner in status areas */
.status-value i.spinning,
.tools-section-count i.spinning {
    width: 12px;
    height: 12px;
    color: #007bff;
}

/* Enhanced status notifications with progress */
.status-notification {
    animation: slideInFromRight 0.4s ease-out;
    transition: all 0.3s ease;
}

    .status-notification.notification-loading {
        background: linear-gradient(90deg, rgba(0, 123, 255, 0.1) 0%, rgba(0, 123, 255, 0.2) 50%, rgba(0, 123, 255, 0.1) 100%);
        background-size: 200% 100%;
        animation: slideInFromRight 0.4s ease-out, shimmer 2s ease-in-out infinite;
        border-left-color: #007bff;
    }

    .status-notification.notification-success {
        border-left-color: #28a745;
        background: rgba(40, 167, 69, 0.1);
    }

    .status-notification.notification-error {
        border-left-color: #dc3545;
        background: rgba(220, 53, 69, 0.1);
    }

/* Progress bar for long operations */
.progress-indicator {
    position: relative;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 1px;
    overflow: hidden;
    margin-top: 8px;
}

    .progress-indicator::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        width: 30%;
        background: linear-gradient(90deg, #007bff, #17a2b8);
        border-radius: 1px;
        animation: progressSlide 2s ease-in-out infinite;
    }

@keyframes progressSlide {
    0% {
        left: -30%;
    }

    100% {
        left: 100%;
    }
}

/* Enhanced hover states during loading */
.mcp-item.status-loading:hover {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.12) 50%, rgba(255, 255, 255, 0.05) 100%);
}

/* Staggered loading animation for multiple items */
.mcp-item:nth-child(1).caching-progress {
    animation-delay: 0s;
}

.mcp-item:nth-child(2).caching-progress {
    animation-delay: 0.2s;
}

.mcp-item:nth-child(3).caching-progress {
    animation-delay: 0.4s;
}

.mcp-item:nth-child(4).caching-progress {
    animation-delay: 0.6s;
}

.mcp-item:nth-child(5).caching-progress {
    animation-delay: 0.8s;
}

/* Loading overlay for form submissions */
.form-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 12px;
    backdrop-filter: blur(2px);
}

.form-loading-content {
    color: white;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
}

    .form-loading-content i {
        width: 20px;
        height: 20px;
        margin-bottom: 8px;
    }

/* Success pulse animation */
@keyframes successPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }

    70% {
        transform: scale(1.02);
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

.success-pulse {
    animation: successPulse 0.6s ease-out;
}

/* Error shake animation */
@keyframes errorShake {
    0%, 100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.error-shake {
    animation: errorShake 0.5s ease-in-out;
}

/* Loading dots for text */
.loading-dots::after {
    content: '';
    animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {
    0%, 20% {
        content: '.';
    }

    40% {
        content: '..';
    }

    60%, 100% {
        content: '...';
    }
}

/* Micro-interactions for better feedback */
.status-action-btn,
.mcp-control-btn {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

    .status-action-btn:active:not(:disabled),
    .mcp-control-btn:active:not(:disabled) {
        transform: scale(0.95);
    }

/* Responsive loading states */
@media (max-width: 768px) {
    .status-notification {
        font-size: 12px;
        padding: 10px 14px;
    }

    .mcp-item.status-loading {
        background-size: 150% 100%;
        animation-duration: 1.5s;
    }

    .chat-item-time.loading {
        font-size: 11px;
    }

    .spinning {
        animation-duration: 0.8s;
    }
}

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
    .mcp-item.status-loading {
        background: linear-gradient(90deg, rgba(255, 255, 255, 0.02) 0%, rgba(255, 255, 255, 0.06) 50%, rgba(255, 255, 255, 0.02) 100%);
    }

    .progress-indicator {
        background: rgba(255, 255, 255, 0.05);
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .spinning,
    .shimmer,
    .caching-progress::before,
    .progress-indicator::after {
        animation: none;
    }

    .mcp-item.status-loading {
        background: rgba(0, 123, 255, 0.1);
    }

    .status-notification {
        animation: none;
        transition: opacity 0.3s ease;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .chat-item-time.loading {
        color: #ffffff;
        background: #007bff;
        padding: 2px 6px;
        border-radius: 3px;
    }

    .mcp-item.status-loading {
        border-left-width: 4px;
        border-left-color: #007bff;
    }
}

/* ==================================================================================
 * MCP PRE-WARMING PROGRESS INDICATORS - Add to your sparkai.css
 * ==================================================================================
 * Subtle progress indicators that show pre-warming status
 */

/* Pre-warm trigger button in MCP sidebar header */
.mcp-prewarm-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid #e6e6e6;
    border-radius: 6px;
    background: transparent;
    color: #5a5a5a;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}
.mcp-prewarm-btn svg { width: 12px; height: 12px; }
.mcp-prewarm-btn:hover { background: #f0f0f0; color: #e0874a; border-color: rgba(224,135,74,.3); }
.mcp-prewarm-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Pre-warming progress indicator in MCP section header */
.mcp-prewarming-progress {
    background: linear-gradient(135deg, rgba(23, 162, 184, 0.1) 0%, rgba(0, 123, 255, 0.1) 100%);
    border: 1px solid rgba(23, 162, 184, 0.2);
    border-radius: 8px;
    margin: 0px 0px 10px 0px;
    padding: 10px 12px;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    animation: slideInFromTop 0.3s ease-out;
    width: 100%;
}

    .mcp-prewarming-progress::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent 0%, rgba(23, 162, 184, 0.15) 50%, transparent 100%);
        animation: progressSweep 3s ease-in-out infinite;
    }

@keyframes progressSweep {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

.prewarming-status {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 1;
}

    .prewarming-status i {
        width: 14px;
        height: 14px;
        color: #17a2b8;
    }

.prewarming-text {
    color: #17a2b8;
    font-weight: 500;
}

.prewarming-tooltip {
    color: #ccc;
    font-size: 11px;
    margin-top: 4px;
    position: relative;
    z-index: 1;
}

/* Pulsing effect for servers being pre-warmed */
.mcp-item.prewarming-in-progress {
    position: relative;
    animation: prewarmPulse 2s ease-in-out infinite;
}

@keyframes prewarmPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(23, 162, 184, 0.4);
        border-left-color: #17a2b8;
    }

    50% {
        box-shadow: 0 0 0 4px rgba(23, 162, 184, 0);
        border-left-color: #0056b3;
    }
}

.mcp-item.prewarming-in-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, rgba(23, 162, 184, 0.05) 0%, rgba(23, 162, 184, 0.1) 50%, rgba(23, 162, 184, 0.05) 100%);
    background-size: 200% 100%;
    animation: shimmerPrewarm 2s ease-in-out infinite;
    pointer-events: none;
    border-radius: inherit;
}

@keyframes shimmerPrewarm {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* Enhanced loading phases with different icons */
.chat-item-time.prewarming-phase {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #17a2b8;
    font-weight: 500;
}

    .chat-item-time.prewarming-phase i {
        width: 12px;
        height: 12px;
    }

    /* Different colors for different phases */
    .chat-item-time.prewarming-phase:has(i[data-feather="power"]) {
        color: #ffc107; /* Yellow for activating */
    }

    .chat-item-time.prewarming-phase:has(i[data-feather="wifi"]) {
        color: #007bff; /* Blue for connecting */
    }

    .chat-item-time.prewarming-phase:has(i[data-feather="download"]) {
        color: #28a745; /* Green for caching */
    }

    .chat-item-time.prewarming-phase:has(i[data-feather="zap"]) {
        color: #17a2b8; /* Cyan for optimizing */
    }

/* Enhanced tooltips for pre-warming phases */
.mcp-item[title*="Pre-warming"]:hover::after {
    content: attr(title);
    position: absolute;
    background: rgba(23, 162, 184, 0.95);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 1000;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    animation: tooltipFadeIn 0.2s ease-out;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Progress indicator in tools dropdown */
.tools-section-header.prewarming {
    position: relative;
}

    .tools-section-header.prewarming::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        height: 2px;
        width: 30%;
        background: linear-gradient(90deg, #17a2b8, #007bff);
        border-radius: 1px;
        animation: progressSlideTools 2s ease-in-out infinite;
    }

@keyframes progressSlideTools {
    0% {
        left: 0;
        width: 30%;
    }

    50% {
        left: 35%;
        width: 30%;
    }

    100% {
        left: 70%;
        width: 30%;
    }
}

/* Status summary enhanced with progress info */
.mcp-status-summary.prewarming {
    border-left: 3px solid #17a2b8;
    background: linear-gradient(90deg, rgba(23, 162, 184, 0.1) 0%, transparent 100%);
}

    .mcp-status-summary.prewarming .status-value {
        color: #17a2b8;
        animation: pulse 1.5s ease-in-out infinite;
    }

/* Micro-animation for phase transitions */
.chat-item-time.phase-transition {
    animation: phaseTransition 0.4s ease-out;
}

@keyframes phaseTransition {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* Success completion animation */
.mcp-item.prewarming-complete {
    animation: prewarmComplete 0.6s ease-out;
}

@keyframes prewarmComplete {
    0% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .mcp-prewarming-progress {
        margin: 6px 8px 0 8px;
        padding: 8px 10px;
        font-size: 11px;
    }

    .prewarming-tooltip {
        font-size: 10px;
    }

    .chat-item-time.prewarming-phase {
        font-size: 11px;
    }

    .mcp-item[title*="Pre-warming"]:hover::after {
        font-size: 10px;
        padding: 6px 10px;
    }
}

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
    .mcp-prewarming-progress {
        background: linear-gradient(135deg, rgba(23, 162, 184, 0.15) 0%, rgba(0, 123, 255, 0.15) 100%);
        border-color: rgba(23, 162, 184, 0.3);
    }

    .mcp-item.prewarming-in-progress::after {
        background: linear-gradient(90deg, rgba(23, 162, 184, 0.08) 0%, rgba(23, 162, 184, 0.15) 50%, rgba(23, 162, 184, 0.08) 100%);
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .mcp-prewarming-progress::before,
    .mcp-item.prewarming-in-progress,
    .mcp-item.prewarming-in-progress::after,
    .progressSlideTools,
    .prewarmPulse,
    .shimmerPrewarm {
        animation: none;
    }

    .mcp-prewarming-progress {
        background: rgba(23, 162, 184, 0.2);
    }

    .mcp-item.prewarming-in-progress {
        border-left: 4px solid #17a2b8;
        background: rgba(23, 162, 184, 0.1);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .mcp-prewarming-progress {
        background: rgba(23, 162, 184, 0.3);
        border: 2px solid #17a2b8;
    }

    .prewarming-status,
    .prewarming-text {
        color: #ffffff;
        font-weight: bold;
    }

    .chat-item-time.prewarming-phase {
        background: rgba(23, 162, 184, 0.2);
        padding: 4px 8px;
        border-radius: 4px;
        color: #ffffff;
        font-weight: bold;
    }
}
/* ==================================================================================
 * CLEAN mIself ANIMATION - Consistent #eceef2 Background
 * ==================================================================================
 */

/* ✅ IN-CHAT mIself Animation (Main Style) */
.maestro-thinking-bubble {
    background: transparent !important;
    border: none !important;
    border-radius: 0;
    box-shadow: none !important;
}

.maestro-mini-animation {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 8px 0;
    min-height: unset;
    background: transparent;
}

/* ✅ Conductor Figure */
.mini-conductor {
    position: relative;
    flex-shrink: 0;
}

.mini-conductor-figure {
    width: 60px;
    height: 80px;
    position: relative;
    animation: miniConductorSway 2.5s ease-in-out infinite;
}

.mini-conductor-head {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    border-radius: 50%;
    margin: 0 auto 4px;
    animation: miniHeadNod 1.8s ease-in-out infinite;
}

.mini-conductor-body {
    width: 25px;
    height: 40px;
    background: linear-gradient(135deg, #374151 0%, #4b5563 100%);
    border-radius: 12px 12px 4px 4px;
    margin: 0 auto;
    position: relative;
}

.mini-conductor-arm {
    position: absolute;
    width: 4px;
    height: 18px;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    border-radius: 2px;
    top: 5px;
    transform-origin: bottom center;
}

    .mini-conductor-arm.left-arm {
        left: -6px;
        animation: miniLeftArmConduct 1.2s ease-in-out infinite;
    }

    .mini-conductor-arm.right-arm {
        right: -6px;
        animation: miniRightArmConduct 1.5s ease-in-out infinite;
    }

.mini-baton {
    position: absolute;
    width: 1px;
    height: 12px;
    background: linear-gradient(135deg, #eab308 0%, #d97706 100%);
    top: -10px;
    left: 1.5px;
    box-shadow: 0 0 4px rgba(234, 179, 8, 0.6);
}

/* ✅ Musical Notes */
.mini-musical-notes {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 40px;
}

.mini-note {
    position: absolute;
    font-size: 12px;
    color: #8b5cf6;
    animation: miniFloatingNotes 2.5s ease-in-out infinite;
}

.mini-note-1 {
    left: 10%;
    animation-delay: 0s;
}

.mini-note-2 {
    left: 45%;
    animation-delay: 0.8s;
}

.mini-note-3 {
    left: 75%;
    animation-delay: 1.6s;
}

/* ✅ Status Text Area */
.maestro-status-text {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0;
}

.maestro-title {
    font-size: 13px;
    font-weight: 500;
    color: #555;
    display: inline;
    margin: 0;
}

/* ✅ Mini Phases */
.orchestration-mini-phases {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: transparent;
}

.mini-phase {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(241, 245, 249, 0.6);
    border-radius: 6px;
    border-left: 2px solid rgba(203, 213, 225, 0.4);
    transition: all 0.3s ease;
    opacity: 0.6;
    font-size: 12px;
}

    .mini-phase.active {
        background: rgba(139, 92, 246, 0.1);
        border-left-color: #8b5cf6;
        opacity: 1;
        transform: scale(1.05);
        box-shadow: 0 2px 8px rgba(139, 92, 246, 0.15);
    }

.mini-phase-icon {
    width: 14px !important;
    height: 14px !important;
    flex-shrink: 0;
    color: #6b7280;
}

.mini-phase.active .mini-phase-icon {
    color: #8b5cf6;
    animation: miniPhaseIconPulse 1s ease-in-out infinite;
}

.mini-phase span {
    color: #6b7280;
    font-weight: 500;
    white-space: nowrap;
}

.mini-phase.active span {
    color: #8b5cf6;
    font-weight: 600;
}

/* ✅ Animations */
@keyframes miniConductorSway {
    0%, 100% {
        transform: rotate(-2deg) scale(0.9);
    }

    50% {
        transform: rotate(2deg) scale(1);
    }
}

@keyframes miniHeadNod {
    0%, 100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-1px);
    }
}

@keyframes miniLeftArmConduct {
    0% {
        transform: rotate(-20deg);
    }

    50% {
        transform: rotate(30deg);
    }

    100% {
        transform: rotate(-20deg);
    }
}

@keyframes miniRightArmConduct {
    0% {
        transform: rotate(30deg);
    }

    50% {
        transform: rotate(-15deg);
    }

    100% {
        transform: rotate(30deg);
    }
}

@keyframes miniFloatingNotes {
    0%, 20% {
        opacity: 0;
        transform: translateY(0) scale(0.8);
    }

    10% {
        opacity: 1;
        transform: translateY(-8px) scale(1);
    }

    90%, 100% {
        opacity: 0;
        transform: translateY(-16px) scale(0.9);
    }
}

@keyframes miniPhaseIconPulse {
    0%, 100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* ✅ Fade Out Animation */
#maestroThinking.fade-out {
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.3s ease-out;
}

/* ✅ Responsive Design */
@media (max-width: 768px) {
    .maestro-mini-animation {
        gap: 15px;
        padding: 12px 16px;
        background: transparent;
    }

    .mini-conductor-figure {
        width: 50px;
        height: 70px;
    }

    .maestro-title {
        font-size: 14px;
        background: transparent !important;
    }

    .orchestration-mini-phases {
        grid-template-columns: 1fr;
        gap: 6px;
        background: transparent;
    }

    .maestro-status-text {
        background: transparent;
    }
}

/* ✅ Tools Dropdown Close Button (Keep this working) */
.tools-dropdown-close {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 6px !important;
    padding: 8px !important;
    color: #fff !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

    .tools-dropdown-close:hover {
        background: rgba(255, 255, 255, 0.2) !important;
        border-color: rgba(255, 255, 255, 0.3) !important;
        transform: translateY(-1px) !important;
    }

    .tools-dropdown-close i {
        width: 16px !important;
        height: 16px !important;
        stroke-width: 2 !important;
    }

/* ✅ Clean up any remaining conflicts */
.maestro-mini-animation * {
    background-color: transparent;
}

.maestro-mini-animation,
.maestro-status-text,
.orchestration-mini-phases,
.maestro-title {
    background: transparent !important;
}


.chat-welcome-container.hidden {
    display: none; /* ✅ Completely removes it including shadows */
}

/* ================================================================
   MEMORY MODULE
   ================================================================ */

/* ── Sidebar view header ── */
.memory-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.memory-search-toggle,
.memory-add-topic-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: #929aac;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

    .memory-search-toggle:hover,
    .memory-add-topic-btn:hover {
        background: rgba(114, 82, 211, 0.1);
        color: #7252D3;
    }

    .memory-search-toggle i,
    .memory-add-topic-btn i {
        width: 14px;
        height: 14px;
    }

.memory-distill-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: linear-gradient(135deg, #7252D3, #9b59b6);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
    white-space: nowrap;
}

    .memory-distill-btn:hover {
        opacity: 0.88;
    }

    .memory-distill-btn i {
        width: 12px;
        height: 12px;
    }

/* ── Search bar ── */
.memory-search-bar {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    background: #fafafa;
}

.memory-search-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    padding: 6px 10px;
}

    .memory-search-input-wrap i {
        width: 14px;
        height: 14px;
        color: #929aac;
        flex-shrink: 0;
    }

    .memory-search-input-wrap input {
        flex: 1;
        border: none;
        outline: none;
        font-size: 13px;
        color: #212121;
        background: transparent;
    }

#memorySearchClear {
    border: none;
    background: transparent;
    cursor: pointer;
    color: #929aac;
    padding: 0;
    display: flex;
    align-items: center;
}

    #memorySearchClear i {
        width: 12px;
        height: 12px;
    }

.memory-search-results {
    margin-top: 8px;
    max-height: 260px;
    overflow-y: auto;
}

.memory-search-loading, .memory-search-empty {
    padding: 12px;
    text-align: center;
    font-size: 12px;
    color: #929aac;
}

.memory-search-result {
    padding: 8px 10px;
    border-radius: 6px;
    margin-bottom: 4px;
    background: #fff;
    border: 1px solid #f0f0f0;
    cursor: pointer;
    transition: border-color 0.15s;
}

    .memory-search-result:hover {
        border-color: #d0d0d0;
    }

.memory-search-result-topic {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #929aac;
    margin-bottom: 4px;
}

.memory-result-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.memory-search-result-content {
    font-size: 12px;
    color: #212121;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

    .memory-search-result-content mark {
        background: rgba(114, 82, 211, 0.2);
        color: #7252D3;
        border-radius: 2px;
        padding: 0 2px;
    }

.memory-search-result-source {
    font-size: 10px;
    color: #929aac;
    margin-top: 4px;
}

/* ── Empty state ── */
.memory-empty-state {
    padding: 40px 20px;
    text-align: center;
    color: #929aac;
}

    .memory-empty-state i {
        width: 32px;
        height: 32px;
        margin-bottom: 10px;
    }

    .memory-empty-state p {
        font-size: 13px;
        font-weight: 500;
        margin: 0 0 6px;
    }

    .memory-empty-state small {
        font-size: 11px;
        line-height: 1.5;
    }

/* ── Topics list ── */
.memory-topics-list {
    padding: 8px;
    overflow-y: auto;
    flex: 1;
}

/* ── Topic item ── */
.memory-topic-item {
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
    transition: box-shadow 0.15s;
}

    .memory-topic-item:hover {
        box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    }

.memory-topic-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
}

.memory-topic-icon {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .memory-topic-icon i {
        width: 14px;
        height: 14px;
    }

.memory-topic-info {
    flex: 1;
    min-width: 0;
}

.memory-topic-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #212121;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.memory-topic-count {
    font-size: 11px;
    color: #929aac;
}

.memory-topic-delete {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    color: #929aac;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.memory-topic-item:hover .memory-topic-delete {
    opacity: 1;
}

.memory-topic-delete:hover {
    color: #dc2626;
    background: rgba(220,38,38,0.08);
}

.memory-topic-delete i {
    width: 12px;
    height: 12px;
}

.memory-topic-summary {
    padding: 0 12px 8px;
    font-size: 11px;
    color: #666;
    line-height: 1.5;
    border-top: 1px solid #f5f5f5;
    padding-top: 8px;
}

.memory-topic-expand {
    width: 100%;
    padding: 6px 12px;
    border: none;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
    cursor: pointer;
    font-size: 11px;
    color: #929aac;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background 0.15s, color 0.15s;
}

    .memory-topic-expand:hover {
        background: #f0f0f0;
        color: #7252D3;
    }

    .memory-topic-expand i {
        width: 12px;
        height: 12px;
    }

/* ── Cards ── */
.memory-topic-cards {
    padding: 8px;
    background: #f8f9fa;
    border-top: 1px solid #f0f0f0;
}

.memory-no-cards {
    padding: 12px;
    text-align: center;
    font-size: 12px;
    color: #929aac;
}

.memory-card {
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 6px;
    transition: border-color 0.15s;
}

    .memory-card:hover {
        border-color: #d0d0d0;
    }

    .memory-card:last-child {
        margin-bottom: 0;
    }

.memory-card-content {
    font-size: 12px;
    color: #212121;
    line-height: 1.5;
    margin-bottom: 8px;
}

.memory-card-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.memory-card-ai-tag {
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    background: rgba(114, 82, 211, 0.12);
    color: #7252D3;
    border-radius: 3px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.memory-card-date {
    font-size: 10px;
    color: #929aac;
}

.memory-card-source {
    font-size: 10px;
    color: #7252D3;
    text-decoration: none;
    margin-left: auto;
}

    .memory-card-source:hover {
        text-decoration: underline;
    }

.memory-card-source-deleted {
    font-size: 10px;
    color: #929aac;
    display: flex;
    align-items: center;
    gap: 3px;
    margin-left: auto;
}

    .memory-card-source-deleted i {
        width: 10px;
        height: 10px;
    }

.memory-card-delete {
    width: 18px;
    height: 18px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #929aac;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    margin-left: auto;
}

.memory-card:hover .memory-card-delete {
    opacity: 1;
}

.memory-card-delete:hover {
    color: #dc2626;
}

.memory-card-delete i {
    width: 10px;
    height: 10px;
}

/* ── Color variants ── */
.memory-color-purple .memory-topic-icon {
    background: rgba(114, 82, 211, 0.12);
    color: #7252D3;
}

.memory-color-blue .memory-topic-icon {
    background: rgba(59, 130, 246, 0.12);
    color: #3b82f6;
}

.memory-color-green .memory-topic-icon {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}

.memory-color-orange .memory-topic-icon {
    background: rgba(249, 115, 22, 0.12);
    color: #ea580c;
}

.memory-color-red .memory-topic-icon {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
}

.memory-color-teal .memory-topic-icon {
    background: rgba(20, 184, 166, 0.12);
    color: #0d9488;
}

.memory-result-dot.memory-color-purple {
    background: #7252D3;
}

.memory-result-dot.memory-color-blue {
    background: #3b82f6;
}

.memory-result-dot.memory-color-green {
    background: #16a34a;
}

.memory-result-dot.memory-color-orange {
    background: #ea580c;
}

.memory-result-dot.memory-color-red {
    background: #dc2626;
}

.memory-result-dot.memory-color-teal {
    background: #0d9488;
}

/* ── Brain save button on messages ── */
.message-action-btn.memory-save-btn {
    color: #929aac;
}

    .message-action-btn.memory-save-btn:hover {
        color: #7252D3;
        background: rgba(114, 82, 211, 0.1);
    }

/* ── Save popover ── */
.memory-save-popover {
    position: fixed;
    z-index: 99998;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    width: 260px;
    animation: memoryPopoverIn 0.15s ease-out;
}

@keyframes memoryPopoverIn {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.97);
    }

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

.memory-popover-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px 8px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 12px;
    font-weight: 600;
    color: #212121;
}

    .memory-popover-header i {
        width: 14px;
        height: 14px;
        color: #7252D3;
        flex-shrink: 0;
    }

.memory-popover-close {
    margin-left: auto;
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #929aac;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .memory-popover-close:hover {
        color: #374151;
        background: #f3f4f6;
    }

    .memory-popover-close i {
        width: 12px;
        height: 12px;
    }

.memory-popover-body {
    padding: 12px;
}

.memory-popover-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #929aac;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 6px;
}

.memory-topic-select-wrap {
    display: flex;
    gap: 6px;
    align-items: center;
}

.memory-topic-select {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #e6e6e6;
    border-radius: 6px;
    font-size: 12px;
    color: #212121;
    background: #fff;
    outline: none;
}

    .memory-topic-select:focus {
        border-color: #7252D3;
    }

.memory-new-topic-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #e6e6e6;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    color: #7252D3;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

    .memory-new-topic-btn:hover {
        background: rgba(114,82,211,0.08);
    }

    .memory-new-topic-btn i {
        width: 12px;
        height: 12px;
    }

.memory-new-topic-inline {
    margin-top: 6px;
}

.memory-new-topic-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #7252D3;
    border-radius: 6px;
    font-size: 12px;
    color: #212121;
    outline: none;
    box-sizing: border-box;
}

.memory-popover-save-btn {
    width: 100%;
    margin-top: 10px;
    padding: 8px;
    background: #7252D3;
    color: #fff;
    border: none;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.15s;
}

    .memory-popover-save-btn:hover {
        background: #6345c4;
    }

    .memory-popover-save-btn i {
        width: 14px;
        height: 14px;
    }

/* ── Distill inline sidebar card ── */
.memory-distill-card {
    background: linear-gradient(135deg, rgba(114,82,211,0.06), rgba(155,89,182,0.04));
    border: 1px solid rgba(114,82,211,0.2);
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
}

.memory-distill-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(114,82,211,0.1);
}

.memory-distill-card-icon {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: rgba(114,82,211,0.12);
    color: #7252D3;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .memory-distill-card-icon.error {
        background: rgba(220,38,38,0.1);
        color: #dc2626;
    }

    .memory-distill-card-icon i {
        width: 13px;
        height: 13px;
    }

.memory-distill-card-title-wrap {
    flex: 1;
}

.memory-distill-card-title {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #212121;
}

.memory-distill-card-meta {
    font-size: 10px;
    color: #929aac;
}

.memory-distill-card-dismiss {
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #929aac;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
}

    .memory-distill-card-dismiss:hover {
        color: #374151;
        background: rgba(0,0,0,0.06);
    }

    .memory-distill-card-dismiss i {
        width: 12px;
        height: 12px;
    }

/* scanning state */
.memory-distill-scanning {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    font-size: 12px;
    color: #666;
}

.memory-distill-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e7dff3;
    border-top-color: #7252D3;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* summary line */
.memory-distill-inline-summary {
    font-size: 11px;
    color: #666;
    line-height: 1.5;
    padding: 8px 12px 4px;
    margin: 0;
}

/* topics inside card */
.memory-distill-inline-topics {
    padding: 6px 8px 0;
}

.memory-distill-inline-topic {
    border: 1px solid #eee;
    border-radius: 7px;
    margin-bottom: 6px;
    overflow: hidden;
    background: #fff;
}

.memory-distill-inline-topic-header {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 10px;
    background: #fafafa;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
}

    .memory-distill-inline-topic-header input {
        accent-color: #7252D3;
        flex-shrink: 0;
    }

.memory-distill-topic-icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .memory-distill-topic-icon i {
        width: 11px;
        height: 11px;
    }

.memory-color-purple .memory-distill-topic-icon {
    background: rgba(114,82,211,0.12);
    color: #7252D3;
}

.memory-color-blue .memory-distill-topic-icon {
    background: rgba(59,130,246,0.12);
    color: #3b82f6;
}

.memory-color-green .memory-distill-topic-icon {
    background: rgba(34,197,94,0.12);
    color: #16a34a;
}

.memory-color-orange .memory-distill-topic-icon {
    background: rgba(249,115,22,0.12);
    color: #ea580c;
}

.memory-color-red .memory-distill-topic-icon {
    background: rgba(239,68,68,0.12);
    color: #dc2626;
}

.memory-color-teal .memory-distill-topic-icon {
    background: rgba(20,184,166,0.12);
    color: #0d9488;
}

.memory-distill-topic-name {
    font-size: 12px;
    font-weight: 600;
    color: #212121;
    flex: 1;
}

.memory-distill-badge {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 2px 5px;
    border-radius: 3px;
    flex-shrink: 0;
}

    .memory-distill-badge.new {
        background: rgba(114,82,211,0.12);
        color: #7252D3;
    }

    .memory-distill-badge.existing {
        background: rgba(34,197,94,0.12);
        color: #16a34a;
    }

/* individual cards inside distill result */
.memory-distill-inline-cards {
    padding: 4px 6px 6px;
}

.memory-distill-inline-card {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    padding: 5px 6px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.12s;
}

    .memory-distill-inline-card:hover {
        background: #f5f7fa;
    }

    .memory-distill-inline-card input {
        flex-shrink: 0;
        margin-top: 2px;
        accent-color: #7252D3;
    }

.memory-distill-inline-card-text {
    font-size: 11px;
    color: #374151;
    line-height: 1.4;
}

/* action buttons row */
.memory-distill-card-actions {
    display: flex;
    gap: 6px;
    padding: 8px 10px 10px;
}

.memory-distill-accept-all {
    flex: 1;
    padding: 7px 10px;
    background: #7252D3;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: background 0.15s;
}

    .memory-distill-accept-all:hover {
        background: #6345c4;
    }

    .memory-distill-accept-all i {
        width: 12px;
        height: 12px;
    }

.memory-distill-reject-all {
    padding: 7px 10px;
    background: transparent;
    color: #929aac;
    border: 1px solid #e6e6e6;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

    .memory-distill-reject-all:hover {
        border-color: #d0d0d0;
        color: #374151;
    }

/* error state */
.memory-distill-error-msg {
    padding: 8px 14px 12px;
    font-size: 12px;
    color: #dc2626;
    margin: 0;
}

/* ── Toast notification ── */
.memory-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: #212121;
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 999999;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

    .memory-toast.visible {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

    .memory-toast i {
        width: 14px;
        height: 14px;
        flex-shrink: 0;
    }

.memory-toast-success {
    background: #16a34a;
}

.memory-toast-error {
    background: #dc2626;
}

.memory-toast-warning {
    background: #d97706;
}

.memory-load-error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    margin: 8px;
    background: rgba(220,38,38,0.06);
    border: 1px solid rgba(220,38,38,0.15);
    border-radius: 7px;
    font-size: 12px;
    color: #dc2626;
}

    .memory-load-error i {
        width: 14px;
        height: 14px;
        flex-shrink: 0;
    }

.memory-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 12px;
    font-size: 12px;
    color: #929aac;
}

/* ── Card type tags ── */
.memory-card-type-row {
    margin-bottom: 7px;
}

.memory-card-type-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 2px 6px;
    border-radius: 4px;
}

    .memory-card-type-tag i {
        width: 9px;
        height: 9px;
    }

    .memory-card-type-tag.snippet {
        background: rgba(114,82,211,0.1);
        color: #7252D3;
    }

    .memory-card-type-tag.full {
        background: rgba(59,130,246,0.1);
        color: #3b82f6;
    }

    .memory-card-type-tag.library {
        background: rgba(20,184,166,0.1);
        color: #0d9488;
    }

/* ── Full response card ── */
.memory-card-full {
    border-left: 3px solid #3b82f6;
}

.memory-card-full-content {
    max-height: 120px;
    overflow-y: auto;
    font-size: 12px;
    color: #374151;
    line-height: 1.5;
}

/* ── Library card ── */
.memory-card-library {
    border-left: 3px solid #0d9488;
}

.memory-card-image {
    width: 100%;
    height: 80px;
    overflow: hidden;
    border-radius: 5px;
    margin-bottom: 8px;
    background: #f3f4f6;
}

    .memory-card-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

.memory-card-link-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

    .memory-card-link-row i {
        width: 12px;
        height: 12px;
        color: #0d9488;
        flex-shrink: 0;
    }

.memory-card-link-title {
    font-size: 12px;
    font-weight: 600;
    color: #0d9488;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

    .memory-card-link-title:hover {
        text-decoration: underline;
    }

.memory-card-description {
    font-size: 11px;
    color: #6b7280;
    line-height: 1.4;
    margin-top: 4px;
}

/* ── Popover content preview ── */
.memory-save-content-preview {
    font-size: 11px;
    color: #666;
    background: #f8f9fa;
    border: 1px solid #e6e6e6;
    border-radius: 5px;
    padding: 6px 8px;
    margin-bottom: 10px;
    line-height: 1.4;
    max-height: 60px;
    overflow: hidden;
}

/* ── Library button in header ── */
.memory-add-library-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: #929aac;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

    .memory-add-library-btn:hover {
        background: rgba(13,148,136,0.1);
        color: #0d9488;
    }

    .memory-add-library-btn i {
        width: 14px;
        height: 14px;
    }

/* ── Full response save button ── */
.memory-save-full-btn:hover {
    color: #3b82f6 !important;
    background: rgba(59,130,246,0.1) !important;
}


/* =================================================================
   RIGHT HAMBURGER BUTTON (.toggle-secondary-sidebar)
   Matches .toggle-sidebar exactly. Shown on mobile (d-lg-none).
   ================================================================= */

.toggle-secondary-sidebar {
    background: none;
    border: none;
    font-size: 24px;
    color: #212121;
    cursor: pointer;
    padding: 8px;
    display: none; /* hidden by default; overridden by d-lg-none media query */
}

    .toggle-secondary-sidebar svg {
        width: 24px;
        height: 24px;
    }

/* Mobile: show right hamburger */
@media (max-width: 991px) {
    .toggle-secondary-sidebar {
        display: block;
    }
}


/* =================================================================
   CONTENT CENTERING — desktop only
   On mobile the content runs full-width edge to edge.
   ================================================================= */

@media (min-width: 992px) {
    .page-content,
    .studio-content,
    .products-content,
    .products-detail-content {
        max-width: 960px;
        margin-left: auto;
        margin-right: auto;
        padding-left: 2rem;
        padding-right: 2rem;
        box-sizing: border-box;
    }
}

@media (max-width: 991px) {
    .page-content,
    .studio-content,
    .products-content,
    .products-detail-content {
        max-width: 100% !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        box-sizing: border-box !important;
    }
}


/* =================================================================
   STUDIO FILTERS — responsive scrollable row
   Prevents the filter tabs from overflowing on narrow screens.
   ================================================================= */

@media (max-width: 991px) {
    .studio-filter-row {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px; /* room for scrollbar */
    }

    .studio-filters {
        flex-wrap: nowrap;
        min-width: max-content; /* keep all buttons on one line, scroll to reach them */
    }
}


/* =================================================================
   PRODUCTS BODY — layout overrides
   Products pages have only the LEFT sidebar (70px wide).
   The global .page-container margin-left:365px is for the chat page
   (left nav + secondary sidebar). Override it here.
   ================================================================= */

/* ── Desktop ─────────────────────────────────────────────────────── */
@media (min-width: 992px) {
    /* Page container: only left nav offset */
    .products-body .page-container {
        margin-left: 70px !important;
    }

    .products-body.menu-pin .page-container {
        margin-left: 250px !important;
    }

    /* Header follows the same offset */
/*    .products-body .header {
        left: 70px !important;
    }

    .products-body.menu-pin .header {
        left: 250px !important;
    }*/

    /* Secondary sidebar is desktop-invisible on products pages.
       The right hamburger is d-lg-none so it's already hidden — this
       just ensures the sidebar panel itself doesn't occupy space. */
    .products-body .secondary-sidebar {
        display: none !important;
    }
}

/* ── Mobile ──────────────────────────────────────────────────────── */
@media (max-width: 991px) {
    /* No left offset on mobile */
    .products-body .page-container {
        margin-left: 0 !important;
    }

    /* Header fills full width on mobile */
    .products-body .header {
        left: 0 !important;
        right: 0 !important;
    }

    /* Secondary sidebar slides in from the RIGHT on products pages.
       Override the default left-based slide-in animation. */
    .products-body .secondary-sidebar {
        display: block !important;
        left: auto !important;
        right: -295px !important; /* start off-screen right */
        transform: none !important;
        transition: right 0.3s ease !important;
        top: 45px;
        width: 295px;
        height: calc(100% - 45px);
        position: fixed !important;
        z-index: 1000;
    }

    /* Slide in from right when body has .secondary-sidebar-visible */
    .products-body.secondary-sidebar-visible .secondary-sidebar {
        right: 0 !important;
        left: auto !important;
    }

    /* Overlay */
    .products-body.secondary-sidebar-visible .secondary-sidebar-overlay {
        display: block;
        opacity: 1;
    }
}


/* =================================================================
   MCP PRE-WARMING WELCOME POPUP
   Must be fixed-position so it floats above all pages,
   not in document flow where it bleeds into the left edge.
   ================================================================= */

.mcp-prewarming-welcome {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 320px;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.14);
    overflow: hidden;
}

    .mcp-prewarming-welcome .welcome-content {
        padding: 0;
    }

    .mcp-prewarming-welcome .welcome-header {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 14px 16px;
        background: linear-gradient(135deg, #5d5386, #4a90d9);
        color: #fff;
    }

        .mcp-prewarming-welcome .welcome-header h4 {
            margin: 0;
            font-size: 14px;
            font-weight: 600;
            flex: 1;
            color: #fff;
        }

    .mcp-prewarming-welcome .welcome-close {
        background: none;
        border: none;
        color: rgba(255,255,255,0.8);
        cursor: pointer;
        padding: 2px;
        display: flex;
        align-items: center;
    }

    .mcp-prewarming-welcome .welcome-body {
        padding: 16px;
        font-size: 13px;
        color: #444;
    }

    .mcp-prewarming-welcome .welcome-footer {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        border-top: 1px solid #f0f0f0;
        font-size: 12px;
    }

@media (max-width: 991px) {
    .mcp-prewarming-welcome {
        bottom: 16px;
        right: 16px;
        left: 16px;
        width: auto;
    }
}

/* mIself cursor pulse */
.maestro-cursor {
    display: inline-block;
    color: var(--primary, #8b6fd4);
    font-size: 14px;
    margin-left: 1px;
    animation: maestro-blink 1s step-start infinite;
    vertical-align: text-bottom;
}

@keyframes maestro-blink {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.orchestration-mini-phases {
    display: none !important;
}

/* ── CapabilityUI iframe — adaptive width ───────────────────────────────────
   When a message bubble contains a capability block, lift the 900px cap so
   the iframe fills the available chat column automatically.                  */
.capability-ui-block {
    width: 100%;
}

.capability-ui-iframe {
    width: 100%;
    border: none;
    display: block;
}

/* Lift max-width constraint on any bubble that wraps a capability block */
.message-bubble:has(.capability-ui-block) {
    max-width: 100%;
}

/* Maestro thinking bubble: no extra padding, aligns with normal messages */
.maestro-thinking-bubble {
    padding-bottom: 12px !important;
}

/* ── Inline thinking (lives inside the message bubble) ─────────────────────── */
.maestro-inline-thinking {
    padding: 4px 0 8px 0;
}

    .maestro-inline-thinking .maestro-mini-animation {
        padding: 4px 0;
        min-height: unset;
    }

/* =================================================================
   HOME PAGE — Secondary sidebar on RIGHT side
   Only applies to Home (/) via .home-body class on <body>.
   Admin and other chat pages keep the sidebar on the LEFT.
   ================================================================= */

/* ── Desktop: move sidebar to right ─────────────────────────────── */
@media (min-width: 992px) {
    .home-body .secondary-sidebar {
        left: auto;
        right: 0;
        border-right: none !important;
        border-left: 1px solid #e6e6e6;
        box-shadow: none !important;
        outline: none;
        overflow: hidden;
        transition: right 0.4s cubic-bezier(0.05, 0.74, 0.27, 0.99);
    }

    .home-body.menu-pin .secondary-sidebar {
        left: auto;
        right: 0;
    }

    /* Adjust content height: subtract toggle bar (~37px) */
    .home-body .secondary-sidebar-content {
        height: calc(100vh - 45px - 37px);
        /* Hide scrollbar completely — content still scrollable (iOS-style).
           Eliminates scrollbar gutter that causes the right-edge shadow. */
        scrollbar-width: none;             /* Firefox */
    }

    .home-body .secondary-sidebar-content::-webkit-scrollbar {
        display: none;                     /* Chrome/Safari */
    }

    /* Hide the per-view "Recent Chats" header — toggle bar already says History */
    .home-body .sidebar-view-header {
        display: none;
    }

    /* Hide toolbar tabs on Home — sidebar only shows chat history.
       Use visibility:hidden (not display:none) to keep flex layout space
       so "New Chat" stays on the right via justify-content:space-between. */
    .home-body .header .secondary-toolbar {
        visibility: hidden;
        pointer-events: none;
    }

    /* Page container: left nav only + right margin for sidebar */
    .home-body .page-container {
        margin-left: 70px;
        margin-right: 295px;
    }

    .home-body.menu-pin .page-container {
        margin-left: 250px;
        margin-right: 295px;
    }

    /* Chat areas: left-aligned to nav, right offset for sidebar */
    .home-body .chat-welcome-container {
        left: 70px;
        right: 315px;
    }

    .home-body.menu-pin .chat-welcome-container {
        left: 250px;
        right: 315px;
    }

    .home-body .chat-messages-area {
        left: 70px;
        right: 315px;
    }

    .home-body.menu-pin .chat-messages-area {
        left: 250px;
        right: 315px;
    }

    .home-body .chat-container.bottom-mode {
        left: 70px;
        right: 315px;
    }

    .home-body.menu-pin .chat-container.bottom-mode {
        left: 250px;
        right: 315px;
    }
}

/* ── Mobile: sidebar slides from right ──────────────────────────── */
@media (max-width: 991px) {
    .home-body .secondary-sidebar {
        left: auto;
        right: -295px;
        border-right: none;
        border-left: 1px solid #e6e6e6;
        transition: right 0.3s ease;
    }

    .home-body.secondary-sidebar-visible .secondary-sidebar {
        right: 0;
        left: auto;
    }

    /* Reset right margin — full width on mobile */
    .home-body .page-container {
        margin-right: 0;
    }

    .home-body .chat-welcome-container,
    .home-body .chat-messages-area {
        right: 20px;
    }

    .home-body .chat-container.bottom-mode {
        right: 20px;
    }
}

@media (max-width: 768px) {
    .home-body .chat-welcome-container,
    .home-body .chat-messages-area {
        right: 10px;
    }

    .home-body .chat-container.bottom-mode {
        right: 10px;
    }
}

/* =================================================================
   SECONDARY SIDEBAR — Toggle bar + Collapsed state (Home only)
   ================================================================= */

/* Toggle bar: hidden by default (Admin etc.), shown only on .home-body */
.ss-toggle-bar {
    display: none;
}

.home-body .ss-toggle-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    background: #fafbfc;
    flex-shrink: 0;
}

.ss-toggle-title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ss-toggle-title svg {
    color: #7252D3;
    flex-shrink: 0;
}

.ss-toggle-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: #626a7a;
}

.ss-collapse-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: #929aac;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.ss-collapse-btn:hover {
    background: rgba(114, 82, 211, 0.1);
    color: #7252D3;
}

/* Floating expand tab — visible only when collapsed */
.ss-expand-tab {
    display: none;
}

@media (min-width: 992px) {
    .home-body.ss-collapsed .ss-expand-tab {
        display: flex;
        position: fixed;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        z-index: 999;
        width: 24px;
        height: 48px;
        border: 1px solid #d8d0ed;
        border-right: none;
        background: #f5f0ff;
        border-radius: 8px 0 0 8px;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        color: #7252D3;
        box-shadow: -2px 0 8px rgba(114, 82, 211, 0.1);
        transition: background 0.15s, width 0.15s;
    }

    .home-body.ss-collapsed .ss-expand-tab:hover {
        background: #ede7f9;
        width: 30px;
    }

    .home-body.ss-collapsed .ss-expand-tab svg {
        width: 14px;
        height: 14px;
    }

    /* Hide the label and extra icons — only show the chevron */
    .home-body.ss-collapsed .ss-expand-tab .ss-expand-label {
        display: none;
    }

    /* ── Collapsed state: fully hidden (no DOM rendering, no data load) ── */
    .home-body.ss-collapsed .secondary-sidebar {
        display: none;
    }

    .home-body.ss-collapsed .page-container {
        margin-right: 0;
    }

    .home-body.ss-collapsed.menu-pin .page-container {
        margin-right: 0;
    }

    .home-body.ss-collapsed .chat-welcome-container {
        left: 70px;
        right: 20px;
    }

    .home-body.ss-collapsed.menu-pin .chat-welcome-container {
        left: 250px;
        right: 20px;
    }

    .home-body.ss-collapsed .chat-messages-area {
        left: 70px;
        right: 20px;
    }

    .home-body.ss-collapsed.menu-pin .chat-messages-area {
        left: 250px;
        right: 20px;
    }

    .home-body.ss-collapsed .chat-container.bottom-mode {
        left: 70px;
        right: 20px;
    }

    .home-body.ss-collapsed.menu-pin .chat-container.bottom-mode {
        left: 250px;
        right: 20px;
    }
}

/* =================================================================
   HOME PAGE: Hide admin-only elements
   ================================================================= */

/* Hide Tools button on Home page */
.home-body .admin-only-btn { display: none !important; }

/* Hide Agents, MCP, Memory tabs on Home — keep only History on desktop */
.home-body .secondary-toolbar-btn[data-view="agents"],
.home-body .secondary-toolbar-btn[data-view="mcp"],
.home-body .secondary-toolbar-btn[data-view="memory"] {
    display: none !important;
}

/* Hide entire toolbar on Home mobile */
@media (max-width: 991px) {
    .home-body .secondary-toolbar {
        display: none !important;
    }
}

/* Ensure right sidebar toggle is visible on mobile (Home) */
@media (max-width: 991px) {
    .home-body .toggle-secondary-sidebar {
        display: flex !important;
        align-items: center;
    }
}

/* ── Mobile bottom navigation bar ──────────────────────────── */
.mobile-bottom-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--s-surface, #fff);
    border-top: 1px solid var(--s-border, #e2dff0);
    z-index: 500;
    justify-content: space-around;
    align-items: center;
    padding: 0 8px;
}

.mbb-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    text-decoration: none;
    color: var(--s-text-muted, #9b94ae);
    font-size: 10px;
    font-weight: 500;
    border-radius: 8px;
    transition: color 0.12s, background 0.12s;
    min-width: 56px;
}

.mbb-item svg { width: 20px; height: 20px; }

.mbb-item:hover {
    color: var(--s-text-mid, #6b6480);
    text-decoration: none;
}

.mbb-item.mbb-active {
    color: var(--s-accent, #6d5eac);
}

@media (max-width: 768px), (pointer: coarse) and (max-width: 1024px) {
    .mobile-bottom-bar { display: flex; }
    body { padding-bottom: 56px; }
    body.settings-body .page-content-wrapper { padding-bottom: 56px; }
}

/* =================================================================
   KNOWLEDGE SOURCES MODAL
   ================================================================= */
.ks-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(26,22,40,.45);
    backdrop-filter: blur(3px);
    z-index: 10000;
    opacity: 0;
    transition: opacity .25s;
}
.ks-modal-backdrop.visible { opacity: 1; }

.ks-modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(.95);
    background: var(--s-surface, #fff);
    border: 1px solid var(--s-border, #e8dfd5);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.18);
    z-index: 10001;
    width: 520px;
    max-width: 92vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity .25s, transform .25s;
}
.ks-modal.visible { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.ks-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--s-border, #e8dfd5);
    flex-shrink: 0;
}
.ks-modal-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--s-text, #1a1628);
    display: flex;
    align-items: center;
    gap: 8px;
}
.ks-modal-close {
    background: none; border: none; cursor: pointer;
    color: var(--s-text-muted, #b5a99b); padding: 4px;
}
.ks-modal-close:hover { color: var(--s-text, #1a1628); }

.ks-modal-search {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--s-border, #e8dfd5);
    flex-shrink: 0;
}
.ks-modal-search input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--s-border, #e8dfd5);
    border-radius: 8px;
    font-size: 13px;
    color: var(--s-text, #1a1628);
    background: var(--s-surface, #fff);
    font-family: inherit;
}
.ks-modal-search input:focus { outline: none; border-color: var(--s-accent, #a88bc2); }
.ks-modal-search-btn {
    background: var(--s-accent, #a88bc2);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
}
.ks-modal-search-btn:hover { opacity: .85; }

.ks-modal-results {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.ks-source-card {
    border: 1px solid var(--s-border, #e8dfd5);
    border-radius: 10px;
    margin-bottom: 12px;
    overflow: hidden;
}
.ks-source-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--s-surface-2, #f5f1ec);
}
.ks-source-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--s-text, #1a1628);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ks-source-count {
    font-size: 10px;
    color: var(--s-text-muted, #b5a99b);
    flex-shrink: 0;
}
.ks-chunk {
    padding: 10px 14px;
    border-top: 1px solid var(--s-border, #e8dfd5);
}
.ks-chunk-idx {
    font-size: 10px;
    font-weight: 700;
    color: var(--s-accent, #a88bc2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.ks-chunk-text {
    font-size: 12.5px;
    color: var(--s-text-mid, #6b6480);
    line-height: 1.6;
}

@media (max-width: 600px) {
    .ks-modal {
        width: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        top: 0; left: 0;
        transform: translateY(20px);
    }
    .ks-modal.visible { transform: translateY(0); }
}

/* ============================================================================
   ACTIVE PERSONA CHIP  (top-bar indicator from sparkai-extras.js)
   ============================================================================ */
.header-persona-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 8px;
    border-radius: 999px;
    border: 1px solid var(--s-border, #e5e7eb);
    background: var(--s-bg-card, #fff);
    color: var(--s-text, #111);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    line-height: 1.2;
    transition: background 0.15s, border-color 0.15s;
}

.header-persona-chip:hover {
    background: var(--s-surface-2, #f3f4f6);
    border-color: var(--s-accent, #7c3aed);
}

.header-persona-chip-icon {
    width: 14px;
    height: 14px;
    color: var(--s-accent, #7c3aed);
    flex-shrink: 0;
}

.header-persona-chip-label {
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Popover that appears when chip is clicked */
.header-persona-popover {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    min-width: 220px;
    max-width: 280px;
    background: var(--s-bg-card, #fff);
    border: 1px solid var(--s-border, #e5e7eb);
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    z-index: 9000;
    padding: 6px;
    display: none;
}

.header-persona-popover.active { display: block; }

.header-persona-popover-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--s-text, #111);
    font-size: 13px;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
}

.header-persona-popover-item:hover {
    background: var(--s-surface-2, #f3f4f6);
}

.header-persona-popover-item.is-active {
    color: var(--s-accent, #7c3aed);
    font-weight: 600;
}

.header-persona-popover-item.is-deactivate {
    color: #b91c1c;
    border-top: 1px solid var(--s-border, #e5e7eb);
    margin-top: 4px;
    padding-top: 10px;
}

.header-persona-popover-empty {
    padding: 10px;
    font-size: 12px;
    color: var(--s-text-muted, #6b7280);
    text-align: center;
}

/* Position the chip+popover container relative so popover anchors correctly */
.header-persona-chip-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}


/* ── Persona picker: belief quote line (Block B Step 3) ───────────────── */
/* Surfaces the persona's `belief` field as a small italic quote under the   */
/* name in the header popover. Optional — if belief is null/empty, only the  */
/* name renders, exactly as before this change.                              */
.header-persona-popover-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.header-persona-popover-name {
    font-size: 13px;
    line-height: 1.3;
}
.header-persona-popover-belief {
    font-size: 11px;
    line-height: 1.35;
    font-style: italic;
    color: var(--s-text-muted, #b5a99b);
    opacity: 0.85;
    white-space: normal;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}


/* Mobile (ship 51): with pinch-zoom re-enabled platform-wide, iOS
   auto-zooms when focusing form controls sized <16px. Pin text-entry
   controls to 16px on small screens so focus never jumps the layout. */
@media (max-width: 768px) {
    input[type="text"], input[type="email"], input[type="search"],
    input[type="password"], input[type="number"], input[type="url"],
    textarea, select { font-size: 16px; }
}
