/**
 * AI Chat and Sidebar Styles
 */

/* Sidebar Container */
.ai-sidebar {
    position: fixed;
    right: 0;
    top: 50px;
    bottom: 0;
    width: 420px;
    background: #fff;
    box-shadow: -2px 0 15px rgba(0, 0, 0, 0.15);
    z-index: 1050;
    transition: transform 0.3s ease-in-out, width 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
}

.ai-sidebar.collapsed {
    transform: translateX(100%);
}

.ai-sidebar.expanded {
    width: 850px;
}

@media (min-width: 1600px) {
    .ai-sidebar.expanded {
        width: 1000px;
    }
}

@media (min-width: 1900px) {
    .ai-sidebar.expanded {
        width: 1200px;
    }
}

/* Toggle Button */
.ai-sidebar-toggle {
    position: absolute;
    left: -45px;
    top: 50%;
    transform: translateY(-50%);
    width: 45px;
    height: 45px;
    background: #337ab7;
    color: #fff;
    border-radius: 8px 0 0 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.2);
    transition: background-color 0.2s;
}

.ai-sidebar-toggle:hover {
    background: #286090;
}

.ai-sidebar.collapsed .ai-sidebar-toggle {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.2);
    }
    50% {
        box-shadow: -2px 2px 15px rgba(51, 122, 183, 0.5);
    }
}

/* Sidebar Content */
.ai-sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Header */
.ai-sidebar-header {
    padding: 12px 15px;
    background: #f8f8f8;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

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

.ai-sidebar-header h4 i {
    margin-right: 8px;
    color: #337ab7;
}

.ai-header-actions {
    display: flex;
    gap: 5px;
}

/* Quick Actions */
.ai-quick-actions {
    padding: 12px 15px;
    background: #fafafa;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.ai-quick-actions h5 {
    margin: 0 0 10px 0;
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai-quick-actions .ai-action {
    display: block;
    width: 100%;
    margin-bottom: 6px;
    text-align: left;
    padding: 8px 12px;
    font-size: 13px;
}

.ai-quick-actions .ai-action:last-child {
    margin-bottom: 0;
}

.ai-quick-actions .ai-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-quick-actions .ai-action i {
    margin-right: 8px;
    color: #666;
}

.ai-quick-actions .ai-action:not(:disabled):hover i {
    color: #337ab7;
}

/* Context Info */
.ai-context-info {
    padding: 8px 15px;
    background: #fff9e6;
    border-bottom: 1px solid #f0e6cc;
    flex-shrink: 0;
}

.ai-context-info small {
    font-size: 12px;
}

.ai-context-info i {
    margin-right: 5px;
}

/* Chat Area */
.ai-sidebar-chat {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ai-chat-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Messages Container */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f5f5f5;
}

/* Welcome Message */
.ai-welcome-message {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

.ai-welcome-message ul {
    margin: 10px 0;
    padding-left: 20px;
}

.ai-welcome-message li {
    margin-bottom: 5px;
    color: #555;
}

.ai-welcome-message .ai-examples {
    margin-bottom: 0;
    color: #888;
    font-size: 12px;
    font-style: italic;
}

/* Message Bubbles */
.ai-message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.ai-message-user {
    align-items: flex-end;
}

.ai-message-assistant {
    align-items: flex-start;
}

.ai-message-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
    font-size: 14px;
    word-wrap: break-word;
}

/* Wider messages for standalone page */
.ai-main-chat .ai-message-content {
    max-width: 95%;
}

.ai-message-user .ai-message-content {
    background: #337ab7;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-message-assistant .ai-message-content {
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ai-message-error .ai-message-content {
    background: #f8d7da;
    color: #721c24;
}

.ai-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 8px;
    padding: 0 4px;
    text-align: right;
}

/* Table wrapper for horizontal scrolling */
.ai-table-wrapper {
    overflow-x: auto;
    margin: 12px 0;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

/* Tables in Messages */
.ai-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    white-space: nowrap;
}

.ai-table th,
.ai-table td {
    padding: 10px 14px;
    border: 1px solid #e0e0e0;
    text-align: left;
}

.ai-table th {
    background: #f5f5f5;
    font-weight: 600;
    color: #333;
}

.ai-table td {
    background: #fff;
}

.ai-table tr:nth-child(even) td {
    background: #fafafa;
}

.ai-table tr:hover td {
    background: #f0f7ff;
}

/* Cell content with lists */
.ai-cell-list {
    margin: 0;
    padding-left: 16px;
    list-style-type: disc;
}

.ai-cell-list li {
    margin: 2px 0;
    white-space: normal;
}

.ai-table td .ai-cell-list {
    font-size: 12px;
}

/* Headings in Messages */
.ai-heading {
    margin: 16px 0 8px 0;
    color: #333;
    font-weight: 600;
}

h2.ai-heading {
    font-size: 18px;
    border-bottom: 2px solid #337ab7;
    padding-bottom: 6px;
}

h3.ai-heading {
    font-size: 16px;
}

h4.ai-heading {
    font-size: 14px;
    color: #555;
}

h5.ai-heading {
    font-size: 13px;
    color: #555;
}

/* Bullet points */
.ai-bullet {
    margin: 4px 0;
    padding-left: 8px;
}

.ai-numbered {
    margin: 4px 0;
}

/* Paragraphs in messages */
.ai-message-content p {
    margin: 8px 0;
}

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

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

.ai-message-content hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 12px 0;
}

/* Code in Messages */
.ai-message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
}

