/**
 * Enhanced Chat Interface CSS with Markdown Support and RAG Integration
 * Basic layout, background colors, Markdown styling, and RAG knowledge indicators
 * PHASE 3C-2: Added basic knowledge usage indicators
 */

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

/* Main container - full screen with top space for menu */
.isen-minimal-container {
    width: 100%;
    height: 100vh;
    background-color: #f5f5f5;
    padding-top: 60px; /* Space for menu */
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Chat wrapper - centered with max width */
.isen-chat-wrapper {
    width: 100%;
    max-width: 600px;
    background-color: #ffffff;
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
}

/* Messages area */
.isen-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #ffffff;
}

/* Chat messages container - no internal scrolling */
.isen-chat-messages {
    flex: 1;
    overflow: visible; /* No internal scrolling */
    height: auto;
}

/* WordPress page context specific overrides */
.isen-chat-container .isen-chat-messages {
    overflow: visible !important; /* No internal scrolling */
    height: auto !important;
}

/* Ensure the chat container has proper layout */
.isen-chat-container {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important; /* Auto height - no fixed height */
    /*min-height: 400px; */ /* Minimum height for better appearance */
}

@media (max-width: 768px) {
    .isen-chat-container {
        min-height: calc(100vh - 100px);
    }
}

@media (min-width: 769px) {
    .isen-chat-container {
        min-height: calc(100vh - 100px);
    }
}

