/**
 * ChatV2 Modal Styles
 * 
 * This file contains styles for the ChatV2 modal overlay and container.
 * These styles are loaded directly (NOT bundled/minified) to ensure they're
 * available immediately when the modal is triggered.
 * 
 * DO NOT include this file in BundleConfig.cs
 */

/* Modal Container - Slide-in from right */
.modal2 {
    position: fixed;
    top: 0;
    right: -90%; /* Adjust this value to the width of your modal */
    width: 90%; /* Adjust this value to your desired modal width */
    /*height: 100vh;*/ /* Full height of the viewport */
    height: calc(var(--vh, 1vh) * 100);
    background-color: white;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    transition: right 0.5s ease;
    display: flex;
    flex-direction: column;
}

.modal2.show {
    right: 0;
    display: block;
    z-index: 111;
}

/* Mobile: Full width modal */
@media (max-width: 999px) {
    .modal2 {
        width: 100vw; /* Full width on mobile */
        right: -100vw; /* Slide from fully off screen */
    }

    .chat-close {
        top: 64px !important;
        right: 13px !important;
    }

    .modal2.show {
        top: 50px; /* Below mobile header */
    }
}

/* Legacy support for older breakpoint */
@media (max-width: 768px) {
    .modal2.show {
        width: 100vw; /* Full width of the viewport */
    }
}

/* Modal Content Overrides */
#aiChatModal > .modal-content {
    padding: 0 !important;
    border-radius: 0 !important;
}

.modal-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    height: 100%; /* Ensure the content takes up the full height */
    box-sizing: border-box; /* Include padding in height calculation */
}

.modal-close {
    position: absolute;
    top: 20px;
    left: 20px;
    cursor: pointer;
    display: block;
    background-color: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #888;
}

/* Modern CSS-based loading animation for modal */
.chat-loading-container {
    display: flex;
    height: 100%;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

.chat-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.chat-loading-text {
    font-size: 23px;
    font-weight: 600;
    color: #6b7280;
}

.chat-loading-dots {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    height: 20px;
}

.chat-loading-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    animation: chat-loading-pulse 1.4s ease-in-out infinite;
    will-change: transform, opacity;
}

.chat-loading-dot:nth-child(1) {
    animation-delay: 0s;
}

.chat-loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes chat-loading-pulse {
    0% {
        transform: scale(0.6);
        opacity: 0.3;
    }
    50% {
        transform: scale(1.3);
        opacity: 1;
    }
    100% {
        transform: scale(0.6);
        opacity: 0.3;
    }
}

/* Ensure loading is visible during modal opening */
.modal2:not(.modal2-ready) .chat-loading-container {
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
}

.modal2:not(.modal2-ready) .chat-loading-dot {
    animation-play-state: running !important;
}

.chat-loading-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    text-align: center;
}

.chat-loading-error p:first-child {
    font-size: 18px;
    font-weight: 600;
    color: #dc3545;
    margin-bottom: 1rem;
}

.chat-loading-error p:last-of-type {
    color: #666;
    margin-bottom: 1.5rem;
}

/* Response Loading Animation */
.chat-response-loading-container {
    display: flex;
    justify-content: center;
    padding-top: 16px;
}

.chat-response-loading-container > div:first-of-type {
    display: flex;
    align-items: center;
    color: #333333;
    justify-content: center;
    height: 30px;
    padding-bottom: 16px;
}

.chat-response-loading-container .cancel-request-wrap {
    text-align: center;
}

.chat-response-loading-container .cancel-request-wrap a,
.chat-response-loading-container .cancel-request-wrap a:link,
.chat-response-loading-container .cancel-request-wrap a:visited,
.chat-response-loading-container .cancel-request-wrap a:hover,
.chat-response-loading-container .cancel-request-wrap a:active {
    color: #0084ff;
}

/* Chat Container Base Styles */
.chat-container {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    background-color: #f9f9f9;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    box-sizing: border-box;
    padding-top: 50px;
}

.chat-header {
    background-color: #fff;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    box-shadow: 0 4px 20px -16px;
    justify-content: space-between;
    padding: 6px;
}

.message-action-buttons {
    padding: 0 10px;
}