.ai-message-content pre {
    background: #f4f4f4;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 10px 0;
}

.ai-message-content pre code {
    background: none;
    padding: 0;
}

/* Links in Messages */
.ai-message-content a {
    color: #337ab7;
    text-decoration: none;
    border-bottom: 1px dotted #337ab7;
    transition: all 0.2s ease;
}

.ai-message-content a:hover {
    color: #23527c;
    border-bottom-color: #23527c;
    border-bottom-style: solid;
}

.ai-message-content a::after {
    content: ' ↗';
    font-size: 10px;
    vertical-align: super;
    opacity: 0.6;
}

/* Links in tables should be more subtle */
.ai-message-content table a::after {
    content: '';
}

/* Typing Indicator */
.ai-typing-indicator {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #fff;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    width: fit-content;
    margin-bottom: 15px;
}

.ai-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    margin: 0 2px;
    animation: typing 1.4s infinite ease-in-out;
}

.ai-typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.ai-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* Chat Header */
.ai-chat-header {
    padding: 10px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.ai-chat-title {
    font-weight: 600;
    color: #333;
}

#ai-new-chat {
    padding: 4px 10px;
    font-size: 12px;
}

#ai-new-chat:hover {
    background-color: #e9ecef;
}

/* Input Area */
.ai-chat-input-wrapper {
    padding: 12px 15px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.ai-chat-input-wrapper textarea {
    flex: 1;
    resize: none;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.4;
    font-family: inherit;
}

.ai-chat-input-wrapper textarea:focus {
    outline: none;
    border-color: #337ab7;
    box-shadow: 0 0 0 2px rgba(51, 122, 183, 0.2);
}

.ai-chat-input-wrapper button {
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.ai-chat-input-wrapper button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#ai-stop {
    background-color: #d9534f;
    border-color: #d43f3a;
}

#ai-stop:hover {
    background-color: #c9302c;
    border-color: #ac2925;
}

.ai-stopped {
    color: #999;
    font-style: italic;
}

/* Standalone Page Styles */
.ai-standalone-container {
    max-width: 900px;
    margin: 0 auto;
    height: calc(100vh - 60px);
    padding: 20px;
}

.ai-standalone-container .ai-chat-wrapper {
    height: 100%;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.ai-standalone-container .ai-chat-messages {
    background: #fafafa;
}

/* Flow Container - sequential content display */
.ai-flow-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Intermediate Text (reasoning before tool calls) */
.ai-intermediate-text {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fafafa;
    overflow: hidden;
    font-size: 13px;
}

.ai-intermediate-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: #f0f0f0;
    cursor: pointer;
    user-select: none;
}

