﻿/*
 * File: ARPAIChatControl.css
 * Version: 54.0
 * Changelog:
 * Base Version: 53.0
 * v54.0 - 2025-08-19:
 * - Reverted aspect-ratio styling for a constrained-height approach.
 * - Set min-height and max-height on .ARP-chart-wrapper to create a
 * fixed-height area for the chart to render within.
 * v53.0 - 2025-08-19:
 * - Simplified the .ARP-chart-wrapper to use a `min-height` of 350px.
 */

/* --- THEME VARIABLES --- */
.ARP-chat-container {
    /* Colors */
    --user-bubble-bg: #255ea9;
    --assistant-bubble-bg: white;
    --text-color: #323130;
    --bg-color: #f3f2f1;
    --content-bg-color: #ffffff;
    --border-color: #c8c6c4;
    --input-bg: #ffffff;
    --table-bg: #ffffff;
    --table-border-color: #e1dfdd;
    --table-header-bg: #f3f2f1;
    --table-row-hover-bg: #f3f2f1;
    --metadata-text-color: #8a8886;
    --sample-prompt-bg: #f3f2f1;
    --sample-prompt-border: #c8c6c4;
    --sample-prompt-hover-bg: #e1dfdd;
    --disabled-bg: #c8c6c4;
    --disabled-border: #c8c6c4;
    --disabled-text: #8a8886;
    --stop-button-bg: #a4262c;
    /* Typography */
    --font-size-base: 13px;
    --font-size-md: 14px;
    --font-size-sm: 12px;
    --line-height-base: 1.5;
}

    .ARP-chat-container.dark-mode {
        --user-bubble-bg: #3b82f6;
        --assistant-bubble-bg: #374151;
        --text-color: #e5e7eb;
        --bg-color: #111827;
        --content-bg-color: #1f2937;
        --border-color: #4b5563;
        --input-bg: #374151;
        --table-bg: #374151;
        --table-border-color: #4b5563;
        --table-header-bg: #4b5563;
        --table-row-hover-bg: #5a6678;
        --metadata-text-color: #9ca3af;
        --sample-prompt-bg: #374151;
        --sample-prompt-border: #4b5563;
        --sample-prompt-hover-bg: #4b5563;
        --disabled-bg: #4b5563;
        --disabled-border: #c8c6c4;
        --disabled-text: #9ca3af;
        --stop-button-bg: #f17075;
    }

/* --- BASE LAYOUT --- */
.ARP-chat-container {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
    background-color: var(--bg-color);
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    font-size: var(--font-size-base);
    color: var(--text-color);
}

.ARP-chat-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    position: relative;
    background-color: var(--content-bg-color);
}

.ARP-message-log {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 10px;
    padding-right: 10px;
    margin-left: 2px;
}

