/* Dx Chat Teaser Styles */

.dx-chat-widget {
    font-family: Arial, sans-serif;
    position: relative;
}

.dx-chat-container {
    display: flex;
    flex-direction: column;
    background-color: transparent;
    height: auto;
    min-height: 80px;
    max-width: 100%;
    overflow: visible;
    transition: all 0.3s ease;
}

.dx-chat-container.expanded {
    height: 400px;
    overflow: hidden;
}

.dx-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    opacity: 0;
    max-height: 0;
    transition: all 0.3s ease;
}

.dx-chat-container.expanded .dx-chat-messages {
    opacity: 1;
    max-height: 350px;
}

.dx-chat-messages.has-messages {
    box-shadow: inset 0 -10px 15px -10px rgba(0, 0, 0, 0.1);
}

.dx-chat-message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 18px;
    word-wrap: break-word;
    animation: fadeInUp 0.3s ease-out;
}

.dx-chat-message.user {
    align-self: flex-end;
    background-color: #1d7885;
    color: white;
    border-bottom-right-radius: 5px;
}

.dx-chat-message.ai {
    align-self: flex-start;
    background-color: #f1f1f1;
    color: #333333;
    border-bottom-left-radius: 5px;
}

/* Legacy styles - moved to updated section below */

.dx-chat-input:focus {
    border-color: #1d7885;
}

/* Legacy send button styles - moved to updated section below */

.dx-chat-send-btn:hover {
    background-color: #005a87;
}

.dx-chat-send-btn:active {
    transform: translateY(0);
}

.dx-chat-send-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
    transform: translateY(-50%)!important;
}

.dx-chat-send-btn i {
    font-size: 14px;
}

/* Compound Q&A Messages */
.dx-chat-compound-message {
    max-width: 100%;
    width: 100%;
    margin-bottom: 15px;
    border-radius: 12px;
    overflow: visible;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    animation: fadeInUp 0.3s ease-out;
}

.dx-chat-question {
    background-color: #fff;
    color: #1d7885;
    padding: 12px 16px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    border-radius: 12px 12px 0 0;
    border: 1px solid #efefef;
}

.dx-question-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: #D9F4F9;
    border-radius: 50rem;
}

.dx-question-icon i {
    color: #1d7885;
    font-family: Noto Sans, sans-serif;
    font-size: 18px;
    font-weight: 700;
    line-height: 24px;
}

.dx-question-icon img {
    width: 100%;
    height: 100%;
    max-width: 100px;
    max-height: 100px;
    object-fit: contain;
}

.dx-question-text {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
    color: #1d7885;
    text-transform: capitalize;
}

.dx-chat-answer {
    background-color: #ffffff;
    color: #333;
    padding: 16px;
    line-height: 1.6;
    min-height: auto;
    overflow: visible;
    word-wrap: break-word;
    overflow-wrap: break-word;
    border-radius: 0 0 12px 12px;
}

/* Markup styling in messages */
.dx-chat-message h1, .dx-chat-message h2, .dx-chat-message h3,
.dx-chat-answer h1, .dx-chat-answer h2, .dx-chat-answer h3 {
    margin: 12px 0 8px 0;
    font-weight: 600;
    color: #1d7885;
}

.dx-chat-message h1, .dx-chat-answer h1 {
    font-size: 1.4em;
}

.dx-chat-message h2, .dx-chat-answer h2 {
    font-size: 1.2em;
}

.dx-chat-message h3, .dx-chat-answer h3 {
    font-size: 1.1em;
    margin: 10px 0;
}

.dx-chat-message strong,
.dx-chat-answer strong {
    font-weight: 600;
}

.dx-chat-message em,
.dx-chat-answer em {
    font-style: italic;
    color: #666;
}

.dx-chat-message code,
.dx-chat-answer code {
    background-color: #f1f1f1;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #d63384;
    border: 1px solid #e9ecef;
}

.dx-chat-message ul,
.dx-chat-answer ul {
    margin: 10px 0;
    padding-left: 20px;
}

.dx-chat-message ol,
.dx-chat-answer ol {
    margin: 10px 0;
    padding-left: 20px;
}