/* Messages list should take available space */
.isen-messages-list {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Messages list container */
.isen-messages-container {
    padding: 0px 0px 80px 0px;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

/* Messages list */
.isen-messages-list {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Individual messages */
.isen-message {
}

.isen-message-assistant {
    text-align: left;
    margin-bottom: 20px;
}

.isen-message-user {
    text-align: left;
}

.isen-message-user p {
    display: inline-block;
    /*font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto-Bold, sans-serif;*/
    font-family: 'Roboto-Regular', sans-serif;
    margin: 25px 0 10px 25px;
    background-color: #eee;
    color: darkslategray;
    border-radius: 20px;
    padding: 8px 15px 10px 15px;
}

[data-theme="dark"] .isen-message-user p {
    background-color: #444;
    color: white;
    border-radius: 20px;
}

.isen-message-user .OLD p {
    display: inline-block;
    font-family: 'Roboto-Bold', sans-serif;
    color: rgb(0,87,210);
    margin: 25px 0 5px 25px;
}




/* PHASE 3C-2: RAG Knowledge Usage Indicators */

/* Knowledge usage indicator */
.isen-knowledge-used {
    background-color: #f0f8ff;
    border-left: 3px solid #0066cc;
    padding: 8px 12px;
    margin: 0 0 12px 0;
    color: #0066cc;
    border-radius: 0 4px 4px 0;
}

/* Knowledge indicator in assistant messages */
.isen-message-assistant .isen-knowledge-used {
    margin-top: 0;
    margin-bottom: 12px;
}

/* Markdown Styling for AI Responses */

/* Paragraphs */
.isen-message-assistant p {
    margin: 12px 0;
}

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

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

/* Emphasis */
.isen-message-assistant strong {
    font-weight: 600;
}

.isen-message-assistant em {
    font-style: italic;
}

/* Code blocks */
.isen-code-block {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    margin: 16px 0;
    overflow-x: auto;
    /*font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto-Bold, sans-serif;*/
}

.isen-code-block code {
    background: none;
    padding: 0;
    border: none;
    border-radius: 0;
}

/* Inline code */
.isen-inline-code {
    background-color: #f1f3f4;
    padding: 2px 6px;
    border-radius: 3px;
    /*font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto-Bold, sans-serif;*/
    color: #d73a49;
    border: 1px solid #e1e4e8;
}

/* Links */
.isen-message-assistant a {
    transition: color 0.2s ease;
}

/* Blockquotes */
.isen-message-assistant blockquote {
    border-left: 4px solid #0066cc;
    margin: 16px 0;
    padding: 12px 16px;
    background-color: #f8f9ff;
    border-radius: 0 4px 4px 0;
    color: #555;
    font-style: italic;
}

.isen-message-assistant blockquote p {
    margin: 0;
}

/* Horizontal rules */
.isen-message-assistant hr {
    border: none;
    height: 1px;
    background-color: #eee;
    margin: 24px 0;
}

/* Tables (if AI generates them) */
.isen-message-assistant table {
    border-collapse: collapse;
    margin: 16px 0;
    width: 100%;
}

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

.isen-message-assistant th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #454545;
}

.isen-message-assistant tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* Input area */



.isen-input-container textarea::placeholder {
    color: #454545;
}
.isen-chat-input-area-wrapper {
    position: fixed;
    bottom: 30px;
    padding-right: 20px;
}


.isen-chat-input-area {
    position: relative;
    width: 100%;
    height: 180px;
}



.isen-chat-input-area::before {
    content: "";
    position: absolute;
    top: -30px;
    bottom: -30px;
    /*background-color: rgba(168,213,255,1.0); light blue */
    /*background-color: rgba(168,213,142,1.0); green lighter */
    /*background-color: rgba(93,183,122,1.0);*/
    background-color: rgba(0,164,175,1.0);
    z-index: -1;
    height: 210px;
}

.isen-chat-input-area::before {
    left: -1000px;
    right: -1000px;
}

@media (max-width: 640px) {
    .isen-chat-input-area::before {
        left: -20px;
        right: -20px;
    }
}


/*
.isen-chat-input-area::before {
    content: "";
    position: fixed;
    top: auto;
    bottom: 0px;
    left: -1000px;
    right: -1000px;
    background-color: rgba(168,213,142,1.0);
    z-index: -1;
    height: 200px;
}
*/


.isen-input-area {
    background-color: #f9f9f9;
    padding: 15px;
}

.isen-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

/* Message input */
.isen-message-input {
    flex: 1;
    color: white !important;
    background-color: transparent;
    padding: 10px 0;
    resize: vertical;
    min-height: 80px;
    max-height: 120px;
    max-width: 600px;
    width: calc(100% - 60px);
}

.isen-message-input:focus {
}

/* Send button */
.isen-send-button {
    float: right;
}

.isen-send-button:hover {
    background-color: darkslategray;
}

.isen-send-button:disabled {
    background-color: #777;
    cursor: not-allowed;
}

/* Footer info */
.isen-footer-info {
    width: 100%;
    max-width: 600px;
    display: flex;
    justify-content: space-between;
    background-color: transparent;
    padding: 10px 0;
}

.isen-plan-info,
.isen-token-info {
    background-color: transparent;
    color: #666;
}

/* Typing indicator */
.isen-typing-indicator {
    background-color: transparent;
    margin-bottom: 10px;
}

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

.isen-message {
    animation: fadeIn 0.3s ease-out;
}

/* Code syntax highlighting classes (basic) */
.isen-code-block .language-javascript,
.isen-code-block .language-js {
    color: #454545;
}

.isen-code-block .language-python {
    color: #454545;
}

.isen-code-block .language-css {
    color: #454545;
}

.isen-code-block .language-html {
    color: #454545;
}

/* Hidden inputs */
input[type="hidden"] {
    display: none;
}

/* Mobile responsiveness */
@media (max-width: 640px) {
    .isen-minimal-container {
        padding-top: 40px;
        padding-left: 10px;
        padding-right: 10px;
    }
    
    .isen-chat-wrapper {
        max-width: 100%;
    }
    
    .isen-footer-info {
        max-width: 100%;
        flex-direction: column;
        gap: 5px;
        text-align: center;
    }
    
    /* Adjust markdown elements for mobile */
    .isen-code-block {
        padding: 8px;
        margin: 12px 0;
    }
    
    .isen-message-assistant ul,
    .isen-message-assistant ol {
        padding-left: 16px;
    }
    
    .isen-message-assistant table {
    }
    
    .isen-message-assistant th,
    .isen-message-assistant td {
        padding: 6px 8px;
    }
    
    /* PHASE 3C-2: Mobile adjustments for knowledge indicators */
    .isen-knowledge-used {
        padding: 6px 10px;
        margin: 0 0 10px 0;
    }
}

/* Logout link styling */
.isen-logout-link {
    display: inline-block;
    margin-left: 10px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.isen-logout-link:hover {
    text-decoration: none;
}

.isen-logout-link:active {
    transform: translateY(1px);
}








/* Chat Button Icons CSS */



/* Loading state icon (spinning or dots) */
[data-icon="icon-loading"]::before {
    /*content: "âŸ³";*/
    font-size: 36px;
    animation: spin 1s linear infinite;
}

/* Spinning animation for loading icon */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Alternative loading icon using dots */
[data-icon="icon-loading"]::before {
    /*content: "â‹¯";*/
    font-size: 36px;
    animation: pulse 1.5s ease-in-out infinite;
}

/* Pulse animation for dots */
@keyframes pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Ensure the span takes up proper space */
.isen-send-text {
    display: inline-block;
    min-width: 36px;
    text-align: center;
}

/* Button disabled state styling */
#isen-send-button:disabled .isen-send-text {
    opacity: 0.25;
}