.ai-intermediate-header:hover {
    background: #e8e8e8;
}

.ai-intermediate-icon {
    font-size: 12px;
}

.ai-intermediate-label {
    flex: 1;
    font-size: 11px;
    font-weight: 500;
    color: #666;
}

.ai-intermediate-toggle {
    font-size: 10px;
    color: #888;
}

.ai-intermediate-content {
    padding: 10px 12px;
    color: #555;
    line-height: 1.5;
    border-top: 1px solid #e0e0e0;
}

/* Flow Text - plain text blocks in the flow container */
.ai-flow-text {
    line-height: 1.6;
    color: #333;
}

.ai-flow-text p {
    margin: 0 0 8px 0;
}

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

/* Inline Tool Display */
.ai-inline-tool {
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 12px;
    border-left: 3px solid #2196f3;
    background: #f5f9ff;
}

.ai-inline-tool.ai-tool-running {
    border-left-color: #2196f3;
    background: #e3f2fd;
}

.ai-inline-tool.ai-tool-complete {
    border-left-color: #4caf50;
    background: #e8f5e9;
}

.ai-inline-tool.ai-tool-error {
    border-left-color: #f44336;
    background: #ffebee;
}

.ai-inline-tool-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.ai-inline-tool-name {
    font-family: 'Consolas', 'Monaco', monospace;
    color: #1565c0;
}

.ai-inline-tool.ai-tool-complete .ai-inline-tool-name {
    color: #2e7d32;
}

.ai-inline-tool.ai-tool-error .ai-inline-tool-name {
    color: #c62828;
}

.ai-inline-tool-params {
    margin-top: 4px;
    padding: 4px 8px;
    background: rgba(255,255,255,0.7);
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 11px;
    color: #666;
    word-break: break-all;
}

.ai-inline-tool-params:empty {
    display: none;
}

.ai-inline-tool-result {
    margin-top: 6px;
    padding: 6px 8px;
    background: rgba(255,255,255,0.8);
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 11px;
    color: #2e7d32;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-inline-tool-result:empty {
    display: none;
}

.ai-inline-tool.ai-tool-error .ai-inline-tool-result {
    color: #c62828;
}

/* Tool Loading State */
.ai-inline-tool-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-top: 8px;
    background: rgba(33, 150, 243, 0.08);
    border-radius: 4px;
    border: 1px dashed rgba(33, 150, 243, 0.3);
}

.ai-tool-loading-text {
    font-size: 12px;
    color: #1565c0;
    font-weight: 500;
}

/* Collapsible Tool State */
.ai-inline-tool-header {
    cursor: pointer;
    user-select: none;
}

.ai-tool-toggle {
    margin-left: auto;
    font-size: 10px;
    color: #999;
    transition: transform 0.2s ease;
}

.ai-inline-tool.ai-tool-collapsed .ai-tool-toggle {
    transform: rotate(-90deg);
}

.ai-inline-tool-body {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease;
    max-height: 500px;
    opacity: 1;
}

