/* ==========================================================================
   AgenticApp - Component Styles
   Reusable component classes for consistent UI patterns
   ========================================================================== */

/* ==========================================================================
   CARDS & CONTAINERS
   ========================================================================== */

/* Agent Card - List view card for agents */
.agent-card {
    height: 100%;
}

    .agent-card .card-title {
        margin-bottom: 0;
        font-size: 1.25rem;
        font-weight: 600;
    }

    .agent-card .card-text {
        font-size: 0.875rem;
    }

/* Stats Card - Metric display cards */
.stats-card {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    background: white;
    border-radius: 0.5rem;
    border: 1px solid #e0e0e0;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    gap: 1rem;
}

    .stats-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }

    .stats-card .stats-icon {
        font-size: 2rem;
        width: 3rem;
        height: 3rem;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 0.5rem;
        background: rgba(0, 123, 255, 0.1);
        flex-shrink: 0;
    }

        .stats-card .stats-icon.text-primary {
            background: rgba(0, 123, 255, 0.1);
            color: #007bff;
        }

        .stats-card .stats-icon.text-success {
            background: rgba(40, 167, 69, 0.1);
            color: #28a745;
        }

        .stats-card .stats-icon.text-info {
            background: rgba(23, 162, 184, 0.1);
            color: #17a2b8;
        }

        .stats-card .stats-icon.text-warning {
            background: rgba(255, 193, 7, 0.1);
            color: #ffc107;
        }

    .stats-card .stats-content {
        flex: 1;
    }

    .stats-card .stats-value {
        font-size: 1.75rem;
        font-weight: 700;
        line-height: 1;
        margin-bottom: 0.25rem;
    }

    .stats-card .stats-label {
        font-size: 0.875rem;
        color: #6c757d;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        font-weight: 500;
    }

    /* Legacy stats card styles for backward compatibility */
    .stats-card h2 {
        font-size: 2rem;
        font-weight: 700;
        margin-bottom: 0;
    }

    .stats-card h6 {
        font-size: 0.75rem;
        letter-spacing: 0.5px;
        margin-bottom: 0.5rem;
    }

/* Info Card - General information card */
.info-card {
    margin-top: 1rem;
}

    .info-card .card-header h5 {
        margin-bottom: 0;
        font-size: 1rem;
        font-weight: 600;
    }

/* ==========================================================================
   FORMS & INPUTS
   ========================================================================== */

/* Form Section - Grouping related form fields */
.form-section {
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 0.375rem;
    margin-bottom: 1.5rem;
}

    .form-section h5 {
        font-size: 1.125rem;
        font-weight: 600;
        margin-bottom: 1rem;
        color: #495057;
    }

/* Form Group Spacing */
.form-group-spaced {
    margin-bottom: 1.5rem;
}

/* Required Field Indicator */
.field-required {
    color: #dc3545;
    font-weight: 600;
}

/* ==========================================================================
   BADGES & STATUS INDICATORS
   ========================================================================== */

/* Status Badge Group */
.status-badge-group {
    display: flex;
    gap: 0.25rem;
}

/* Active/Inactive Badges */
.badge-active {
    background-color: #28a745;
}

.badge-inactive {
    background-color: #6c757d;
}

/* Shared/Private Badges */
.badge-shared {
    background-color: #17a2b8;
}