.dx-chat-message li,
.dx-chat-answer li {
    margin-bottom: 6px;
    line-height: 1.5;
}

.dx-chat-message p,
.dx-chat-answer p {
    margin: 8px 0;
    line-height: 1.6;
}

.dx-chat-message blockquote,
.dx-chat-answer blockquote {
    border-left: 4px solid #1d7885;
    padding-left: 12px;
    margin: 12px 0;
    font-style: italic;
    color: #666;
    background-color: #f8f9fa;
    padding: 8px 12px;
    border-radius: 0 4px 4px 0;
}

.dx-chat-message a,
.dx-chat-answer a {
    color: #1d7885;
    text-decoration: underline;
}

.dx-chat-message a:hover,
.dx-chat-answer a:hover {
    color: #005a87;
}

/* T&C Notice */
.dx-chat-tc-notice {
    padding: 8px 15px;
    font-size: 11px;
    color: #666;
    text-align: center;
    line-height: 1.4;
}

/* Animation keyframes */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.4;
    }
    50% {
        opacity: 1;
    }
}

/* Loading indicator */
.dx-chat-loading {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 15px;
    align-self: flex-start;
    max-width: 80%;
    color: #666;
    font-size: 14px;
}

.dx-chat-loading-dots {
    display: flex;
    gap: 3px;
}

.dx-chat-loading-dot {
    width: 6px;
    height: 6px;
    background-color: #1d7885;
    border-radius: 50%;
    animation: pulse 1.4s infinite ease-in-out;
}

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

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

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

/* Markdown Heading Styles */
@media (min-width: 768px) {
    .markdownHeading {
        font-size: 16px;
        font-weight: 400;
        font-family: Noto Sans, sans-serif !important;
    }

    .markdownHeading pre, .markdownHeading code, .markdownHeading p, .markdownHeading span, .markdownHeading li {
        font-size: 16px !important;
        font-weight: 400;
        font-family: Noto Sans, sans-serif !important;
        color: #444242;
    }

    .markdownHeading strong {
        font-size: 16px !important;
        font-weight: 600;
        font-family: Noto Sans, sans-serif !important;
    }
}

.markdownHeading table {
    table-layout: fixed;
    width: 100%;
}

.markdownHeading table thead, .markdownHeading table tbody, .markdownHeading table tfoot, .markdownHeading table tr, .markdownHeading table td, .markdownHeading table th {
    border-width: 1px !important;
    padding: 5px;
    color: #1d1919;
}

.markdownHeading table thead {
    background-color: #efefef;
}

.markdownHeading h1, .markdownHeading .h1, .markdownHeading h2, .markdownHeading .h2, .markdownHeading h3, .markdownHeading .h3, .markdownHeading h4, .markdownHeading .h4, .markdownHeading h5, .markdownHeading .h5, .markdownHeading h6, .markdownHeading .h6 {
    margin: 2.5rem 0 1rem 0 !important;
    font-weight: 600;
    color: #1d1919;
}

/* Remove top margin for first heading in dx-chat-answer */
.dx-chat-answer .markdownHeading h1:first-child, 
.dx-chat-answer .markdownHeading h2:first-child, 
.dx-chat-answer .markdownHeading h3:first-child, 
.dx-chat-answer .markdownHeading h4:first-child, 
.dx-chat-answer .markdownHeading h5:first-child, 
.dx-chat-answer .markdownHeading h6:first-child {
    margin-top: 0 !important;
}

/* More specific rule - remove top margin for first heading regardless of position */
.dx-chat-answer h1:first-of-type,
.dx-chat-answer h2:first-of-type,
.dx-chat-answer h3:first-of-type,
.dx-chat-answer h4:first-of-type,
.dx-chat-answer h5:first-of-type,
.dx-chat-answer h6:first-of-type {
    margin-top: 0 !important;
}