.ai-inline-tool.ai-tool-collapsed .ai-inline-tool-body {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

.ai-inline-tool.ai-tool-collapsed {
    padding-bottom: 6px;
}

/* Hover hint for collapsed tools */
.ai-inline-tool.ai-tool-collapsed .ai-inline-tool-header:hover .ai-tool-toggle {
    color: #337ab7;
}

/* Streaming Message */
.ai-message-streaming .ai-text-content {
    min-height: 20px;
}

/* Wave blocks loading indicator */
.ai-wave-loader {
    display: inline-flex;
    align-items: flex-end;
    gap: 3px;
    height: 14px;
    vertical-align: middle;
    margin-left: 2px;
}

.ai-wave-loader span {
    width: 4px;
    background: linear-gradient(180deg, #337ab7 0%, #5ba3d9 100%);
    border-radius: 2px;
    animation: wave-bar 1s ease-in-out infinite;
}

.ai-wave-loader span:nth-child(1) { animation-delay: 0s; }
.ai-wave-loader span:nth-child(2) { animation-delay: 0.12s; }
.ai-wave-loader span:nth-child(3) { animation-delay: 0.24s; }
.ai-wave-loader span:nth-child(4) { animation-delay: 0.36s; }

@keyframes wave-bar {
    0%, 100% {
        height: 4px;
        opacity: 0.4;
    }
    50% {
        height: 14px;
        opacity: 1;
    }
}

/* Thinking Section */
.ai-thinking-section {
    margin-bottom: 12px;
    border: 1px solid #e8d4f8;
    border-radius: 8px;
    background: #faf5ff;
    overflow: hidden;
}

.ai-thinking-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
    background: #f3e8fa;
    transition: background-color 0.2s;
}

.ai-thinking-header:hover {
    background: #ebe0f5;
}

.ai-thinking-icon {
    font-size: 14px;
}

.ai-thinking-label {
    flex: 1;
    font-size: 12px;
    font-weight: 500;
    color: #6b4d8a;
}

.ai-thinking-toggle {
    font-size: 10px;
    color: #8b6ba8;
    transition: transform 0.2s;
}

.ai-thinking-content {
    padding: 12px;
    font-size: 12px;
    line-height: 1.5;
    color: #555;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 150px;
    overflow-y: auto;
    background: #faf5ff;
}

/* Larger height while actively thinking */
.ai-thinking-active .ai-thinking-content {
    max-height: 300px;
    border-top: 1px solid #e8d4f8;
}

.ai-thinking-collapsed .ai-thinking-header {
    background: #f8f4fc;
}

/* Tool Log Section */
.ai-tool-log {
    margin-bottom: 12px;
    border: 1px solid #d4e8d4;
    border-radius: 8px;
    background: #f5faf5;
    overflow: hidden;
    font-size: 12px;
}

.ai-tool-log-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
    background: #e8f4e8;
    transition: background-color 0.2s;
}

.ai-tool-log-header:hover {
    background: #dceadc;
}

.ai-tool-log-icon {
    font-size: 12px;
}

.ai-tool-log-label {
    flex: 1;
    font-weight: 500;
    color: #2e7d32;
}

.ai-tool-log-toggle {
    font-size: 10px;
    color: #4caf50;
}

.ai-iteration-badge {
    background: #4caf50;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 500;
}

.ai-tool-log-entries {
    padding: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.ai-tool-entry {
    padding: 8px;
    margin-bottom: 6px;
    border-radius: 4px;
    background: white;
    border-left: 3px solid #ccc;
}

.ai-tool-entry:last-child {
    margin-bottom: 0;
}

.ai-tool-entry.ai-tool-running {
    border-left-color: #2196f3;
    background: #e3f2fd;
}

.ai-tool-entry.ai-tool-complete {
    border-left-color: #4caf50;
}

.ai-tool-entry.ai-tool-error {
    border-left-color: #f44336;
    background: #ffebee;
}

.ai-tool-entry .ai-tool-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    color: #333;
}

.ai-tool-entry .ai-tool-name {
    font-family: 'Consolas', 'Monaco', monospace;
    color: #1565c0;
}

.ai-tool-entry .ai-tool-iter {
    font-size: 10px;
    color: #888;
    margin-left: auto;
}

.ai-tool-entry .ai-tool-icon {
    font-size: 12px;
    font-weight: bold;
}

.ai-tool-entry .ai-tool-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid #b0d4ed;
    border-top-color: #2196f3;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.ai-tool-entry.ai-tool-complete .ai-tool-icon {
    color: #4caf50;
}

.ai-tool-entry.ai-tool-error .ai-tool-icon {
    color: #f44336;
}

.ai-tool-params {
    margin-top: 4px;
    padding: 4px 8px;
    background: #f5f5f5;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 11px;
    color: #666;
    word-break: break-all;
}

