/**
 * 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 */
    /*position: relative;*/
    /*z-index: 9999;*/
    /*background-color: rgba(255,255,255,0.8);*/
}
/*
.isen-chat-container::before {
    left: -1000px;
    right: -1000px;
    background-color: rgba(255,255,255,0.8);
    content: "";
    position: absolute;
    bottom: 0px;
    z-index: -2;
    height: 210px;
}
*/

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

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

/* 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 20px 0px;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 999;
}

/* 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: #565656;
}
@media (max-width: 640px) {
}
.isen-input-container textarea {
  margin-bottom: 0px;
}

.isen-chat-input-area-wrapper {
    position: fixed;
    bottom: 30px;
    padding-right: 20px;
}



.isen-chat-input-area-search {
    position: fixed;
    z-index: 99;
    //bottom: 0px;
    width: 100%;
    height: 210px;
}

/* Chat page: input centered (bottom 40%) until conversation has messages, then bottom 0 */
@media (max-width: 980px) {
  .isen-chat-page .isen-chat-input-area,
  .isen-chat-page .isen-chat-input-area-search {
    bottom: 40%;
    transition: bottom 0.7s ease;
  }
}
@media (min-width: 981px) {
  .isen-chat-page .isen-chat-input-area,
  .isen-chat-page .isen-chat-input-area-search {
    bottom: 45%;
    transition: bottom 0.7s ease;
  }
}
.isen-chat-page:has(.isen-messages-list .isen-message) .isen-chat-input-area,
/* Only real messages in the list count; typing indicator uses .isen-message but is outside .isen-messages-list */
.isen-chat-page:has(.isen-messages-list .isen-message) .isen-chat-input-area-search {
    bottom: 0;
}

@keyframes fadeIn_introTextLine {
	0% {
		opacity: 0;
		transform: translate3d(25%, 0, 0); }
	50% {
		opacity: 0.25; }
	100% {
		opacity: 1;
		transform: translate3d(0, 0, 0); }
}

.isen-chat-page:has(.isen-messages-list .isen-message) .introTextLine {
    display: none;
}
.introTextLine {
    opacity: 0;
    animation: fadeIn_introTextLine 0.5s ease-out 0s forwards;
}



@media (max-width: 500px) {
  .introTextLine {
    margin: 0 50px 15px 20px;
  }
}
@media (min-width: 501px) {
  .introTextLine {
    font-size: 22px;
    margin: 0 50px 15px 35px;
    width: calc(100% - 140px);
  }
}
@media (max-width: 980px) {
  .introTextLine {
    max-width: 420px;
  }
}


.isen-chat-input-area {
    position: fixed;
    /*bottom: 0;*/
    z-index: 999;
}
@media (max-width: 400px) {
  .isen-chat-input-area {
    margin-bottom: 60px;
  }
}
@media (min-width: 401px) {
  .isen-chat-input-area {
    margin-bottom: 40px;
  }
}

@media (max-width: 980px) {
  .isen-chat-input-area {
    width: calc(100% - 0px);
  }
}
@media (min-width: 981px) {
  .isen-chat-input-area {
    width: 50%;
  }
}

.isen-chat-input-area::before {
    content: "";
    position: absolute;
    top: -30px;
    //bottom: 0px;
    z-index: -1;
    height: 150px;
    left: -1000px;
    right: -1000px;
    background-color: rgba(255,255,255,0.9);
}
[data-theme="dark"] .isen-chat-input-area::before {
    background-color: #1a1a1a;
}


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




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

.isen-input-footer {
    position: relative;
}
@media (max-width: 500px) {
  .isen-input-footer {
    //width: calc(100% - 40px);
    line-height: 10px;
    margin-top: 5px;
  }
}
@media (min-width: 501px) {
  .isen-input-footer {
    left: 10%;
  }
}

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

/* Message input */
.isen-message-input {
    font-family: 'Roboto-Regular-Murk',sans-serif;
    flex: 1;
    padding: 12px 20px;
    //border: solid 1px #454545;
    border: none;
  	border-radius: 40px;
    resize: vertical;
    overflow: hidden;
    line-height: 1.4;
    box-shadow: 0 0px 10px rgba(59,69,252,0.35);
}
[data-theme="dark"] .isen-message-input {
  border: 1px solid #666;
  box-shadow: 0 0px 10px rgba(189,199,255,0.35);
}
@media (max-width: 500px) {
  .isen-message-input {
    width: calc(100% - 40px);
    margin-right: 20px;
  }
}
@media (min-width: 501px) {
  .isen-message-input {
    width: calc(100% - 80px);
    margin-right: 10px;
  }
}
@media (max-width: 980px) {
  .isen-message-input {
    max-width: 480px;
  }
}

textarea.isen-message-input::placeholder {
  font-family: 'Roboto-Italic',sans-serif;
  color: #99f;
}
[data-theme="dark"] textarea.isen-message-input::placeholder {
  color: #999;
}

@media (max-width: 500px) {
  textarea.isen-message-input::placeholder {
    /*font-size: 5vw;*/
  }
}
.isen-chat-page:has(.isen-messages-list .isen-message) .isen-chat-input-area textarea.isen-message-input::placeholder {
  //font-size: 10px;
}

.isen-message-input:focus {
}

/* Send button */
@media (max-width: 500px) {
  .isen-send-button {
    position: absolute;
    margin-left: -40px;
    margin-top: -20px;
  }
}
@media (min-width: 501px) {
  .isen-send-button {
    position: absolute;
  }
}

.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;
    animation: fadeIn 0.75s ease-out;
}

/* Button disabled state styling */
#isen-send-button:disabled .isen-send-text {
    opacity: 0.05;
    display: none;
    margin-top: 200px;
}

/* Delete history confirmation modal (replaces browser confirm) */
.isen-delete-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.isen-delete-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255, 0.75);
    cursor: pointer;
}
[data-theme="dark"] .isen-delete-modal-backdrop {
    background: rgba(0,0,0, 0.75);
}

.isen-delete-modal-dialog {
    position: relative;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 100%;
    padding: 20px 35px 35px 35px;
}
[data-theme="dark"] .isen-delete-modal-dialog {
  background: #454545;
}
.isen-delete-modal-title {
    text-align: center;
}
/*.isen-delete-modal-message {
    margin: 0 0 1.25rem;
    color: #444;
    line-height: 1.5;
}*/
.isen-delete-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}
/*
.isen-delete-modal-cancel,
.isen-delete-modal-confirm {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9375rem;
    cursor: pointer;
    border: 1px solid #ccc;
    background: #fff;
}
.isen-delete-modal-cancel:hover {
    background: #f5f5f5;
}
.isen-delete-modal-confirm {
    border-color: #c00;
    background: #c00;
    color: #fff;
}
.isen-delete-modal-confirm:hover {
    background: #a00;
}
*/