/* Ultra-specific rule to override any heading margin at the start of answers */
.dx-chat-answer > *:first-child h1,
.dx-chat-answer > *:first-child h2,
.dx-chat-answer > *:first-child h3,
.dx-chat-answer > *:first-child h4,
.dx-chat-answer > *:first-child h5,
.dx-chat-answer > *:first-child h6,
.dx-chat-answer > h1,
.dx-chat-answer > h2,
.dx-chat-answer > h3,
.dx-chat-answer > h4,
.dx-chat-answer > h5,
.dx-chat-answer > h6 {
    margin-top: 0 !important;
}

.markdownHeading li, .markdownHeading p, .markdownHeading pre, .markdownHeading code {
    line-height: 24px;
    margin-bottom: 24px;
    color: #1d1919;
}

.markdownHeading ol, .markdownHeading ul {
    margin-bottom: 0;
    color: #1d1919;
}

.markdownHeading h1, .markdownHeading .h1, .markdownHeading h2, .markdownHeading .h2, .markdownHeading h3, .markdownHeading .h3, .markdownHeading h4, .markdownHeading .h4 {
    line-height: normal !important;
}

@media (min-width: 768px) {
    .markdownHeading h1, .markdownHeading .h1, .markdownHeading h2, .markdownHeading .h2, .markdownHeading h3, .markdownHeading .h3, .markdownHeading h4, .markdownHeading .h4 {
        font-size: 16px !important;
    }
}

@media (max-width: 767px) {
    .markdownHeading h1, .markdownHeading .h1, .markdownHeading h2, .markdownHeading .h2, .markdownHeading h3, .markdownHeading .h3, .markdownHeading h4, .markdownHeading .h4 {
        font-size: 14px !important;
    }
}

.markdownHeading ol, .markdownHeading ul {
    padding-left: 24px !important;
}

/* Citation Tooltips */
.sourcesCitation {
    display: inline-block;
    cursor: pointer;
    position: relative;
    margin: 0 2px;
    vertical-align: baseline;
    user-select: none;
}

.sourcesCitation:hover citation {
    background-color: #d1e7ea;
    border-color: #155963;
    transform: scale(1.05);
    transition: all 0.2s ease;
}

.sourcesCitation:hover::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    font-weight: normal;
    animation: tooltipFadeIn 0.2s ease;
}

.sourcesCitation:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #333;
    z-index: 1000;
}