.ai-tool-result {
    margin-top: 4px;
    padding: 4px 8px;
    font-size: 11px;
    color: #2e7d32;
    background: #e8f5e9;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 120px;
    overflow-y: auto;
}

.ai-tool-result:empty {
    display: none;
}

.ai-tool-entry.ai-tool-error .ai-tool-result {
    color: #c62828;
    background: #ffebee;
}

/* Tool Status */
.ai-tool-status {
    margin-bottom: 12px;
}

.ai-tool-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
}

.ai-tool-running {
    background: #e8f4fc;
    color: #1a5276;
}

.ai-tool-complete {
    background: #e8f8e8;
    color: #1e7b1e;
}

.ai-tool-error {
    background: #fce8e8;
    color: #a51d1d;
}

.ai-tool-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #b0d4ed;
    border-top-color: #337ab7;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.ai-tool-icon {
    font-size: 14px;
    font-weight: bold;
}

.ai-tool-complete .ai-tool-icon {
    color: #2e7d32;
}

.ai-tool-error .ai-tool-icon {
    color: #c62828;
}

.ai-tool-name {
    flex: 1;
}

.ai-tool-summary {
    font-size: 11px;
    color: #666;
    font-style: italic;
    margin-left: 8px;
}

.ai-tool-error-text {
    font-size: 11px;
    color: #c62828;
}

/* Error text in messages */
.ai-error {
    color: #c62828;
    font-style: italic;
}

/* Text content in streaming messages */
.ai-text-content {
    min-height: 1em;
}

.ai-text-content:empty {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .ai-sidebar {
        width: 100%;
    }

    .ai-sidebar-toggle {
        left: -40px;
        width: 40px;
        height: 40px;
    }
}

/* Context Warning Banner */
.ai-context-warning {
    padding: 12px 16px;
    background: #fff3cd;
    border-bottom: 1px solid #ffc107;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
}

.ai-context-warning-critical {
    background: #f8d7da;
    border-bottom-color: #da8f05;
}

.ai-context-warning-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 200px;
}

.ai-context-warning-content i {
    color: #856404;
    font-size: 16px;
}

.ai-context-warning-critical .ai-context-warning-content i {
    color: #721c24;
}

.ai-context-warning-content span {
    font-size: 13px;
    color: #856404;
}

.ai-context-warning-critical .ai-context-warning-content span {
    color: #721c24;
}

.ai-context-warning-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.ai-context-warning-actions .btn {
    font-size: 12px;
    padding: 4px 10px;
}

/* Sidebar warning - more compact */
.ai-sidebar .ai-context-warning {
    padding: 10px 12px;
    flex-direction: column;
    align-items: stretch;
}

.ai-sidebar .ai-context-warning-content {
    margin-bottom: 8px;
}

.ai-sidebar .ai-context-warning-content span {
    font-size: 12px;
}

.ai-sidebar .ai-context-warning-actions {
    justify-content: flex-end;
}

/* ============================================
   CRM Action Proposals
   ============================================ */

/* Action Proposal Container */
.ai-action-proposal {
    border: 2px solid #5cb85c;
    border-radius: 8px;
    padding: 15px;
    margin: 12px 0;
    background: #f9fff9;
    transition: all 0.3s ease;
}

.ai-action-proposal:hover {
    box-shadow: 0 2px 8px rgba(92, 184, 92, 0.2);
}

/* Action Header */
.ai-action-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #d6e9c6;
}

.ai-action-icon {
    font-size: 20px;
    color: #3c763d;
}

.ai-action-title {
    font-weight: 600;
    font-size: 14px;
    color: #3c763d;
}