.ARP-message-bubble {
    padding: 8px 16px;
    border-radius: 6px;
    line-height: var(--line-height-base);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.ARP-message-bubble p {
    margin: 0;
}


.ARP-user-message {
    background-color: var(--user-bubble-bg);
    color: #ffffff;
    align-self: flex-end;
    max-width: 70%;
}

.ARP-assistant-message {
    position: relative;
    color: var(--text-color);
    align-self: flex-start;
    padding: 8px 0;
    margin-left: 45px; /* Make space for the larger logo */
}

    /* --- Assistant Message Logo --- */
    .ARP-assistant-message::before {
        content: '';
        position: absolute;
        left: -41px;
        top: 4px;
        width: 30px;
        height: 30px;
        background-image: url(https://www.planautomate.com/wp-content/uploads/2025/09/pa-cloud-adobe-v1-cloud-only.png);
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;
        transition: opacity 0.3s ease-in-out;
        opacity: 1;
    }

.ARP-chat-container.dark-mode .ARP-assistant-message::before {
    background-image: url('/resources/images/pa-cloud-adobe-v1-white-cloud-only.png');
}

/* Hide static logo when thinking animation is active */
.ARP-assistant-message.is-thinking::before {
    opacity: 0;
}


/* --- Thinking Indicator & Animation --- */
.ARP-tool-indicator {
    /* Hide the indicator by default */
    display: none;
    position: absolute;
    left: -41px;
    top: 4px;
    align-items: center;
    gap: 8px;
    height: 30px; /* Match logo height */
}

/* Show the indicator when the parent bubble is thinking */
.ARP-assistant-message.is-thinking .ARP-tool-indicator {
    display: flex;
}

.ARP-logo-indicator {
    width: 30px;
    height: 30px;
    background-image: url('/resources/images/pa-cloud-adobe-v1-cloud-only.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    animation: arp-logo-pulse 1.5s ease-in-out infinite;
    transition: filter 0.3s ease-in-out;
    filter: none; /* Default (light mode) */
}

.ARP-chat-container.dark-mode .ARP-logo-indicator {
    filter: invert(1) grayscale(1) brightness(3);
}

@keyframes arp-logo-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(0.90);
        opacity: 0.5;
    }
}

/* Hide the "Thinking..." text once content starts streaming in */
.ARP-assistant-message.is-streaming .ARP-tool-indicator span {
    display: none;
}


/* --- Scroll Down Indicator --- */
.ARP-scroll-indicator {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translate(-50%, 20px);
    background-color: var(--user-bubble-bg);
    color: white;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 10;
}

    .ARP-scroll-indicator.visible {
        transform: translate(-50%, 0);
        opacity: 1;
        pointer-events: auto;
    }


/* --- Footer Styling --- */
.ARP-footer-info {
    padding: 2px 12px 8px 12px;
    font-size: var(--font-size-sm);
    color: var(--metadata-text-color);
    text-align: center;
    flex-shrink: 0;
    background-color: var(--content-bg-color);
}

/* --- Input Area Layout --- */
.ARP-input-area {
    display: flex;
    padding: 10px;
    border-top: 1px solid var(--border-color);
    background-color: var(--content-bg-color);
    flex-shrink: 0;
    align-items: flex-start;
}

.ARP-input-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.ARP-input-area input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    color: var(--text-color);
    border-radius: 4px;
    padding: 8px;
    font-size: var(--font-size-md);
}

.ARP-input-buttons {
    display: flex;
    flex-shrink: 0;
    margin-left: 8px;
    gap: 8px;
}

.ARP-input-area button {
    padding: 8px 8px;
    border: 1px solid var(--user-bubble-bg);
    background-color: var(--user-bubble-bg);
    color: #ffffff;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

    .ARP-input-area button:disabled {
        background-color: var(--disabled-bg);
        border-color: var(--disabled-border);
        color: var(--disabled-text);
        cursor: not-allowed;
    }

.ARP-secondary-button {
    background-color: var(--assistant-bubble-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    font-weight: normal;
}

#ARPAIChatControl_StopButton {
    background-color: var(--stop-button-bg);
    border-color: var(--stop-button-bg);
    display: none; /* Hidden by default */
}

.ARP-input-area.is-busy #ARPAIChatControl_SendButton {
    display: none;
}

.ARP-input-area.is-busy #ARPAIChatControl_StopButton {
    display: inline-flex; /* Show when busy */
    align-items: center;
    justify-content: center;
}

.ARP-chat-container.dark-mode .ARP-secondary-button {
    color: var(--text-color);
}

/* --- Sample Prompts --- */
.ARP-sample-prompts-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    padding-top: 8px;
    flex-shrink: 0;
}

.ARP-sample-prompt {
    background-color: var(--sample-prompt-bg);
    border: 1px solid var(--sample-prompt-border);
    border-radius: 16px;
    padding: 4px 12px;
    font-size: var(--font-size-sm);
    color: var(--text-color);
    cursor: pointer;
}

    .ARP-sample-prompt:hover {
        background-color: var(--sample-prompt-hover-bg);
    }

/* --- Markdown, Tables, and Charts --- */
.ARP-message-bubble h1,
.ARP-message-bubble h2,
.ARP-message-bubble h3 {
    font-weight: 600;
}

.ARP-message-bubble h1 {
    font-size: 1.25em;
    margin-bottom:0;
}

.ARP-message-bubble h2 {
    font-size: 1.15em;
    margin-bottom:0;
}