.sourcesCitation citation {
    font-family: Noto Sans, sans-serif !important;
    margin: 0;
    box-sizing: border-box;
    font-size: 13px !important;
    font-weight: 400;
    line-height: 20px;
    color: #1d1d1d;
    border-radius: 5px;
    cursor: pointer;
    padding: 1px 8px;
    background: #e4f0f0;
    border: 1px solid #1d7885;
    font-style: normal;
    display: inline-block;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Question Icon Styling - Removed */

/* Input Wrapper */
.dx-chat-input-wrapper {
    padding: 10px;
    width: 100%;
}

/* Updated Input Container and Input Styling */
.dx-chat-input-container {
    display: flex;
    padding: 15px;
    background-color: white;
    gap: 0;
    align-items: flex-end;
    position: relative;
    min-height: 80px;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin: 0 auto;
    width: 100%;
    transition: all 0.3s ease;
}

.dx-chat-input {
    flex: 1;
    padding: 12px 60px 12px 15px;
    border: none;
    border-radius: 10px;
    outline: none;
    font-size: 15px;
    background-color: white;
    transition: all 0.3s ease;
    margin-right: 0;
    min-height: 48px;
    max-height: 120px;
    resize: none;
    overflow-y: auto;
    line-height: 1.4;
    font-family: inherit;
    box-sizing: border-box;
}

.dx-chat-input:focus, .dx-chat-input:active {
    border-color: #1d7885!important;
}

.dx-chat-send-btn {
    padding: 10px 18px;
    background-color: #1d7885;
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: auto;
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    height: 36px;
    z-index: 2;
}

.dx-chat-send-btn.icon-only {
    padding: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    justify-content: center;
}

/* Responsive styles */
@media (max-width: 768px) {
    .dx-chat-compound-message {
        max-width: 100%;
        width: 100%;
    }
    
    .dx-chat-message {
        max-width: 90%;
    }
    
    .dx-chat-input {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px 55px 12px 15px;
        min-height: 44px;
    }
    
    .dx-chat-input-wrapper {
        padding: 8px;
    }
    
    .dx-chat-input-container {
        padding: 12px;
        min-height: 70px;
        margin: 0 auto;
        border-radius: 12px;
    }
    
    .dx-question-icon {
        width: 32px;
        height: 32px;
        background: #D9F4F9;
        border-radius: 50rem;
    }
    
    .dx-question-icon i {
        font-size: 16px;
        color: #1d7885;
    }
    
    .dx-question-icon img {
        width: 18px;
        height: 18px;
    }
    
    .dx-chat-question {
        font-size: 16px;
        padding: 10px 12px;
    }
    
    .dx-chat-send-btn {
        height: 32px;
        right: 15px;
    }
    
    .dx-chat-send-btn.icon-only {
        width: 32px;
        height: 32px;
    }
    
    .dx-chat-question {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .dx-chat-answer {
        padding: 12px;
        font-size: 14px;
    }
}

.dx-chat-loading-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #999;
    animation: loadingDot 1.4s infinite ease-in-out both;
}

.dx-chat-loading-dot:nth-child(1) { animation-delay: -0.32s; }
.dx-chat-loading-dot:nth-child(2) { animation-delay: -0.16s; }

/* Error message */
.dx-chat-error {
    align-self: center;
    background-color: #fee;
    color: #c33;
    border: 1px solid #fcc;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 14px;
    max-width: 90%;
    text-align: center;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes loadingDot {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Scrollbar styling */
.dx-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.dx-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.dx-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.dx-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive design */
@media (max-width: 768px) {
    .dx-chat-container {
        height: 350px;
    }
    
    .dx-chat-message {
        max-width: 90%;
    }
    
    .dx-chat-input-container {
        padding: 10px;
    }
    
    .dx-chat-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .dx-chat-send-btn {
        padding: 10px 15px;
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .dx-chat-container {
        height: 300px;
    }
    
    .dx-chat-messages {
        padding: 10px;
    }
    
    .dx-chat-input-container {
        flex-direction: column;
        gap: 8px;
    }
    
    .dx-chat-input {
        width: 100%;
    }
    
    .dx-chat-send-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Typewriter Animation */
@keyframes typewriter {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    0%, 50% {
        border-color: transparent;
    }
    51%, 100% {
        border-color: #1d7885;
    }
}

/* Skeleton Loading Animation */
@keyframes skeleton-loading {
    0% {
        background-position: -400px 0;
    }
    100% {
        background-position: calc(400px + 100%) 0;
    }
}

/* Input Container Transition */
@keyframes slideToBottom {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(calc(100vh - 120px));
    }
}

/* Typewriter Effect for Input Placeholder */
.dx-chat-input.typewriter-effect::placeholder {
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid #1d7885;
    animation: blink 1s infinite;
}

/* Skeleton Loading for Messages */
.dx-chat-messages.skeleton-loading {
    position: relative;
}

.dx-chat-messages.skeleton-loading .skeleton-message {
    max-width: 100%;
    margin: 10px 0;
    background: #ffffff;
    border-radius: 12px 12px 0 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    animation: fadeInUp 0.3s ease-out;
}

.dx-chat-messages.skeleton-loading .skeleton-question {
    background-color: #fff;
    color: #1d7885;
    padding: 12px 16px;
    font-weight: 600;
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    min-height: 50px;
}

.dx-chat-messages.skeleton-loading .skeleton-answer {
    padding: 15px 20px;
    background-color: #f8f9fa;
    min-height: 80px;
    position: relative;
    overflow: hidden;
}

.dx-chat-messages.skeleton-loading .skeleton-answer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, #f5f5f5 40%, #e8e8e8 50%, #f5f5f5 60%);
    background-size: 400px 100%;
    animation: skeleton-loading 3s ease-in-out infinite;
}

/* Input Wrapper Slide Animation */
.dx-chat-input-wrapper.sliding-to-bottom {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    z-index: 1000;
    animation: slideToBottom 0.5s ease-out forwards;
}