/* Model tested/untested status badges */
.badge-tested {
    background-color: rgba(25, 135, 84, 0.15);
    color: var(--success-green, #198754);
    font-size: 0.7rem;
}

.badge-untested {
    background-color: rgba(255, 193, 7, 0.15);
    color: var(--bs-warning-text-emphasis, #997404);
    font-size: 0.7rem;
}

/* Model table row tested indicator - subtle green left border */
.model-row-tested {
    border-left: 3px solid var(--success-green, #198754);
}

.model-row-untested {
    border-left: 3px solid var(--bs-warning, #ffc107);
}

.badge-private {
    background-color: #007bff;
}

/* ==========================================================================
   BUTTONS & ACTIONS
   ========================================================================== */

/* Action Toolbar - Button groups for actions */
.action-toolbar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Button Group Full Width */
.btn-group-full {
    width: 100%;
}

/* Icon Button - Buttons with icons */
.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

/* Back Button */
.btn-back {
    padding: 0;
    font-size: 1.5rem;
    color: #6c757d;
    background: none;
    border: none;
}

    .btn-back:hover {
        color: #495057;
    }

/* ==========================================================================
   MODALS & OVERLAYS
   ========================================================================== */

/* Modal Backdrop - Semi-transparent overlay */
.modal-backdrop-custom {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1040;
}

/* Confirmation Modal */
.modal-confirm .modal-body {
    padding: 1.5rem;
}

.modal-confirm .modal-footer {
    padding: 1rem 1.5rem;
}

/* ==========================================================================
   LOADING & STATES
   ========================================================================== */

/* Loading State - Centered spinner */
.loading-state {
    text-align: center;
    padding: 3rem 1rem;
}

    .loading-state .spinner-border {
        width: 3rem;
        height: 3rem;
        border-width: 0.3rem;
    }

/* Empty State - No data message */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

    .empty-state i {
        font-size: 3rem;
        color: #6c757d;
        margin-bottom: 1rem;
    }

    .empty-state p {
        color: #6c757d;
        font-size: 1.125rem;
    }

/* Error State - Error message display */
.error-state {
    padding: 1rem;
    border-radius: 0.375rem;
}

/* ==========================================================================
   PAGE HEADERS
   ========================================================================== */

/* Page Header - Top of page with title and actions */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

    .page-header h3 {
        margin-bottom: 0;
        font-size: 1.75rem;
        font-weight: 600;
    }

/* Page Header with Back Button */
.page-header-with-back {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

    .page-header-with-back h3 {
        margin-bottom: 0;
        font-size: 1.5rem;
        font-weight: 600;
    }

/* ==========================================================================
   LISTS & ITEMS
   ========================================================================== */

/* Tool List - List of tools with icons */
.tool-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

    .tool-list li {
        padding: 0.5rem 0;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

        .tool-list li i {
            color: #6c757d;
        }

/* Definition List Horizontal */
.dl-horizontal dt {
    font-weight: 600;
    color: #495057;
}

.dl-horizontal dd {
    margin-bottom: 0.5rem;
}

/* ==========================================================================
   GRID & LAYOUT
   ========================================================================== */

/* Stats Grid - Grid layout for statistics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

/* Card Grid - Grid layout for cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* ==========================================================================
   CHAT INTERFACE - Full viewport, single column, compact design
   ========================================================================== */

/* Chat Page - Full viewport minus navbar, no scrollbars */
.chat-page {
    /* Compensate for workspace-content padding */
    margin: -24px;
    height: calc(100vh - 70px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative; /* For sidebar positioning context */
    transition: margin-right 0.3s ease;
}

/* Adjust container when sidebar is visible */
.chat-page.with-sidebar {
    margin-right: calc(-24px + 280px); /* Compensate for workspace padding + sidebar width */
}

/* ========== CONVERSATION PANEL ========== */
.chat-conversation {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
    transition: margin-right 0.3s ease;
}

/* Adjust for sidebar - legacy class */
.chat-conversation.with-sidebar {
    margin-right: 280px;
}

/* Chat Header - Agent selector + compact metrics */
/* Chat Header - 3 Visual Groups */
.chat-header {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #dee2e6;
    background: white;
    flex-shrink: 0;
    gap: 0;
    width: 100%;
}

/* Header Groups with Visual Separation */
.chat-header-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1rem;
    height: 100%;
}

/* Group 1: Configuration (Agent + Model Stacked) */
.chat-config-group {
    flex: 0 1 auto;
    padding-left: 0;
    border-right: 1px solid #e0e0e0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
}

.chat-config-stack {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 260px;
    max-width: 320px;
}

.chat-selector-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 32px;
    overflow: hidden;
}

.chat-selector-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6c757d;
    min-width: 50px;
    margin: 0;
}

/* Group 2: History (Conversation + New) */
.chat-history-group {
    flex: 1 1 auto;
    border-right: 1px solid #e0e0e0;
}

/* Group 3: Metrics (Context + Cost) */
.chat-metrics-group {
    flex: 0 0 auto;
    padding-right: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}



.chat-dropdown {
    padding: 0.375rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background: white;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

    .chat-dropdown:hover {
        border-color: #adb5bd;
    }

    .chat-dropdown:focus {
        outline: none;
        border-color: #007bff;
        box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    }

    /* Dropdown options styling */
    .chat-dropdown option {
        font-size: 0.85rem;
        padding: 0.5rem;
    }

    .chat-dropdown optgroup {
        font-weight: 600;
        color: #495057;
        font-size: 0.8rem;
    }

.chat-agent-dropdown {
    flex: 1;
    min-width: 150px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-agent-info-btn {
    line-height: 1;
    border: none;
    background: none;
    padding: 0;
    margin-left: 0.25rem;
    color: var(--bs-info);
    cursor: pointer;
    flex-shrink: 0;
}

.chat-agent-info-btn:focus {
    outline: none;
    box-shadow: none;
}

.chat-agent-info-btn:hover {
    color: var(--bs-info-text-emphasis);
}

.chat-conversation-dropdown {
    min-width: 200px;
    max-width: 350px;
}

.chat-model-dropdown {
    flex: 1;
    min-width: 150px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Loading/Error States */
.chat-loading-text {
    margin-left: 0.5rem;
    font-size: 0.875rem;
    color: #6c757d;
}

.chat-error-text {
    color: #dc3545;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Metrics Styling */
.chat-metrics-display {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.chat-metric-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.chat-metric-label {
    color: #6c757d;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    text-align: right;
}

.chat-metric-value {
    font-weight: 700;
    color: #212529;
    font-size: 0.875rem;
    text-align: right;
}

    .chat-metric-value.cost {
        color: #007bff;
    }

.chat-metrics-details-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    color: #6c757d;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    border: none;
    background: transparent;
    transition: color 0.15s ease-in-out;
}

    .chat-metrics-details-btn:hover {
        color: #007bff;
        text-decoration: none;
    }

/* Context Usage with Progress Bar */
.chat-metric-item.context-usage {
    min-width: 120px;
}

.context-bar {
    position: relative;
    width: 100%;
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
}

.context-fill {
    position: absolute;
    left: 0;
    top: 0;
    width: var(--fill-percent, 0%);
    height: 100%;
    background: #28a745;
    transition: width 0.3s ease, background-color 0.3s ease;
    border-radius: 10px;
}

    .context-fill.warning {
        background: #ffc107;
    }

    .context-fill.critical {
        background: #dc3545;
    }

.context-percent {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.7rem;
    font-weight: 700;
    color: #212529;
    z-index: 1;
}

/* Responsive: Tablet and smaller */
@media (max-width: 992px) {
    .chat-header-group {
        padding: 0 0.75rem;
    }

    .chat-metrics-group {
        gap: 0.5rem;
    }

    .chat-metrics-display {
        gap: 1rem;
    }

    .chat-metric-label {
        font-size: 0.6rem;
    }

    .chat-metric-value {
        font-size: 0.8rem;
    }

    .chat-agent-dropdown,
    .chat-conversation-dropdown {
        min-width: 150px;
        max-width: 200px;
    }
}

/* Responsive: Mobile - Stack groups vertically */
@media (max-width: 768px) {
    .chat-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .chat-header-group {
        padding: 0;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        padding-bottom: 0.75rem;
    }

    .chat-header-group:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    .chat-config-group,
    .chat-history-group {
        padding-bottom: 0.5rem;
    }

    .chat-config-stack {
        width: 100%;
        min-width: 0;
    }

    .chat-selector-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
    }

    .chat-selector-label {
        min-width: 0;
    }

    .chat-agent-dropdown,
    .chat-conversation-dropdown {
        width: 100%;
        min-width: 0;
        max-width: none;
    }

    .chat-metrics-group {
        flex-direction: row;
        justify-content: space-between;
    }

    .chat-metric-item {
        align-items: flex-start;
    }

    .chat-metric-item.context-usage {
        min-width: 100px;
    }
}

/* ========== MESSAGES AREA ========== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    background: #fafafa;
}

/* Empty state */
.chat-empty {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    text-align: center;
    gap: 1rem;
}

    .chat-empty i {
        font-size: 3rem;
        color: #dee2e6;
    }

    .chat-empty p {
        margin: 0;
        font-size: 1rem;
    }

/* Messages */
.chat-message {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}

    .chat-message.user {
        align-items: flex-end;
    }

    .chat-message.agent {
        align-items: flex-start;
    }

.chat-message-bubble {
    max-width: 75%;
    padding: 0.75rem 1rem;
    padding-right: 2.75rem; /* Make room for copy button */
    border-radius: 1rem;
    position: relative;
}

.chat-message.user .chat-message-bubble {
    background: #007bff;
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.chat-message.agent .chat-message-bubble {
    background: white;
    color: #212529;
    border: 1px solid #dee2e6;
    border-bottom-left-radius: 0.25rem;
}

.chat-message-meta {
    font-size: 0.7rem;
    color: #6c757d;
    margin-top: 0.25rem;
    padding: 0 0.25rem;
}

.chat-message.user .chat-message-meta {
    text-align: right;
}

.chat-message-content {
    word-wrap: break-word;
    line-height: 1.5;
}

/* Markdown elements - compact spacing with breathing room */
.chat-message-content h1,
.chat-message-content h2,
.chat-message-content h3,
.chat-message-content h4,
.chat-message-content h5,
.chat-message-content h6 {
    margin: 1.2em 0 0.6em 0;
    font-weight: 600;
    line-height: 1.2;
}

.chat-message-content h1 { font-size: 1.3em; }
.chat-message-content h2 { font-size: 1.2em; }
.chat-message-content h3 { font-size: 1.1em; }

.chat-message-content h1:first-child,
.chat-message-content h2:first-child,
.chat-message-content h3:first-child { margin-top: 0; }

.chat-message-content p { margin: 0.1em 0; }

.chat-message-content ul,
.chat-message-content ol {
    margin: 0.15em 0;
    padding-left: 1.5em;
}

.chat-message-content li { margin: 0.05em 0; }

.chat-message-content pre {
    margin: 0.25em 0;
    padding: 0.4em;
    background: #282c34;
    border-radius: 4px;
    overflow-x: auto;
}

.chat-message-content pre code {
    background: none;
    padding: 0;
    color: #abb2bf;
    font-size: 0.85rem;
    line-height: 1.3;
}

.chat-message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.1em 0.3em;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

.chat-message.user .chat-message-content code {
    background: rgba(255, 255, 255, 0.3);
}

.chat-message.user .chat-message-content pre {
    background: rgba(0, 0, 0, 0.3);
}

.chat-message.user .chat-message-content pre code {
    color: #ffffff;
}

.chat-message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.25em 0;
    font-size: 0.9em;
}

.chat-message-content table th,
.chat-message-content table td {
    border: 1px solid #dee2e6;
    padding: 0.25em 0.4em;
    text-align: left;
}

.chat-message-content table th {
    background: rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

.chat-message.user .chat-message-content table th,
.chat-message.user .chat-message-content table td {
    border-color: rgba(255, 255, 255, 0.3);
}

.chat-message.user .chat-message-content table th {
    background: rgba(255, 255, 255, 0.2);
}

.chat-message-content blockquote {
    border-left: 3px solid #007bff;
    padding-left: 0.6em;
    margin: 0.25em 0;
    color: #6c757d;
    font-style: italic;
}

.chat-message.user .chat-message-content blockquote {
    border-left-color: rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.9);
}

.chat-message-content hr {
    border: none;
    border-top: 1px solid #dee2e6;
    margin: 0.3em 0;
}

.chat-message-content > *:first-child { margin-top: 0 !important; }
.chat-message-content > *:last-child { margin-bottom: 0 !important; }

/* Mermaid diagram styling */
.chat-message-content pre.mermaid,
.chat-message-content div.mermaid,
.chat-message-content .mermaid-rendered {
    margin: 0.5em 0;
    padding: 0.75em;
    background: white;
    border-radius: 6px;
    overflow-x: auto;
    text-align: center;
}

.chat-message.user .chat-message-content pre.mermaid,
.chat-message.user .chat-message-content div.mermaid,
.chat-message.user .chat-message-content .mermaid-rendered {
    background: rgba(255, 255, 255, 0.95);
}

.chat-message-content .mermaid-error {
    border: 2px dashed #dc3545;
    background: #f8d7da !important;
    padding: 0.5em;
    text-align: left;
}

.chat-message-content .mermaid-error-message {
    color: #721c24;
    font-size: 0.85em;
    margin-bottom: 0.5em;
    font-weight: 500;
}

/* ========== COPY TO CLIPBOARD BUTTONS ========== */

/* Copy Button Base Styling */
.chat-copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 0.25rem;
    padding: 0.375rem 0.5rem;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    color: #666;
    font-size: 0.875rem;
    z-index: 10;
    line-height: 1;
}

    .chat-copy-btn:hover {
        background: rgba(0, 0, 0, 0.1);
        color: #333;
    }

    .chat-copy-btn:active {
        transform: scale(0.95);
    }

    .chat-copy-btn i.fa-check {
        color: #28a745;
    }

/* Show copy button on hover */
.chat-message-bubble:hover .chat-copy-btn {
    opacity: 1;
}

/* Always show check icon when copied */
.chat-copy-btn i.fa-check {
    opacity: 1 !important;
}

/* User message copy button (lighter background) */
.chat-message.user .chat-copy-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

    .chat-message.user .chat-copy-btn:hover {
        background: rgba(255, 255, 255, 0.3);
    }

/* Agent message copy button */
.chat-message.agent .chat-copy-btn {
    background: rgba(0, 0, 0, 0.05);
    color: #666;
}

    .chat-message.agent .chat-copy-btn:hover {
        background: rgba(0, 0, 0, 0.1);
    }

/* Mobile: Always show copy buttons */
@media (max-width: 768px) {
    .chat-copy-btn {
        opacity: 1;
        font-size: 0.75rem;
        padding: 0.25rem 0.375rem;
    }

    .chat-message-bubble {
        padding-right: 2.5rem;
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.6; }
}

/* ==========================================================================
   AGENT WAVEFORM
   ========================================================================== */

.agent-waveform {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 0.5rem 1rem;
    height: 2rem;
}

.agent-waveform-bar {
    display: inline-block;
    width: 3px;
    height: 1rem;
    background-color: #0d6efd;
    border-radius: 2px;
    transform-origin: center;
    animation: agent-wave 1.2s ease-in-out infinite;
}

@keyframes agent-wave {
    0%, 100% { transform: scaleY(0.15); opacity: 0.5; }
    50%       { transform: scaleY(1.0);  opacity: 1.0; }
}

/* ==========================================================================
   TOOL INVOCATION CARD
   ========================================================================== */

.tool-invocation-card {
    display: flex;
    flex-direction: column;
    padding: 0.3rem 0.75rem;
    margin: 0.2rem 0;
    border-left: 3px solid #dee2e6;
    border-radius: 0 0.25rem 0.25rem 0;
    background: #f8f9fa;
    font-size: 0.8rem;
    color: #6c757d;
    cursor: pointer;
    user-select: none;
}

.tool-invocation-card:hover {
    background: #f1f3f5;
}

.tool-invocation-card.in-progress {
    border-left-color: #0d6efd;
    animation: pulse 1.5s ease-in-out infinite;
}

.tool-invocation-card.completed {
    border-left-color: #198754;
    opacity: 0.85;
}

.tool-invocation-card.failed {
    border-left-color: #dc3545;
    background: #fff5f5;
}

.tool-invocation-header {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
    overflow: hidden;
}

.tool-invocation-chevron {
    flex-shrink: 0;
    color: #adb5bd;
    font-size: 0.7rem;
}

.tool-invocation-status { flex-shrink: 0; }

.tool-invocation-name {
    font-weight: 500;
    color: #495057;
    flex-shrink: 0;
    font-family: var(--bs-font-monospace);
}

.tool-invocation-args-preview {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    color: #868e96;
    font-family: var(--bs-font-monospace);
    font-size: 0.75rem;
}

.tool-invocation-timing {
    flex-shrink: 0;
    color: #adb5bd;
    margin-left: auto;
    padding-left: 0.5rem;
}

.tool-invocation-section {
    margin-top: 0.4rem;
    border-top: 1px solid #e9ecef;
    padding-top: 0.3rem;
}

.tool-invocation-section-header {
    font-weight: 600;
    color: #868e96;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.2rem;
}

.tool-invocation-json {
    font-family: var(--bs-font-monospace);
    font-size: 0.75rem;
    color: #495057;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}

@keyframes tool-icon-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.tool-icon-spinning {
    display: inline-block;
    animation: tool-icon-spin 1.5s linear infinite;
}

/* Agent reasoning display */
.chat-reasoning {
    padding: 0.875rem 1rem;
    padding-right: 2.5rem; /* Make room for copy button */
    margin-bottom: 0.875rem;
    border-radius: 0.5rem;
    background: linear-gradient(135deg, #f8f4ff 0%, #f0ebff 100%);
    border-left: 4px solid #8b5cf6;
    position: relative;
    box-shadow: 0 1px 3px rgba(139, 92, 246, 0.1);
}

    .chat-reasoning .reasoning-header {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin-bottom: 0.625rem;
        font-size: 0.8125rem;
        font-weight: 600;
        color: #7c3aed;
    }

        .chat-reasoning .reasoning-header i {
            font-size: 0.9375rem;
        }

        .chat-reasoning .reasoning-header .reasoning-time {
            margin-left: auto;
            font-weight: 400;
            color: #9ca3af;
            font-size: 0.75rem;
        }

    .chat-reasoning .reasoning-content {
        font-size: 0.875rem;
        line-height: 1.5;
        color: #4b5563;
        font-style: italic;
    }

        /* Markdown content in reasoning */
        .chat-reasoning .reasoning-content p {
            margin-bottom: 0.5rem;
        }

            .chat-reasoning .reasoning-content p:last-child {
                margin-bottom: 0;
            }

        .chat-reasoning .reasoning-content code {
            background: rgba(139, 92, 246, 0.1);
            padding: 0.125rem 0.375rem;
            border-radius: 0.25rem;
            font-size: 0.8125rem;
        }

    /* Reasoning copy button */
    .chat-reasoning .chat-copy-btn {
        top: 0.875rem;
        background: rgba(139, 92, 246, 0.1);
        padding: 0.25rem 0.375rem;
        font-size: 0.75rem;
        color: #7c3aed;
    }

        .chat-reasoning .chat-copy-btn:hover {
            background: rgba(139, 92, 246, 0.2);
        }

/* Show reasoning copy button on hover */
.chat-reasoning:hover .chat-copy-btn {
    opacity: 1;
}



/* Mobile: Wider message bubbles */
@media (max-width: 767px) {
    .chat-message-bubble {
        max-width: 85%;
        padding: 0.625rem 0.875rem;
        padding-right: 2.5rem;
    }

    .chat-messages {
        padding: 0.75rem;
    }
}

/* ========== INPUT AREA ========== */
.chat-input {
    padding: 1rem;
    border-top: 1px solid #dee2e6;
    background: white;
}

.chat-input-error {
    margin-bottom: 0.5rem;
    padding: 0.5rem;
}

/* Agent heartbeat indicator for long-running operations */
.agent-heartbeat {
    margin-bottom: 0.75rem;
    padding: 0.625rem 0.875rem;
    background: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #004085;
}

    .agent-heartbeat i {
        color: #007bff;
        font-size: 1rem;
    }

    .agent-heartbeat span {
        flex: 1;
    }

.chat-input-controls {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.chat-input-field {
    flex: 1;
    min-height: 42px;
    max-height: 200px;
    resize: none;
    padding: 0.625rem 0.875rem;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.5;
}

    .chat-input-field:focus {
        outline: none;
        border-color: #007bff;
        box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    }

.chat-input-button {
    flex-shrink: 0;
    min-width: 90px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    border: none;
    border-radius: 0.375rem;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

    .chat-input-button.send {
        background: #007bff;
        color: white;
    }

        .chat-input-button.send:hover:not(:disabled) {
            background: #0056b3;
        }

    .chat-input-button.stop {
        background: #dc3545;
        color: white;
    }

        .chat-input-button.stop:hover {
            background: #c82333;
        }

    .chat-input-button:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

/* Mobile: Adjust input area */
@media (max-width: 767px) {
    .chat-input {
        padding: 0.75rem;
    }

    .chat-input-field {
        font-size: 16px; /* Prevent iOS zoom */
    }

    .chat-input-button {
        min-width: 70px;
        font-size: 0.8rem;
    }
}

/* ========== SCROLLBAR STYLING ========== */
.chat-messages::-webkit-scrollbar,
.chat-agent-list::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track,
.chat-agent-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb,
.chat-agent-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

    .chat-messages::-webkit-scrollbar-thumb:hover,
    .chat-agent-list::-webkit-scrollbar-thumb:hover {
        background: #555;
    }

/* ==========================================================================
   UTILITIES
   ========================================================================== */

/* Text Utilities */
.text-muted-light {
    color: #adb5bd !important;
}

.text-uppercase-spaced {
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Spacing Utilities */
.gap-sm {
    gap: 0.5rem;
}

.gap-md {
    gap: 1rem;
}

.gap-lg {
    gap: 1.5rem;
}

/* Border Utilities */
.border-light-gray {
    border: 1px solid #dee2e6;
}

/* Shadow Utilities */
.shadow-sm-hover:hover {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.shadow-hover:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   CONVERSATIONS
   ========================================================================== */

/* Conversation Messages Container */
.conversation-messages {
    max-height: 70vh;
    overflow-y: auto;
    padding: 1rem;
}

/* Individual Message Item */
.message-item {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
    border-left: 4px solid transparent;
}

    /* User Message */
    .message-item.user {
        background-color: #e3f2fd;
        border-left-color: #2196f3;
    }

    /* Assistant Message */
    .message-item.assistant {
        background-color: #f3e5f5;
        border-left-color: #9c27b0;
    }

    /* System/Other Message */
    .message-item:not(.user):not(.assistant) {
        background-color: #f5f5f5;
        border-left-color: #9e9e9e;
    }

/* Message Header */
.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.message-role {
    font-size: 0.875rem;
    color: #495057;
}

.message-timestamp {
    font-size: 0.75rem;
}

/* Message Content */
.message-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.5;
    color: #212529;
}

/* Conversation Card */
.conversation-card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

    .conversation-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

/* Hover Lift Effect - Cards that lift on hover */
.hover-lift {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

    .hover-lift:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15) !important;
    }

/* ==========================================================================
   CONVERSATION METRICS PANEL
   ========================================================================== */

/* Metrics Panel - Real-time conversation metrics display */
.metrics-panel {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.metrics-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    align-items: center;
}

.metric-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.metric-label {
    font-size: 0.875rem;
    color: #6c757d;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.metric-value {
    font-size: 0.875rem;
    font-weight: 500;
    color: #212529;
}

    .metric-value.cost {
        color: #007bff;
        font-size: 1.125rem;
        font-weight: 600;
    }

/* Progress Bar Container */
.progress-bar-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.progress-bar-custom {
    flex: 1;
    height: 10px;
    background: #e9ecef;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    transition: width 0.5s ease, background-color 0.3s ease;
    border-radius: 5px;
}

    /* Usage Color Classes */
    .progress-fill.usage-low {
        background: linear-gradient(90deg, #28a745, #34ce57);
    }

    .progress-fill.usage-medium {
        background: linear-gradient(90deg, #ffc107, #ffcd38);
    }

    .progress-fill.usage-high {
        background: linear-gradient(90deg, #fd7e14, #ff922b);
    }

    .progress-fill.usage-critical {
        background: linear-gradient(90deg, #dc3545, #e4606d);
        animation: pulse-critical 2s ease-in-out infinite;
    }

@keyframes pulse-critical {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* Alert Adjustments for Metrics Panel */
.metrics-panel .alert {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
}

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================== */

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .action-toolbar {
        width: 100%;
    }

        .action-toolbar .btn {
            flex: 1;
        }

    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .metric-value.cost {
        font-size: 1rem;
    }
}

/* ==========================================================================
   FILE TREE - Shared Component
   ========================================================================== */

/* File Tree Container */
.file-tree {
    padding: 0.5rem;
}

/* Tree Item */
.tree-item {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.25rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s;
}

    .tree-item.compact {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }

    .tree-item[draggable="true"]:active {
        cursor: grabbing;
        opacity: 0.7;
    }

    .tree-item:hover {
        background: rgba(0, 0, 0, 0.05);
    }

    .tree-item.selected {
        background: var(--bs-primary);
        color: white;
    }

        .tree-item.selected i {
            color: white !important;
        }

/* Tree Item Content */
.tree-item-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tree-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-item-size {
    font-size: 0.75rem;
    color: #6c757d;
}

.tree-item.selected .tree-item-size {
    color: rgba(255, 255, 255, 0.8);
}

.tree-item-modified {
    font-size: 0.7rem;
    color: #6c757d;
}

.tree-item.selected .tree-item-modified {
    color: rgba(255, 255, 255, 0.8);
}

/* Tree States */
.tree-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    color: #6c757d;
}

.empty-state-small {
    padding: 2rem;
    text-align: center;
    color: #6c757d;
}

    .empty-state-small p {
        margin: 0;
        font-size: 0.875rem;
    }

/* ==========================================================================
   MCP FILE BROWSER - Full Screen
   ========================================================================== */

/* Full Screen Container */
.page-fullscreen {
    height: calc(100vh - 70px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* File Browser Container */
.filebrowser-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
}

/* File Browser Header */
.filebrowser-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
    flex-shrink: 0;
}

    .filebrowser-header .header-left {
        display: flex;
        align-items: center;
        gap: 2rem;
    }

    .filebrowser-header h4 {
        margin: 0;
        font-size: 1.25rem;
        font-weight: 600;
        min-width: 180px;
    }

    .filebrowser-header .capabilities-badges {
        display: flex;
        gap: 0.25rem;
    }

    .filebrowser-header .header-actions {
        display: flex;
        gap: 0.5rem;
    }

/* File Browser Content */
.filebrowser-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Split View Layout */
.filebrowser-split {
    display: grid;
    grid-template-columns: 30% 70%;
    flex: 1;
    overflow: hidden;
}

/* Tree Panel (Left) */
.filebrowser-tree {
    border-right: 1px solid #dee2e6;
    overflow-y: auto;
    background: #fafafa;
}

.tree-header {
    padding: 0.75rem 1rem;
    background: white;
    border-bottom: 1px solid #dee2e6;
    position: sticky;
    top: 0;
    z-index: 1;
}

.breadcrumb-path {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #495057;
}

.breadcrumb-items {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.breadcrumb-link {
    color: #007bff;
    text-decoration: none;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    transition: background-color 0.15s ease;
}

    .breadcrumb-link:hover {
        background-color: rgba(0, 123, 255, 0.1);
        text-decoration: none;
    }

.breadcrumb-separator {
    color: #6c757d;
    margin: 0 0.25rem;
}

.breadcrumb-current {
    color: #212529;
    font-weight: 600;
}

/* Up button styling */
.tree-header .btn-outline-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

    .tree-header .btn-outline-secondary:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .tree-header .btn-outline-secondary i {
        font-size: 1rem;
    }

/* Details Panel (Right) */
.filebrowser-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    background: white;
    flex-shrink: 0;
}

    .details-header h5 {
        margin: 0;
        font-size: 1.125rem;
        font-weight: 600;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

.details-meta {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #6c757d;
}

    .details-meta span {
        display: flex;
        align-items: center;
        gap: 0.25rem;
    }

.details-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* File Viewer */
.file-viewer {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    overflow: hidden;
}

.code-viewer {
    margin: 0;
    padding: 1rem;
    background: #282c34;
    color: #abb2bf;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    overflow-x: auto;
    max-height: calc(100vh - 300px);
}

/* File Editor */
.file-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.editor-toolbar {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.editor-textarea {
    flex: 1;
    width: 100%;
    padding: 1rem;
    border: none;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    resize: none;
    background: #282c34;
    color: #abb2bf;
}

    .editor-textarea:focus {
        outline: none;
    }

/* Modal Backdrop */
.modal-backdrop-custom {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1040;
}

/* Responsive */
@media (max-width: 992px) {
    .filebrowser-split {
        grid-template-columns: 1fr;
        grid-template-rows: 40% 60%;
    }

    .filebrowser-tree {
        border-right: none;
        border-bottom: 1px solid #dee2e6;
    }

    /* Mobile breadcrumb adjustments */
    .breadcrumb-path {
        flex-wrap: wrap;
    }

    .breadcrumb-items {
        font-size: 0.75rem;
    }

    .tree-header .btn-outline-secondary {
        padding: 0.25rem 0.375rem;
    }
}

/* ==========================================================================
   CHAT FILE BROWSER SIDEBAR
   ========================================================================== */

/* Chat page with sidebar */
.chat-page {
    position: relative;
}

.chat-conversation.with-sidebar {
    margin-right: 280px;
}

/* Sidebar Container */
.chat-sidebar,
.agentic-chat-sidebar {
    position: fixed;
    top: 70px; /* Below navbar */
    right: 0;
    width: 280px;
    height: calc(100vh - 70px);
    background: white;
    border-left: 1px solid #dee2e6;
    transition: transform 0.3s ease;
    z-index: 100;
}

    .chat-sidebar.collapsed,
    .agentic-chat-sidebar.collapsed {
        transform: translateX(280px);
    }

/* Sidebar Toggle Button */
.sidebar-toggle-btn {
    position: fixed;
    top: 50%;
    right: 280px;
    transform: translateY(-50%);
    width: 32px;
    height: 64px;
    background: white;
    border: 1px solid #dee2e6;
    border-right: none;
    border-radius: 8px 0 0 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: right 0.3s ease;
    z-index: 101;
    box-shadow: -2px 0 4px rgba(0, 0, 0, 0.1);
}

    .sidebar-toggle-btn.collapsed {
        right: 0;
        border-right: 1px solid #dee2e6;
        border-left: none;
        border-radius: 0 8px 8px 0;
        box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
    }

    .sidebar-toggle-btn:hover {
        background: #f8f9fa;
    }

    .sidebar-toggle-btn i {
        font-size: 1.25rem;
        color: #6c757d;
    }

/* Sidebar Content */
.chat-filebrowser-sidebar {
    display: flex;
    flex-direction: column;
    height: 100%;
}

    .chat-filebrowser-sidebar .sidebar-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1rem;
        border-bottom: 1px solid #dee2e6;
        background: #f8f9fa;
    }

        .chat-filebrowser-sidebar .sidebar-header h6 {
            margin: 0;
            font-size: 1rem;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

    .chat-filebrowser-sidebar .sidebar-nav {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid #dee2e6;
        background: white;
    }

        .chat-filebrowser-sidebar .sidebar-nav .btn {
            padding: 0.25rem 0.5rem;
            font-size: 0.875rem;
        }

    .chat-filebrowser-sidebar .current-path {
        flex: 1;
        font-size: 0.875rem;
        color: #6c757d;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .chat-filebrowser-sidebar .sidebar-tree {
        flex: 1;
        overflow-y: auto;
        padding: 0.5rem;
    }

    .chat-filebrowser-sidebar .sidebar-footer {
        padding: 0.75rem 1rem;
        border-top: 1px solid #dee2e6;
        background: #f8f9fa;
        text-align: center;
    }

        .chat-filebrowser-sidebar .sidebar-footer small {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 0.25rem;
        }

/* Responsive */
@media (max-width: 992px) {
    /* Remove margin adjustment on smaller screens */
    .chat-page.with-sidebar {
        margin-right: -24px;
    }

    .chat-conversation.with-sidebar {
        margin-right: 0;
    }

    /* Sidebar moves to bottom on mobile/tablet */
    .chat-sidebar,
    .agentic-chat-sidebar {
        width: 100%;
        top: auto;
        bottom: 0;
        height: 50vh;
        border-left: none;
        border-top: 1px solid #dee2e6;
    }

        .chat-sidebar.collapsed,
        .agentic-chat-sidebar.collapsed {
            transform: translateY(50vh);
        }

    .sidebar-toggle-btn {
        right: 50%;
        top: auto;
        bottom: calc(50vh - 16px);
        transform: translateX(50%);
        width: 64px;
        height: 32px;
        border-radius: 8px 8px 0 0;
        border-bottom: none;
    }

        .sidebar-toggle-btn.collapsed {
            bottom: 0;
            border-bottom: 1px solid #dee2e6;
            border-top: none;
            border-radius: 0 0 8px 8px;
        }

        .sidebar-toggle-btn i {
            transform: rotate(90deg);
        }
}

/* ========================================================================== */
/* REUSABLE AGENTIC CHAT COMPONENTS                                          */
/* ========================================================================== */

/* Base container for reusable chat (inherits from .chat-page for full mode) */
.agentic-chat-header {
    /* Mirrors .chat-header but more generic */
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #dee2e6;
    background: white;
    flex-shrink: 0;
    gap: 0.75rem;
}

.agentic-chat-messages {
    /* Mirrors .chat-messages */
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    background: #fafafa;
}

.agentic-chat-input {
    /* Mirrors .chat-input */
    padding: 1rem;
    border-top: 1px solid #dee2e6;
    background: white;
    flex-shrink: 0;
}

.agentic-chat-sidebar {
    /* Mirrors .chat-sidebar */
    position: fixed;
    top: 70px;
    right: 0;
    width: 280px;
    height: calc(100vh - 70px);
    background: white;
    border-left: 1px solid #dee2e6;
    transition: transform 0.3s ease;
    z-index: 100;
}

    .agentic-chat-sidebar.collapsed {
        transform: translateX(280px);
    }

/* ========================================================================== */
/* REFINEMENT CHAT - Compact variant for wizard                             */
/* ========================================================================== */

.refinement-chat-container {
    margin-bottom: 1.5rem;
}

    .refinement-chat-container h5 {
        font-size: 1.125rem;
        font-weight: 600;
        margin-bottom: 0.5rem;
    }

/* Compact chat layout for wizard embedding */
.refinement-chat {
    display: flex;
    flex-direction: column;
    height: 450px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

/* Compact messages area */
.refinement-chat .agentic-chat-messages,
.refinement-messages {
    padding: 12px;
    font-size: 0.875rem;
}

    /* Reduce message bubble sizes */
    .refinement-chat .chat-message-bubble,
    .refinement-messages .chat-message-bubble {
        padding: 0.625rem 0.875rem;
        padding-right: 2.5rem;
        font-size: 0.875rem;
        max-width: 85%;
    }

    /* Smaller message meta */
    .refinement-chat .chat-message-meta,
    .refinement-messages .chat-message-meta {
        font-size: 0.65rem;
        margin-top: 0.2rem;
    }

    /* Compact tool invocation styling */
    .refinement-chat .tool-invocation-card,
    .refinement-messages .tool-invocation-card {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }

/* Compact input area */
.refinement-chat .agentic-chat-input {
    padding: 0.75rem;
}

    .refinement-chat .chat-input-field {
        font-size: 0.875rem;
        padding: 0.625rem 0.875rem;
    }

    .refinement-chat .chat-input-button {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

/* Refinement result card */
.refinement-result {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid #d1ecf1;
    border-radius: 8px;
    background: #f0f9ff;
}

    .refinement-result .alert {
        margin-bottom: 0.75rem;
    }

    .refinement-result .btn {
        margin-right: 0.5rem;
    }

/* Compact mode - Generic modifier for any embedded chat */
.agentic-chat.compact {
    height: 400px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
}

    .agentic-chat.compact .agentic-chat-messages {
        padding: 12px;
    }

    .agentic-chat.compact .agentic-chat-input {
        padding: 0.75rem;
    }

    .agentic-chat.compact .chat-message-content {
        font-size: 13px;
    }

/* No header mode */
.agentic-chat.no-header .agentic-chat-header {
    display: none;
}

/* Responsive for refinement chat */
@media (max-width: 768px) {
    .refinement-chat {
        height: 350px;
    }

    .refinement-chat .chat-message-bubble,
    .refinement-messages .chat-message-bubble {
        max-width: 90%;
    }
}

/* ==========================================================================
   CHAT ATTACHMENTS
   ========================================================================== */

/* Drop Overlay - Shown during drag */
.drop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 123, 255, 0.1);
    border: 3px dashed #007bff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    pointer-events: none;
}

.drop-overlay-content {
    text-align: center;
    color: #007bff;
    pointer-events: none;
}

    .drop-overlay-content i {
        margin-bottom: 1rem;
    }

    .drop-overlay-content p {
        font-size: 1.25rem;
        font-weight: 600;
        margin: 0;
    }

/* Paperclip Button */
.chat-input-button.paperclip {
    background: transparent;
    color: #6c757d;
    border: 1px solid #ced4da;
    min-width: 42px;
    width: 42px;
    padding: 0;
}

    .chat-input-button.paperclip:hover:not(:disabled) {
        background: #f8f9fa;
        color: #495057;
        border-color: #adb5bd;
    }

    .chat-input-button.paperclip i {
        font-size: 1rem;
    }

/* Attachment Preview Area */
.attachment-preview-area {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    margin-bottom: 0.75rem;
    overflow-x: auto;
    flex-wrap: wrap;
}

/* Individual Attachment Preview */
.attachment-preview-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    min-width: 200px;
    max-width: 300px;
    position: relative;
}

/* Image Preview */
.attachment-preview-image {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 0.25rem;
    flex-shrink: 0;
}

/* File Icon */
.attachment-preview-file {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 0.25rem;
    flex-shrink: 0;
}

    .attachment-preview-file i {
        font-size: 1.5rem;
        color: #6c757d;
    }

/* Attachment Info */
.attachment-preview-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.attachment-preview-name {
    font-size: 0.875rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-preview-size {
    font-size: 0.75rem;
    color: #6c757d;
}

/* Remove Button */
.attachment-preview-remove {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(220, 53, 69, 0.1);
    border: none;
    border-radius: 50%;
    color: #dc3545;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, background-color 0.2s ease;
}

.attachment-preview-item:hover .attachment-preview-remove {
    opacity: 1;
}

.attachment-preview-remove:hover {
    background: rgba(220, 53, 69, 0.2);
}

.attachment-preview-remove i {
    font-size: 0.75rem;
}

/* Message Attachments */
.message-attachment {
    margin-top: 0.5rem;
    display: inline-block;
}

/* Image Attachment in Message */
.message-attachment.image-attachment {
    max-width: 100%;
}

.attachment-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: 0.5rem;
    display: block;
    margin-bottom: 0.25rem;
}

.attachment-info {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

.chat-message.user .attachment-info {
    color: rgba(255, 255, 255, 0.8);
}

/* File Attachment in Message */
.message-attachment.file-attachment {
    display: inline-block;
    margin-top: 0.5rem;
}

.attachment-file-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0.375rem;
    color: inherit;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

    .attachment-file-link:hover {
        background: rgba(0, 0, 0, 0.1);
        text-decoration: none;
        color: inherit;
    }

    .attachment-file-link i {
        font-size: 1.125rem;
        color: #6c757d;
    }

.chat-message.user .attachment-file-link {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

    .chat-message.user .attachment-file-link:hover {
        background: rgba(255, 255, 255, 0.3);
    }

    .chat-message.user .attachment-file-link i {
        color: white;
    }

.attachment-size {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Uploading State */
.chat-input.uploading .chat-input-controls {
    pointer-events: none;
    opacity: 0.6;
}

.attachment-uploading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 0.375rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: #004085;
}

    .attachment-uploading i {
        color: #007bff;
    }

/* Mobile Adjustments */
@media (max-width: 768px) {
    .attachment-preview-area {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .attachment-preview-item {
        min-width: 150px;
        max-width: 250px;
    }

    .attachment-image {
        max-height: 300px;
    }

    .attachment-preview-remove {
        opacity: 1;
    }
}

/* === Chat-style attachment alignment/ellipsis trick (append at end) === */

/* Let attachments size/align like the rest of the bubble content */
.chat-message-content .message-attachment {
    display: block; /* overrides your inline-block */
    width: 100%;
    max-width: 100%;
}

    /* File attachment becomes a single "row" that fills bubble width */
    .chat-message-content .message-attachment.file-attachment.attachment-clickable {
        display: inline-flex; /* keeps it looking like a pill */
        width: 100%; /* but spans bubble width */
        max-width: 100%;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        box-sizing: border-box;
    }

    /* Left side can shrink so name ellipsizes */
    .chat-message-content .message-attachment.file-attachment .attachment-info {
        min-width: 0; /* critical for ellipsis in flex */
        flex: 1 1 auto;
    }

    /* Make sure the name truncates cleanly */
    .chat-message-content .message-attachment.file-attachment .attachment-name {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Keep the download icon from shrinking/collapsing */
    .chat-message-content .message-attachment.file-attachment .attachment-download-btn {
        flex: 0 0 auto;
    }

    /* Optional: make the whole row "feel" clickable without changing your colors */
    .chat-message-content .message-attachment.file-attachment.attachment-clickable:active {
        transform: translateY(0.5px);
    }
/* Option A support: container is .attachment-file-link, but must behave like a pill-row */
.message-attachment.file-attachment.attachment-file-link {
    width: 100%;
    justify-content: space-between;
    gap: .5rem;
}

.message-attachment.file-attachment.attachment-file-link {
    width: 100%;
    justify-content: space-between;
    gap: .5rem;
}

/* Download button */
.message-attachment.file-attachment .attachment-download-btn {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background: transparent;
    padding: .25rem .4rem;
    line-height: 1;
    border-radius: .35rem;
    cursor: pointer;
    color: inherit;
    opacity: .75;
}

    .message-attachment.file-attachment .attachment-download-btn:hover {
        opacity: 1;
        background: rgba(0,0,0,.08);
    }
/* User bubble variant */
.chat-message.user .message-attachment.file-attachment .attachment-download-btn:hover {
    background: rgba(255,255,255,.18);
}

/* ==========================================================================
   MODEL CAPABILITY ICONS
   ========================================================================== */

/* Model capability icons */
.model-capabilities {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.capability-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    font-size: 0.75rem;
    color: var(--bs-secondary);
    background: var(--bs-light);
    border-radius: 3px;
    transition: all 0.2s;
}

.capability-icon:hover {
    color: var(--bs-primary);
    background: var(--bs-primary-bg-subtle);
    transform: scale(1.1);
}

/* ==========================================================================
   MODEL TESTING DIALOG
   ========================================================================== */

/* Modal Dialog - Large size for test results */
.modal-dialog-large {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    z-index: 1050;
}

/* Modal Header */
.modal-dialog-large .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
}

    .modal-dialog-large .modal-header h4 {
        margin: 0;
        font-size: 1.25rem;
        font-weight: 600;
    }

    .modal-dialog-large .modal-header .btn-close {
        padding: 0.5rem;
        margin: 0;
    }

/* Modal Body */
.modal-dialog-large .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* Modal Footer */
.modal-dialog-large .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #dee2e6;
    flex-shrink: 0;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
}

    .loading-state .spinner-border {
        width: 3rem;
        height: 3rem;
        margin-bottom: 1rem;
    }

    .loading-state p {
        margin: 0;
        font-size: 1.125rem;
        font-weight: 500;
        color: #495057;
    }

    .loading-state small {
        display: block;
        margin-top: 0.5rem;
    }

/* Capability Tests */
.capability-tests {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.capability-test-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 0.375rem;
}

.capability-badge {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

/* Comparison Table */
.comparison-table {
    font-size: 0.9rem;
}

    .comparison-table td,
    .comparison-table th {
        padding: 0.875rem;
        vertical-align: middle;
    }

    .comparison-table thead {
        background: #f8f9fa;
        border-bottom: 2px solid #dee2e6;
    }

    .comparison-table thead th {
        font-weight: 600;
        color: #495057;
        text-transform: uppercase;
        font-size: 0.75rem;
        letter-spacing: 0.5px;
    }

/* Row Color States */
.table-success td {
    background-color: rgba(25, 135, 84, 0.08) !important;
}

.table-warning td {
    background-color: rgba(255, 193, 7, 0.12) !important;
}

.table-danger td {
    background-color: rgba(220, 53, 69, 0.08) !important;
}

/* Status Badges */
.comparison-table .badge {
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* Backdrop */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1040;
}

/* Responsive */
@media (max-width: 768px) {
    .modal-dialog-large {
        width: 95%;
        max-height: 95vh;
    }

    .modal-dialog-large .modal-header,
    .modal-dialog-large .modal-body,
    .modal-dialog-large .modal-footer {
        padding: 1rem;
    }

    .comparison-table {
        font-size: 0.8rem;
    }

        .comparison-table td,
        .comparison-table th {
            padding: 0.625rem 0.5rem;
        }

    .capability-test-item {
        flex-direction: column;
        align-items: flex-start;
    }
}


/* ==========================================================================
   RAG (Retrieval-Augmented Generation) COMPONENTS
   ========================================================================== */

/* RAG Search Result Cards */
.search-result-card {
    border: 1px solid #e0e0e0;
    border-radius: 0.5rem;
    padding: 1rem;
    background: white;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

    .search-result-card:hover {
        transform: translateX(4px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

.search-result-card .result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.search-result-card .result-file {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-result-card .result-content {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #555;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 0.25rem;
    max-height: 150px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.search-result-card .result-meta {
    font-size: 0.8rem;
    color: #6c757d;
}

    .search-result-card .result-meta i {
        margin-right: 0.25rem;
    }

/* RAG Model Info */
.model-info {
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 0.25rem;
}

/* RAG Progress Indicators */
.rag-progress-container {
    margin: 1rem 0;
}

.rag-progress-bar {
    height: 24px;
    font-size: 0.875rem;
    line-height: 24px;
}

/* Empty state for no results */
.rag-no-results {
    text-align: center;
    padding: 3rem;
    color: #6c757d;
}

    .rag-no-results i {
        font-size: 3rem;
        margin-bottom: 1rem;
        opacity: 0.5;
    }

    .rag-no-results p {
        margin: 0;
        font-size: 1.1rem;
    }

/* Collection badges */
.collection-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Score badges with color coding */
.score-badge {
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.9rem;
}


/* ==========================================================================
   DIRECTORY BROWSER - Modal for folder selection in RAG
   ========================================================================== */

/* Directory Browser List Container */
.directory-browser-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background: white;
}

/* Individual Directory Item */
.directory-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

    .directory-item:last-child {
        border-bottom: none;
    }

    .directory-item:hover {
        background-color: #f8f9fa;
    }

    .directory-item:active {
        background-color: #e9ecef;
    }

    .directory-item i {
        font-size: 1.25rem;
        flex-shrink: 0;
    }

    .directory-item span {
        flex: 1;
        font-size: 0.9rem;
        font-weight: 500;
        color: #495057;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

/* Empty directory state */
.directory-browser-list .alert {
    margin: 1rem;
}

/* Info Page Styles */
.section-title {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e9ecef;
    font-weight: 600;
}

.info-card {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    height: 100%;
}

.info-card-header {
    background-color: #f8f9fa;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #dee2e6;
    border-radius: 0.375rem 0.375rem 0 0;
    font-weight: 600;
}

.info-card-body {
    padding: 1rem;
}

.info-value {
    font-size: 1.1rem;
    font-weight: 500;
    color: #212529;
}

.card-header-light {
    background-color: #f8f9fa;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem 0.375rem 0 0;
}

.border-token-success {
    border-color: #198754 !important;
}

.border-token-warning {
    border-color: #ffc107 !important;
}

.border-token-danger {
    border-color: #dc3545 !important;
}

.border-token-info {
    border-color: #0dcaf0 !important;
}

.font-monospace {
    font-family: 'Courier New', Courier, monospace;
}


/* Chat Reduction Zone Bar */
.zone-bar {
    display: flex;
    height: 16px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--bs-gray-200);
}

.zone-segment { height: 100%; transition: width 0.3s ease; }
.zone-context      { background: var(--bs-info); }
.zone-summary      { background: var(--bs-secondary); }
.zone-conversation { background: var(--bs-warning); }
