/* AI Assist Styles for Expression Builder */
/* Chat Message Styles - Matching UI theme */
.chat-history {
    background: #fbfbfb;
    font-family: "Open Sans", Arial, Helvetica, Sans-Serif;
}
#ai-panel p,
#ai-panel-content p,
.chat-history p,
.ai-message p,
.user-message p,
.streaming-message p,
.loading-message p {
    visibility: visible !important;
    color: inherit !important;
}

/* Ensure all p tags within AI panel and its children are visible */
#ai-panel * p,
.chat-history * p {
    visibility: visible !important;
    color: inherit !important;
}

/* Specific overrides for rendered HTML content in messages */
.ai-message div[ng-bind-html] p,
.streaming-message div[ng-bind-html] p {
    visibility: visible !important;
    color: #404040 !important;
    margin: 4px 0 !important;
}
.user-message,
.ai-message {
    margin-bottom: 15px;
    padding: 10px 12px;
    border-radius: 0;
    line-height: 1.428571429;
    font-size: 13px;
    font-family: "Open Sans", Arial, Helvetica, Sans-Serif;
    animation: fadeIn 0.3s ease;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

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

.user-message {
    background: #f5f5f5;
    color: #404040;
    margin-left: 20%;
    border: 1px solid #ddd;
    border-radius: 0;
}

.ai-message {
    background: #fff;
    color: #404040;
    margin-right: 20%;
    border: 1px solid #ddd;
    border-radius: 0;
    box-shadow: 0 1px 1px #ececec;
}

.loading-message {
    background: #fff;
    color: #666;
    margin-right: 20%;
    border: 1px solid #ddd;
    padding: 10px 12px;
    border-radius: 0;
    font-family: "Open Sans", Arial, Helvetica, Sans-Serif;
}

.streaming-message {
    background: #fff;
    color: #404040;
    margin-right: 20%;
    border: 1px solid #ddd;
    padding: 10px 12px;
    border-radius: 0;
    box-shadow: 0 1px 1px #ececec;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    font-family: "Open Sans", Arial, Helvetica, Sans-Serif;
}

.streaming-cursor {
    animation: blink 1s infinite;
    color: #428bca;
    font-weight: bold;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.streaming-response {
    position: relative;
    display: inline;
}

/* Streaming performance indicator */
.streaming-performance-indicator {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    padding: 4px 8px;
    margin: 4px 0;
    font-size: 11px;
    color: #6c757d;
    border-radius: 3px;
    font-family: monospace;
}

.large-response-indicator {
    background: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

/* Code blocks in messages */
.ai-message pre,
.streaming-message pre,
.loading-message pre {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 0;
    padding: 8px 12px;
    margin: 8px 0;
    overflow-x: auto;
    font-size: 12px;
    font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
}

.ai-message code,
.streaming-message code,
.loading-message code {
    background: #f5f5f5;
    padding: 2px 4px;
    border-radius: 0;
    font-size: 12px;
    color: #c7254e;
    font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
}

.ai-message pre code,
.streaming-message pre code {
    background: transparent;
    padding: 0;
    color: #404040;
}

/* Chat input styling */
.chat-input-area {
    border-top: 1px solid #ddd;
    background: #f8f8f8;
}

.chat-input-area textarea {
    border: 1px solid #ccc;
    border-radius: 0;
    padding: 6px 12px;
    font-size: 13px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    font-family: "Open Sans", Arial, Helvetica, Sans-Serif;
}

.chat-input-area textarea:focus {
    border-color: #428bca;
    outline: 0;
    box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(66,139,202,.6);
}

.chat-input-area textarea.has-selected-code {
    background: #f8f9fa;
    border-left: 4px solid #428bca;
    padding-left: 12px;
}

.chat-input-area button {
    border-radius: 0;
    transition: all 0.2s;
    border: 1px solid #ccc;
    background: #fff;
    color: #404040;
}

.chat-input-area button:hover:not(:disabled) {
    background: #e6e6e6;
    border-color: #adadad;
}

.chat-input-area button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

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

.chat-history::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-history::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 0;
}

.chat-history::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* AI Send Button */
.ai-send-button {
    background: #428bca;
    border: 1px solid #357ebd;
    color: #fff;
    padding: 8px 12px;
    border-radius: 0;
    font-size: 13px;
    font-family: "Open Sans", Arial, Helvetica, Sans-Serif;
}

.ai-send-button:hover:not(:disabled) {
    background: #3071a9;
    border-color: #285e8e;
}

.ai-send-button:disabled {
    background: #ccc;
    border-color: #ccc;
    opacity: 0.65;
}

/* Revert Button Styling */
.btn.btn-xs.btn-warning {
    background: #f0ad4e;
    border-color: #eea236;
    color: #fff;
    font-size: 11px;
    padding: 3px 8px;
}

.btn.btn-xs.btn-warning:hover {
    background: #ec971f;
    border-color: #d58512;
}

/* AI Panel Styles - Resizable panel */
#ai-panel {
    width: 300px;
    min-width: 200px;
    max-width: 2000px;
    flex: 0 0 auto;
    overflow: auto;
    border-left: 1px solid #ddd;
}

.ai-panel-collapsed {
    overflow: hidden !important;
    width: 35px !important;
    min-width: 35px !important;
    max-width: 35px !important;
}

.ai-panel-collapsed * {
    overflow: hidden !important;
}

.ai-panel-collapsed .ai-panel-header input {
    width: 35px;
    text-indent: -9999px;
}

.ai-panel-toggle {
    transition: transform 0.2s ease;
}

.ai-panel-toggle:hover {
    background: rgba(0,0,0,0.05) !important;
    border-radius: 2px;
}