.ARP-message-bubble h3 {
    font-size: 1.05em;
    margin-bottom:0;
}
.ARP-message-bubble h4, .ARP-message-bubble h4 strong {
    font-size: 1em;
    margin-bottom:0;
}
.ARP-message-bubble ul,
.ARP-message-bubble ol {
    padding-left: 25px;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}

.ARP-message-bubble li {
    padding-left: 5px;
    margin-bottom: 0;
}

.ARP-data-table,
.ARP-message-bubble table {
    width: 100%;
    margin-top: 12px;
    border-collapse: collapse;
    font-size: var(--font-size-base);
    background-color: var(--table-bg);
    border: 1px solid var(--table-border-color);
    border-radius: 6px;
    overflow: hidden;
}

    .ARP-data-table th,
    .ARP-data-table td,
    .ARP-message-bubble th,
    .ARP-message-bubble td {
        padding: 8px 12px;
        text-align: left;
        border-bottom: 1px solid var(--table-border-color);
        color: var(--text-color);
        border-left: none;
        border-right: none;
        border-top: none;
    }

.ARP-message-bubble th,
.ARP-message-bubble td {
    border-top: 1px solid var(--table-border-color);
}


.ARP-data-table thead th,
.ARP-message-bubble thead th,
.ARP-message-bubble th {
    background-color: var(--table-header-bg);
    font-weight: 600;
}

.ARP-data-table tbody tr:last-child td,
.ARP-message-bubble tbody tr:last-child td {
    border-bottom: none;
}

.ARP-data-table tbody tr:hover,
.ARP-message-bubble tbody tr:hover {
    background-color: var(--table-row-hover-bg);
}

/* Style for chart messages in the standard, non-fullscreen view */
.ARP-chat-container:not(.is-fullscreen) .ARP-assistant-message.has-chart {
    width: 90%;
    margin-right: 12px; /* Adds space on the right side */
}

/* Keep the original width for the more spacious full-screen view */
.ARP-chat-container.is-fullscreen .ARP-assistant-message.has-chart {
    width: 95%;
}

.ARP-chart-wrapper {
    position: relative;
    margin-top: 10px;
    width: 100%;
    min-height: 300px;
    max-height: 300px;
}

/* --- Full Screen Mode Styles --- */
.ARP-backdrop {
    display: none;
    position: absolute;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(4px);
    z-index: 0;
}

.dark-mode .ARP-backdrop {
    background-color: rgba(0, 0, 0, 0.4);
}

.ARP-chat-container.is-fullscreen {
    position: fixed;
    inset: 2rem;
    width: auto !important;
    height: auto !important;
    z-index: 9991;
    overflow: hidden;
    --font-size-base: 14px;
    --font-size-md: 15px;
    --font-size-sm: 13px;
}

    .ARP-chat-container.is-fullscreen .ARP-message-log {
        padding-right: 20px;
    }

    .ARP-chat-container.is-fullscreen .ARP-chat-content {
        max-width: 950px;
        margin: 0 auto;
        padding: 20px;
        box-sizing: border-box;
    }

    .ARP-chat-container.is-fullscreen .ARP-backdrop {
        display: block;
    }

.ARP-icon-button {
    padding: 8px;
    width: 34px;
    height: 34px;
}

    .ARP-icon-button svg {
        width: 18px !important;
        height: 18px !important;
    }

        .ARP-icon-button svg path {
            fill: currentColor;
        }


/* --- Custom Scrollbar (Dark Mode) --- */
.ARP-chat-container.dark-mode ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.ARP-chat-container.dark-mode ::-webkit-scrollbar-track {
    background: var(--content-bg-color);
}

.ARP-chat-container.dark-mode ::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 10px;
    border: 2px solid var(--content-bg-color);
}

    .ARP-chat-container.dark-mode ::-webkit-scrollbar-thumb:hover {
        background-color: var(--table-row-hover-bg);
    }

@media (max-width: 768px) {
  .ARP-assistant-message::before {
  	display: none;
    content: none;
  }  
  .ARP-assistant-message
  {
	margin-left:0;
  }
  .ARP-message-bubble ul, .ARP-message-bubble ol {  
    padding-left: 0px;
    margin-left: 15px;
  }
}