.ai-action-type-badge {
    margin-left: auto;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 12px;
    background: #dff0d8;
    color: #3c763d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Action Summary */
.ai-action-summary {
    font-size: 14px;
    color: #333;
    margin-bottom: 8px;
    line-height: 1.5;
}

/* Action Reason */
.ai-action-reason {
    font-size: 12px;
    color: #666;
    margin-bottom: 12px;
    padding: 8px 10px;
    background: #f0f0f0;
    border-radius: 4px;
    border-left: 3px solid #5cb85c;
}

/* Action Fields Preview */
.ai-action-fields {
    font-size: 12px;
    margin-bottom: 12px;
    padding: 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.ai-action-field {
    display: flex;
    margin-bottom: 6px;
}

.ai-action-field:last-child {
    margin-bottom: 0;
}

.ai-action-field-label {
    width: 140px;
    flex-shrink: 0;
    font-weight: 500;
    color: #666;
}

.ai-action-field-value {
    flex: 1;
    color: #333;
    word-break: break-word;
}

/* Action Buttons */
.ai-action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
}

.ai-action-buttons .btn {
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ai-action-confirm {
    background-color: #5cb85c;
    border-color: #4cae4c;
    color: #fff;
}

.ai-action-confirm:hover {
    background-color: #449d44;
    border-color: #398439;
    color: #fff;
}

.ai-action-details {
    background-color: #f5f5f5;
    border-color: #ddd;
    color: #333;
}

.ai-action-details:hover {
    background-color: #e8e8e8;
    border-color: #ccc;
}

.ai-action-reject {
    background-color: #fff;
    border-color: #d9534f;
    color: #d9534f;
}

.ai-action-reject:hover {
    background-color: #d9534f;
    border-color: #d43f3a;
    color: #fff;
}

/* Action States */
.ai-action-proposal.ai-action-executing {
    border-color: #31708f;
    background: #f0f8ff;
}

.ai-action-proposal.ai-action-executing .ai-action-header {
    border-bottom-color: #bce8f1;
}

.ai-action-proposal.ai-action-executing .ai-action-icon {
    color: #31708f;
}

.ai-action-proposal.ai-action-executing .ai-action-title {
    color: #31708f;
}

.ai-action-proposal.ai-action-success {
    border-color: #3c763d;
    background: #dff0d8;
}

.ai-action-proposal.ai-action-error {
    border-color: #a94442;
    background: #f2dede;
}

.ai-action-proposal.ai-action-error .ai-action-header {
    border-bottom-color: #ebccd1;
}

.ai-action-proposal.ai-action-error .ai-action-icon {
    color: #a94442;
}

.ai-action-proposal.ai-action-error .ai-action-title {
    color: #a94442;
}

/* Action Result */
.ai-action-result {
    margin-top: 12px;
    padding: 12px;
    border-radius: 4px;
    font-size: 13px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.ai-action-result.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.ai-action-result.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.ai-action-result-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.ai-action-result-content {
    flex: 1;
}

.ai-action-result-content a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

/* Executing Spinner */
.ai-action-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #bce8f1;
    border-top-color: #31708f;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

/* Action Modal Styles */
.ai-action-modal .modal-header {
    background: #f8f8f8;
    border-bottom: 1px solid #e0e0e0;
}

.ai-action-modal .modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-action-modal .modal-title i {
    color: #5cb85c;
}

.ai-action-modal .modal-body {
    padding: 20px;
}

.ai-action-modal .form-group {
    margin-bottom: 15px;
}

.ai-action-modal .form-group label {
    font-weight: 500;
    color: #333;
    margin-bottom: 5px;
}

.ai-action-modal .form-group .form-control {
    border-radius: 4px;
}

.ai-action-modal .form-group .form-control:focus {
    border-color: #5cb85c;
    box-shadow: 0 0 0 2px rgba(92, 184, 92, 0.2);
}

.ai-action-modal .form-group .form-control[readonly] {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

.ai-action-modal .form-group .help-block {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

.ai-action-modal .ai-action-reason-detail {
    margin-top: 20px;
    padding: 12px;
    background: #f9f9f9;
    border-radius: 4px;
    border-left: 3px solid #5cb85c;
}

.ai-action-modal .ai-action-reason-detail strong {
    display: block;
    margin-bottom: 5px;
    color: #333;
}

.ai-action-modal .ai-action-reason-detail p {
    margin: 0;
    font-size: 13px;
    color: #666;
}

.ai-action-modal .modal-footer {
    background: #f8f8f8;
    border-top: 1px solid #e0e0e0;
}

/* Disabled state for buttons while executing */
.ai-action-buttons .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================
   Duplication Proposal Styles
   ============================================ */
.ai-duplication-proposal {
    border-left-color: #17a2b8;
}

.ai-duplication-proposal .ai-action-icon {
    color: #17a2b8;
}

.ai-duplication-proposal .ai-action-type-badge {
    background-color: #17a2b8;
}

.ai-dup-details {
    display: flex;
    align-items: stretch;
    gap: 10px;
    margin: 12px 0;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
}

.ai-dup-source,
.ai-dup-target {
    flex: 1;
    padding: 10px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.ai-dup-source {
    border-left: 3px solid #6c757d;
}

.ai-dup-target {
    border-left: 3px solid #28a745;
}

.ai-dup-arrow {
    display: flex;
    align-items: center;
    color: #17a2b8;
    font-size: 20px;
}

.ai-dup-section-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai-dup-field {
    display: flex;
    margin-bottom: 4px;
    font-size: 13px;
}

.ai-dup-field:last-child {
    margin-bottom: 0;
}

.ai-dup-label {
    color: #666;
    min-width: 80px;
    flex-shrink: 0;
}

.ai-dup-value {
    color: #333;
    font-weight: 500;
}

.ai-dup-value.positive {
    color: #28a745;
}

.ai-dup-value.negative {
    color: #dc3545;
}

.ai-dup-quotes,
.ai-dup-price-adjust {
    margin: 8px 0;
    padding: 8px 12px;
    background: #e8f4f8;
    border-radius: 4px;
    font-size: 13px;
    color: #0c5460;
}

.ai-dup-quotes i,
.ai-dup-price-adjust i {
    margin-right: 6px;
}

.ai-dup-no-quotes {
    background: #f8f9fa;
    color: #6c757d;
}

/* Multiple actions list */
.ai-action-list {
    margin: 12px 0;
}

.ai-action-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin-bottom: 8px;
}

.ai-action-list-item:last-child {
    margin-bottom: 0;
}

.ai-action-list-item input[type="checkbox"] {
    flex-shrink: 0;
}

.ai-action-list-item-content {
    flex: 1;
}

.ai-action-list-item-name {
    font-weight: 500;
    color: #333;
}

.ai-action-list-item-details {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

/* CSV Export Styles */
.ai-csv-export {
    margin: 12px 0;
    padding: 12px 16px;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border: 1px solid #a5d6a7;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ai-csv-export-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-csv-export-icon {
    width: 40px;
    height: 40px;
    background: #4caf50;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

.ai-csv-export-info {
    flex: 1;
}

.ai-csv-export-filename {
    font-weight: 600;
    color: #2e7d32;
    font-size: 14px;
}

.ai-csv-export-details {
    font-size: 12px;
    color: #558b2f;
    margin-top: 2px;
}

.ai-csv-download-btn {
    white-space: nowrap;
}

.ai-csv-download-btn .spinning {
    animation: spin 1s linear infinite;
}

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

/* ==================== File Attachment Styles ==================== */

/* Attachment button in input area */
.ai-attach-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    color: #666;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-attach-btn:hover {
    background: #e8e8e8;
    color: #337ab7;
    border-color: #ccc;
}

.ai-attach-btn.has-files {
    background: #e3f2fd;
    border-color: #337ab7;
    color: #337ab7;
}

/* Attachments preview area */
.ai-attachments-preview {
    padding: 10px 15px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
}

.ai-attachments-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.ai-attachments-count {
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

.ai-clear-attachments {
    font-size: 11px;
    padding: 0;
    color: #999;
}

.ai-clear-attachments:hover {
    color: #d9534f;
    text-decoration: none;
}

/* Attachment chips list */
.ai-attachments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Individual attachment chip */
.ai-attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 16px;
    font-size: 12px;
    max-width: 200px;
}

.ai-attachment-chip .glyphicon-file {
    color: #d9534f;
    font-size: 12px;
    flex-shrink: 0;
}

.ai-attachment-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #333;
}

.ai-attachment-size {
    color: #999;
    font-size: 10px;
    flex-shrink: 0;
}

.ai-attachment-remove {
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: #999;
    line-height: 1;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-attachment-remove:hover {
    color: #d9534f;
}

.ai-attachment-remove .glyphicon {
    font-size: 10px;
}

/* Attachment error display */
.ai-attachment-error {
    color: #d9534f;
    font-size: 11px;
    padding: 6px 10px;
    background: #fdf2f2;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin-top: 8px;
}

/* Attachment indicators in user messages */
.ai-message-attachments {
    margin-bottom: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ai-attachment-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    font-size: 11px;
}

.ai-attachment-indicator .glyphicon-file {
    font-size: 10px;
}

/* ==================== End File Attachment Styles ==================== */

/* ==================== Interactive Choice Prompt Styles ==================== */

.ai-choice-prompt {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 16px;
    margin: 12px 0;
}

.ai-choice-prompt.ai-choice-selected {
    opacity: 0.7;
    pointer-events: none;
}

.ai-choice-question {
    font-weight: 500;
    color: #333;
    margin-bottom: 12px;
    font-size: 14px;
}

/* Button group for 2-4 options */
.ai-choice-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ai-choice-btn {
    padding: 10px 20px;
    border: 2px solid #0066cc;
    background: #fff;
    color: #0066cc;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.ai-choice-btn:hover:not(:disabled) {
    background: #0066cc;
    color: #fff;
}

.ai-choice-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.ai-choice-btn.ai-choice-btn-selected {
    background: #0066cc;
    color: #fff;
    opacity: 1;
}

.ai-choice-btn.ai-choice-btn-selected::before {
    content: "\e013"; /* glyphicon-ok */
    font-family: 'Glyphicons Halflings';
    margin-right: 6px;
    font-size: 12px;
}

/* Option descriptions below buttons */
.ai-choice-descriptions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e9ecef;
}

.ai-choice-desc-item {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.ai-choice-desc-item strong {
    color: #333;
}

/* Dropdown for many options */
.ai-choice-dropdown-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ai-choice-dropdown {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
    max-width: 400px;
}

.ai-choice-dropdown:focus {
    outline: none;
    border-color: #0066cc;
}

.ai-choice-dropdown:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.ai-choice-submit {
    padding: 10px 16px;
    background: #5cb85c;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.ai-choice-submit:hover:not(:disabled) {
    background: #449d44;
}

.ai-choice-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Selection feedback */
.ai-choice-feedback {
    margin-top: 10px;
    padding: 8px 12px;
    background: #d4edda;
    color: #155724;
    border-radius: 4px;
    font-size: 13px;
}

.ai-choice-feedback .glyphicon {
    margin-right: 6px;
}

/* ==================== End Interactive Choice Prompt Styles ==================== */

/* ==================== Interactive Text Input Prompt Styles ==================== */

.ai-input-prompt {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 16px;
    margin: 12px 0;
}

.ai-input-prompt.ai-input-submitted {
    opacity: 0.7;
    pointer-events: none;
}

.ai-input-question {
    font-weight: 500;
    color: #333;
    margin-bottom: 12px;
    font-size: 14px;
}

.ai-input-field-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ai-input-field {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
    max-width: 400px;
}

.ai-input-field:focus {
    outline: none;
    border-color: #0066cc;
}

.ai-input-field:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.ai-input-submit {
    padding: 10px 16px;
    background: #5cb85c;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.ai-input-submit:hover:not(:disabled) {
    background: #449d44;
}

.ai-input-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.ai-input-feedback {
    margin-top: 10px;
    padding: 8px 12px;
    background: #d4edda;
    color: #155724;
    border-radius: 4px;
    font-size: 13px;
}

.ai-input-feedback .glyphicon {
    margin-right: 6px;
}

/* ==================== End Interactive Text Input Prompt Styles ==================== */