.copy-icon {
    background-color: transparent;
}

.copy-icon:hover {
    background-color: #e3e3e3;
}

.copy-icon:active {
    -webkit-box-shadow: none !important;
    box-shadow: none !important;
}

.copy-icon:active > i::before {
    font-weight: 900 !important;
}

.message-action-buttons > button {
    outline: none !important;
}

span.first-message {
    margin-top: 16px;
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    display: flex;
    gap: 16px;
    margin-bottom: 8px;
    padding-left: 16px;
    align-items: flex-end;
}

/* Chat Close Button */
.chat-close {
    font-size: 20px !important;
    height: 28px;
    width: 28px;
    padding: 0 !important;
    -webkit-appearance: none;
    border: 0 !important;
    margin-bottom: auto !important;
    color: #fff;
    border-radius: 3px !important;
    font-family: inherit;
    box-sizing: border-box;
    outline: none;
    position: absolute;
    top: 56px;
    right: 28px;
    z-index: 1;
}

@media (min-width: 1000px) {
    .chat-container {
        padding-top: 0;
    }

    .chat-close {
        top: 20px;
    }
}

/* AI Logo Images */
.ai-logo-image {
    width: 64px;
    height: 64px;
}

.ai-logo-image-static {
    width: 40px;
    height: 40px;
    margin-right: 4px;
}

.intelligence-logo {
    width: 40px;
    height: 40px;
}

/* Chat History/Messages Area */
.chat-history {
    flex-grow: 1;
    padding: 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    scrollbar-gutter: stable;
}

/* Chat Bubbles */
.chat-bubble {
    max-width: 80%;
    padding: 10px;
    border-radius: 20px;
    line-height: 24px;
    font-size: 16px;
    word-break: break-word;
    margin: 5px 0;
    position: relative;
}

.chat-bubble.left {
    align-self: flex-start;
    background-color: none;
    max-width: 100%;
    padding: 10px 10px 0;
    margin: 5px 0 0;
}

.chat-bubble.right {
    align-self: flex-end;
    background-color: #0084ff;
}

.chat-bubble.terms-and-privacy-bubble {
    align-self: center;
    padding: 10px 20px;
    margin-bottom: 10px;
}

.chat-bubble.terms-and-privacy-bubble a {
    text-decoration: underline;
}

/* Chat Input Container */
.chat-input-container {
    flex-shrink: 0;
    padding: 20px 30px 10px;
    background-color: #fff;
    /*display: flex;*/
    align-items: center;
    border-top: 1px solid #ddd;
    box-shadow: 0 4px 20px -8px;
}

.chat-input-placement {
    width: 100%;
    display: flex;
    border-radius: 24px;
    padding: 7px 9px;
    width: 100%;
    display: flex;
    border: 2px solid #fff;
}

.chat-input {
    flex-grow: 1;
    width: 100%;
    flex: 1 1;
    height: 40px;
    padding: 10px 12px;
    border: none;
    border-radius: 16px;
    outline: none;
    overflow-y: hidden;
    resize: none;
    min-height: 40px;
}

/* Send Button */
.chat-send-button {
    background-color: #0084ff;
    color: white;
    border: none;
    padding: 10px 20px;
    margin-left: 10px;
    border-radius: 20px;
    cursor: pointer;
    height: 40px;
}

.chat-send-button > i.fa-arrow-up {
    margin-left: 0 !important;
}

/* Add style for .chat-send-button with disabled attribute */
.chat-send-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Citations Container */
.citations-container {
    margin-top: 5px;
    padding: 10px;
    background-color: #f8f8f8;
    border-radius: 5px;
    font-size: 0.9em;
}

.cancel-request-button {
    -webkit-appearance: none;
    background: #dfe6f1;
    border: 0;
    border-radius: 3px;
    color: inherit;
    color: #1269cf;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 400;
    line-height: 1;
    margin: 0;
    padding: 7px 6px;
}

.citations-container h4 {
    margin-top: 0;
    margin-bottom: 5px;
}

.citations-container ul {
    margin: 0;
    padding-left: 20px;
}

.citations-container a {
    color: #0066cc;
    text-decoration: none;
}

.citations-container a:hover {
    text-decoration: underline;
}
