/* ==========================================================================
   CILE CHATBOT STYLES
   ========================================================================== */

/* Font Family
   ========================================================================== */
.cile-chatbot-container,
.cile-chatbot-container * {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;
}

/* Floating Button
   ========================================================================== */
.cile-chatbot-floating-button {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 10000;
    display: block;
    opacity: 1;
    transform: scale(1);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cile-chatbot-floating-button.hide {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.cile-chatbot-toggle {
    width: 64px;
    height: 64px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-primary-color, #1077CB) 0%, var(--chatbot-secondary-color, #0060AD) 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
    padding: 0;
    font-size: 0;
    position: relative;
}

.cile-chatbot-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
    background: linear-gradient(135deg, var(--chatbot-secondary-color, #0060AD) 0%, var(--chatbot-primary-color, #1077CB) 100%);
}

.cile-chatbot-toggle:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(16, 119, 203, 0.4);
}

.cile-chatbot-icon {
    width: 28px;
    height: 28px;
    stroke: currentColor;
    fill: none;
    transition: transform 0.2s ease;
}

.cile-chatbot-toggle:hover .cile-chatbot-icon {
    transform: scale(1.1);
}

.cile-chatbot-loader {
    width: 28px;
    height: 28px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    stroke: currentColor;
    fill: none;
}

/* Main Container
   ========================================================================== */
.cile-chatbot-container {
    width: 450px;
    height: 600px;
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    background-color: white;
    border: 1px solid #e5e7eb;
    margin: 10px 0 !important;
    border-radius: 16px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cile-chatbot-container.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Header
   ========================================================================== */
.cile-chatbot-header {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, var(--chatbot-primary-color, #1077CB) 0%, var(--chatbot-secondary-color, #0060AD) 100%);
    color: white;
    padding: 0 8px 0 16px;
    flex: 0 0 auto;
}

.cile-chatbot-name {
    font-weight: 500;
    font-size: 16px;
}

.cile-chatbot-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    padding-top: 2px;
}

.cile-chatbot-close:hover {
    background-color: var(--chatbot-primary-color, #0060AD);
}

/* WebChat Container
   ========================================================================== */
.cile-chatbot-container #webchat {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
}

/* Transcript Area
   ========================================================================== */
   .cile-chatbot-container .webchat__basic-transcript__transcript {
    padding: 16px 8px 0 8px !important;
    margin: 0 !important;
}

/* Adaptive Cards alignment
   ========================================================================== */


/* User message container - right aligned with max width, adapts to content */
.cile-chatbot-container .webchat__stacked-layout--from-user {
    margin-left: auto !important;
    max-width: 80% !important;
    width: fit-content !important;
    min-width: 0 !important;
}

.cile-chatbot-container .webchat__stacked-layout--from-user .webchat__bubble {
    max-width: 100% !important;
    width: fit-content !important;
    min-width: 0 !important;
}

.cile-chatbot-container .webchat__stacked-layout--from-user .webchat__bubble__content {
    width: fit-content !important;
    min-width: 0 !important;
}

/* Bot message container - left aligned with max width, adapts to content */
.cile-chatbot-container .webchat__stacked-layout:not(.webchat__stacked-layout--from-user) {
    margin-right: auto !important;
    max-width: 80% !important;
    width: fit-content !important;
    min-width: 0 !important;
}

.cile-chatbot-container .webchat__stacked-layout:not(.webchat__stacked-layout--from-user) .webchat__bubble {
    width: 100% !important;
}

.cile-chatbot-container .webchat__stacked-layout:not(.webchat__stacked-layout--from-user) .webchat__bubble__content {
    width: fit-content !important;
    min-width: 0 !important;
}

/* Feedback buttons styling
   ========================================================================== */
/* Feedback Adaptive Card - remove padding and make full width */
.cile-chatbot-container .webchat__stacked-layout__attachment .ac-adaptiveCard {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
}

.cile-chatbot-container .webchat__stacked-layout__attachment .ac-adaptiveCard .ac-container {
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
}

/* Ensure ColumnSet and Columns contain images properly */
.cile-chatbot-container .webchat__stacked-layout__attachment .ac-adaptiveCard .ac-columnSet {
    overflow: visible !important;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
}

.cile-chatbot-container .webchat__stacked-layout__attachment .ac-adaptiveCard .ac-column {
    overflow: visible !important;
    min-width: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Ensure the div wrapper around images has proper sizing */
.cile-chatbot-container .webchat__stacked-layout__attachment .ac-adaptiveCard .ac-column > div {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 24px !important;
    min-height: 24px !important;
}

/* Base styles for feedback images */
.cile-chatbot-container .webchat__stacked-layout__attachment .ac-image {
    cursor: pointer !important;
    opacity: 0.6 !important;
    transition: opacity 0.2s ease, transform 0.2s ease, filter 0.2s ease !important;
    margin: 0 4px !important;
    padding: 2px !important;
    pointer-events: auto !important;
    min-width: 24px !important;
    min-height: 24px !important;
    width: 24px !important;
    height: 24px !important;
}


/* Hover effect - agrandissement et cursor pointer */
.cile-chatbot-container .webchat__stacked-layout__attachment .ac-image:hover {
    opacity: 1 !important;
    transform: scale(1.15) !important;
    cursor: pointer !important;
}

/* Selected state - filled with primary color */
.cile-chatbot-container .webchat__stacked-layout__attachment .ac-image.feedback-selected {
    opacity: 1 !important;
    transform: scale(1.1) !important;
    cursor: default !important;
}

/* Fill the SVG path with primary color when selected - fill the interior */
.cile-chatbot-container .webchat__stacked-layout__attachment .ac-image.feedback-selected svg path {
    fill: var(--chatbot-primary-color, #1077CB) !important;
    stroke: none !important;
    transition: fill 0.2s ease !important;
}

/* Ensure no stroke on SVG paths */
.cile-chatbot-container .webchat__stacked-layout__attachment .ac-image svg path {
    stroke: none !important;
}

/* Disabled state - when one is selected, disable the other */
.cile-chatbot-container .webchat__stacked-layout__attachment .ac-image.feedback-disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

/* Feedback Popover
   ========================================================================== */
.cile-feedback-popover {
    position: fixed;
    background: white;
    border-radius: 8px;
    padding: 12px;
    width: 280px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10001;
    animation: popoverFadeIn 0.2s ease;
    border: 1px solid #e5e7eb;
}

@keyframes popoverFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.cile-feedback-popover-textarea {
    width: 100%;
    min-height: 60px;
    padding: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 13px;
    resize: vertical;
    margin-bottom: 10px;
    box-sizing: border-box;
}

.cile-feedback-popover-textarea:focus {
    outline: none;
    border-color: var(--chatbot-primary-color, #1077CB);
    box-shadow: 0 0 0 2px rgba(16, 119, 203, 0.1);
}

.cile-feedback-popover-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.cile-feedback-popover-cancel,
.cile-feedback-popover-send {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.cile-feedback-popover-cancel {
    background: #f3f4f6;
    color: #1e2939;
}

.cile-feedback-popover-cancel:hover {
    background: #e5e7eb;
}

.cile-feedback-popover-send {
    background: linear-gradient(135deg, var(--chatbot-primary-color, #1077CB) 0%, var(--chatbot-secondary-color, #0060AD) 100%);
    color: white;
}

.cile-feedback-popover-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(16, 119, 203, 0.3);
}

.cile-feedback-popover-send:active {
    transform: translateY(0);
}

/* Send Box
   ========================================================================== */
   .cile-chatbot-container .webchat__send-box__main {
    padding: 0px 8px 0px 16px;
    border-top: 1px solid #f3f4f6;
    display: flex;
    align-items: center !important;
    justify-content: center !important;
}

.webchat__icon-button--stretch {
    height: 100% !important;
    display: flex !important;
    align-items: center !important;

}


.webchat__send-box__button--align-stretch {
    align-self: center !important;
}

.cile-chatbot-container .webchat__send-box__text-box {
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Send Button
   ========================================================================== */
   .cile-chatbot-container .webchat__icon-button {
    position: relative;
    display: flex !important;
    align-items: center !important;
    height: 100% !important;
}

.cile-chatbot-container .webchat__icon-button__shade {
    display:none !important;
}

.cile-chatbot-container .webchat__icon-button:hover .webchat__icon-button__shade,
.cile-chatbot-container .webchat__icon-button:focus .webchat__icon-button__shade,
.cile-chatbot-container .webchat__icon-button:active .webchat__icon-button__shade {
    background-color: rgba(0, 0, 0, 0.06);
}

.cile-chatbot-container .webchat__send-icon {
    width: 24px;
    height: 24px;
    rotate: -6deg;
    position: relative;
    z-index: 1;
}

/* Mobile Responsive
   ========================================================================== */
@media (max-width: 768px) {
    /* Container takes full screen on mobile */
    .cile-chatbot-container {
        width: 100% !important;
        height: 100vh !important;
        max-width: 100% !important;
        max-height: 100vh !important;
        right: 0 !important;
        bottom: 0 !important;
        top: 0 !important;
        left: 0 !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    /* Floating button positioning on mobile */
    .cile-chatbot-floating-button {
        right: 16px;
        bottom: 16px;
    }

    .cile-chatbot-toggle {
        width: 56px;
        height: 56px;
    }

    .cile-chatbot-icon {
        width: 24px;
        height: 24px;
    }

    /* Header adjustments for mobile */
    .cile-chatbot-header {
        height: 56px;
        padding: 0 8px 0 12px;
    }

    .cile-chatbot-name {
        font-size: 15px;
    }

    /* Feedback popover adjustments for mobile */
    .cile-feedback-popover {
        width: calc(100vw - 32px);
        max-width: 320px;
    }
}

/* Reference Links - Prevent line breaks
   ========================================================================== */
   .cile-chatbot-container .webchat__render-markdown__external-link-icon {
    display: none;
}

/* Modern Reference Section Design
   ========================================================================== */
.cile-chatbot-container .webchat__link-definitions__list {
    margin: 4px 0 0 0 !important;
    padding: 0 !important;
    background: transparent !important;
}

.cile-chatbot-container .webchat__link-definitions__list-item {
    margin: 0 0 0 0 !important;
    padding: 0 !important;
    background: transparent !important;
    font-size: 12px !important;
}

.cile-chatbot-container .webchat__link-definitions__list-item-box {
    display: flex !important;
    align-items: center !important;
    padding: 2px 4px !important;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%) !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
    transition: all 0.3s ease !important;
    text-decoration: none !important;
    color: inherit !important;
}

/* Bot message content - grey background */
.cile-chatbot-container .webchat__stacked-layout:not(.webchat__stacked-layout--from-user) .webchat__stacked-layout__content {
    display: flex !important;
    flex-direction: column !important;
    background: #f3f4f6 !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    padding: 10px !important;
    border-radius: 12px !important;
}

/* User message content - primary gradient background */
.cile-chatbot-container .webchat__stacked-layout--from-user .webchat__stacked-layout__content {
    display: flex !important;
    flex-direction: column !important;
    background: linear-gradient(135deg, var(--chatbot-primary-color, #1077CB) 0%, var(--chatbot-secondary-color, #0060AD) 100%) !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    padding: 12px !important;
    border-radius: 12px !important;
    color: white !important;
}

/* Text content - flex column with gap */
.cile-chatbot-container .webchat__text-content {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
}

.cile-chatbot-container .webchat__link-definitions__list-item-box:hover {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%) !important;
    border-color: #cbd5e1 !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1) !important;
    transform: translateY(-1px) !important;
}

.cile-chatbot-container .webchat__link-definitions__list-item-body {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    gap: 8px !important;
}

.cile-chatbot-container .webchat__link-definitions__badge {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 28px !important;
    height: 28px !important;
    background: linear-gradient(135deg, var(--chatbot-primary-color, #1077CB) 0%, var(--chatbot-secondary-color, #0060AD) 100%) !important;
    color: white !important;
    border-radius: 999px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    border: none !important;
}

.cile-chatbot-container .webchat__link-definitions__list-item-body-main {
    flex: 1 !important;
    min-width: 0 !important;
}

.cile-chatbot-container .webchat__link-definitions__list-item-main-text {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

.cile-chatbot-container .webchat__link-definitions__list-item-text {
    color: #1e293b !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    text-decoration: none !important;
    flex: 1 !important;
    min-width: 0 !important;
    word-break: break-word !important;
}

.cile-chatbot-container .webchat__link-definitions__open-in-new-window-icon {
    width: 16px !important;
    height: 16px !important;
    color: #64748b !important;
    flex-shrink: 0 !important;
    transition: color 0.2s ease !important;
}

.cile-chatbot-container .webchat__link-definitions__list-item-box:hover .webchat__link-definitions__open-in-new-window-icon {
    color: var(--chatbot-primary-color, #1077CB) !important;
}