body {
    margin: 0;
    font-family: "Proxima Nova", serif;
    background: #F5F5F5;
}

/* --- MOBILE BACK BUTTON --- */
.chat-mobile-back {
    display: none;
}

/* AEM Edit Mode */
html.aem-AuthorLayer-Edit .chat-wrapper {
    width: 90% !important;
    max-width: 1358px !important;
    height: 850px !important;
    margin: 20px auto !important;
    overflow: hidden !important;
}

html.aem-AuthorLayer-Edit .chatbot-container,
html.aem-AuthorLayer-Edit .chatbot-messages-wrapper,
cq-Overlay--component {
    height: 850px !important;
}

html.aem-AuthorLayer-Edit .chatbot-messages {
    overflow-y: auto !important;
}

/* ============================================
   CHAT WRAPPER
   ============================================ */

.chat-wrapper {
    width: 100%;
    max-width: 1358px;
    height: calc(100vh - 40px);
    background: #FFFFFF;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    margin: 20px auto;
    overflow: hidden;
}

.chat-wrapper.has-history {
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

/* ============================================
   BANNER
   ============================================ */

.chat-banner {
    width: 100%;
    height: 80px;
    background: #FFFFFF;
    box-shadow: 0px 0px 10px 0px #33333340;
    display: flex;
    align-items: center;
    padding: 20px 115px;
    gap: 10px;
    box-sizing: border-box;
    margin-bottom: 20px;
}

.chat-banner img {
    height: 40px;
    object-fit: contain;
    max-width: 100%;
}

/* ============================================
   MAIN CHAT
   ============================================ */

.chat-main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #F5F5F5;
}

.chat-wrapper.has-history .chat-main {
    padding: 0 20px 0 20px;
}

/* ============================================
   CHATBOT
   ============================================ */

.chatbot-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-self: center;
    width: 100%;
    max-width: 1128px;
    min-height: 0;
    overflow: hidden;
}

.chatbot-messages-wrapper {
    flex: 1;
    overflow: hidden;
    display: flex;
    min-height: 0;
}

.chatbot-messages {
    background: #F5F5F5;
    flex: 1;
    overflow-y: auto;
    padding-right: 20px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    min-height: 0;
}

.chatbot-messages.expert-mode {
    display: flex;
}

.chat-wrapper.has-history .chatbot-messages {
    padding-bottom: 20px !important;
}

/* ============================================
   MESSAGES
   ============================================ */

.message.user {
    display: inline-block;
    max-width: 70%;
    padding: 16px;
    margin: 6px 0;
    border-right: 4px solid #BD3826;
    font-size: 16px;
    color: #000;
    align-self: flex-end;
    border-radius: 2px 0 0 2px;
    border-right: 4px solid #B12431;
    background: #FFF;
    box-shadow: 0 0 28px 0 rgba(144, 144, 144, 0.10);
}

.message.bot {
    display: inline-block;
    max-width: 80%;
    padding: 16px;
    margin: 6px 0;
    align-self: flex-start;
    color: #212529;
    font-family: "Proxima Nova", serif;
    font-size: 14px;
    font-style: normal;
    font-weight: 400;
    line-height: 20px;
}

.chatbot-waiting-phrase {
    margin-bottom: 4px;
    font-style: italic;
    text-align: left;
    padding-left: 8px;
    align-self: flex-start;
    max-width: 80%;
    opacity: 0.9;
    color: #6C757D;
    font-family: "Proxima Nova", serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 20px; /* 142.857% */
}

/* ============================================
   INPUT AREA
   ============================================ */

.chatbot-input {
    display: flex;
    gap: 8px;
    box-sizing: border-box;
    margin: 20px 0 0 0;
    flex-shrink: 0;
    height: auto;
    min-height: 65px;
    max-height: 50vh;
    align-items: flex-end;
}

.chatbot-left-group {
    flex: 1 1 auto;
    display: flex;
    min-width: 0;
    height: auto;
    align-items: flex-end;
}

.chatbot-input-box {
    flex: 1 1 auto;
    display: flex;
    box-sizing: border-box;
    min-width: 0;
    color: #6C757D;
    font-family: "Proxima Nova", serif;
    font-size: 14px;
    font-style: normal;
    font-weight: 400;
    line-height: 20px;
    border-radius: 2px;
    background: #FFF;
    box-shadow: 0 0 28px 0 rgba(144, 144, 144, 0.10);
    height: auto;
    min-height: 65px;
    max-height: 50vh;
    align-items: flex-end;
    padding: 12px 12px;
    gap: 8px;
    overflow: hidden;
}

.chatbot-input-box input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
    outline: none;
    height: 100%;
}

.chatbot-voice-record {
    margin: 8px 8px;
    padding: 8px 0;
    gap: 16px;
    align-self: end;
}

.chatbot-voice-record img {
    width: 24px;
    height: 24px;
    max-width: 24px;
    max-height: 24px;
    object-fit: contain;
    display: block;
}

.chatbot-voice-record:active img,
.chatbot-voice-record img:active {
    transform: none !important;
    scale: 1 !important;
}

.chatbot-voice-record.is-recording img {
    width: 24px;
    height: 24px;
    max-width: 24px;
    max-height: 24px;
}

.chatbot-send-button {
    display: flex;
    width: 41px;
    height: 41px;
    padding: 8px;
    align-items: center;
    gap: 10px;
    border-radius: 2px;
    background: #6C757D;
    margin: 8px 8px;
}

.chatbot-send-button img {
    width: 24px;
    height: 24px;
    max-width: 24px;
    max-height: 24px;
    object-fit: contain;
    display: block;
}

.chatbot-initial-question {
    margin: 20px 0;
    font-weight: 700;
    align-self: center;
    color: #333;
    text-align: center;
    font-family: "Proxima Nova", serif;
    font-size: 24px;
    font-style: normal;
    line-height: normal;
}

.chatbot-enabled input,
.chatbot-enabled .chatbot-send-button,
.chatbot-enabled .chatbot-voice-record {
    opacity: 1;
    pointer-events: auto;
}

.chatbot-disabled input,
.chatbot-disabled .chatbot-send-button,
.chatbot-disabled .chatbot-voice-record {
    opacity: 0.6;
    pointer-events: none;
}

/* --- INPUT EXPERT --- */

.expert-input .chatbot-input {
    margin-bottom: unset;
    margin-top: 20px;
}

.expert-input .chatbot-input-box {
    flex: 1;
    display: flex;
    padding: 0 12px;
    background: #FFF;
    box-sizing: border-box;
    gap: 16px;
    height: auto !important;
    min-height: 64px;
    max-height: 50vh;
    align-items: flex-end !important;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
}

.expert-input .chatbot-input-box input {
    flex: 1;
    height: 100%;
    border: none;
    background: transparent;
    font-size: 16px;
    outline: none;
}

.expert-input .chatbot-voice-record {
    display: flex;
    padding: 8px;
    justify-content: center;
    align-items: center;
    gap: 10px;
    border-radius: 2px;
    background: #FFF;
    flex-shrink: 0;
    height: 41px !important;
    align-self: flex-end;
    margin-bottom: 4px;
}

.expert-input .chatbot-voice-record img {
    width: 100%;
    height: 100%;
    max-width: 24px;
    max-height: 24px;
    object-fit: contain;
}

.expert-input .chatbot-send-button {
    display: flex;
    padding: 8px;
    justify-content: center;
    align-items: center;
    gap: 10px;
    border-radius: 2px;
    background: #6C757D;
    flex-shrink: 0;
    height: 41px !important;
    align-self: flex-end;
    margin-bottom: 4px;
}

.expert-input .chatbot-send-button img {
    width: 100%;
    height: 100%;
    max-width: 24px;
    max-height: 24px;
    object-fit: contain;
}

.chatbot-send-button,
.chatbot-send-button:focus,
.chatbot-send-button:active {
    outline: none !important;
    border: none !important;
}

.chatbot-input-box textarea,
.expert-input .chatbot-input-box textarea {
    flex: 1 1 auto;
    align-self: stretch;
    border: none;
    background: transparent;
    outline: none;
    resize: none;
    width: 100%;
    min-width: 0;
    min-height: 41px;
    overflow-y: auto;
    font-family: "Proxima Nova", serif;
    font-size: 16px;
    line-height: 24px;
    padding: 8px 0;
    margin: 0;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-break: break-word;
    display: block;
    max-height: calc(50vh - 24px);
    max-width: 100%;
}

.chatbot-enabled textarea {
    opacity: 1;
    pointer-events: auto;
    align-content: center;
}
.chatbot-disabled textarea {
    opacity: 0.6;
    pointer-events: none;
    align-content: center;
}

/* ============================================
   SIDEBAR HISTORY
   ============================================ */

.chat-history {
    display: none;
    flex: 0 0 327px;
    width: 327px;
    background: #F5F5F5;
    box-sizing: border-box;
    overflow: hidden;
    flex-direction: column;
}

.chat-wrapper.has-history .chat-history {
    display: flex;
}


.chat-history-header {
    display: flex;
    padding: 24px 16px;
    align-items: center;
    align-self: stretch;
    background: #FFF;
    box-shadow: 0 0 10px 0 rgba(51, 51, 51, 0.10);
}

.chat-history-title {
    margin: 0;
    font-weight: 600;
    color: #333;
    font-family: "Proxima Nova", serif;
    font-size: 14px;
    font-style: normal;
    line-height: normal;
}

.chat-history-content {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-radius: 2px;
    background: #EAEEF0;
    box-shadow: 0 0 10px 0 rgba(51, 51, 51, 0.10);
    min-width: 0;
    overflow: hidden;
}

.chat-history-list {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-radius: 2px;
    background: #EAEEF0;
    min-width: 0;
    overflow: hidden;
}

.chat-history-item {
    all: unset;
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 10px 0 16px 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    border-bottom: 1px solid #DEDEDE;
    color: #333;
    font-family: "Proxima Nova", serif;
    font-size: 14px;
    font-style: normal;
    font-weight: 600;
    line-height: 20px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history-item:hover {
    background: transparent !important;
}

.chat-history-item.active {
    border-color: #B12431;
}

.chat-history-newchat {
    display: flex;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0 0 12px 0;
    align-self: stretch;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 41px;
    padding: 14px 12px;
    justify-content: center;
    align-items: center;
    gap: 8px;
    border-radius: 2px;
    background: #B12431;
    color: #EAEEF0;
    text-align: center;
    font-family: "Proxima Nova", serif;
    font-size: 14px;
    font-style: normal;
    font-weight: 600;
    line-height: normal;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    border-bottom-width: unset;
    border-color: transparent;
}

.expert-mode .chat-history-list {
    display: flex;
    flex-direction: column;
}

.expert-mode .chat-history-newchat {
    margin-top: auto;
}

.chat-mobile-bar {
    background: #F5F5F5;
    display: none;
}

.chat-history-overlay {
    display: none;
}

/* ============================================
   FILTERS
   ============================================ */

.chat-filters {
    display: flex;
    align-items: center;
    margin: 12px 0 12px;
}

.chat-filters-label {
    color: #333;
    font-family: "Proxima Nova", Arial, sans-serif;
    font-size: 14px;
    font-style: normal;
    font-weight: 600;
    line-height: normal;
}

.chat-filters-chips {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: 16px;
}

.chat-filter {
    display: flex;
    padding: 12px 8px;
    justify-content: center;
    align-items: center;
    gap: 8px;
    border-radius: 2px;
    border: 1px solid #6C757D;
    background: #fff;
    color: #6C757D;
    font-family: "Proxima Nova", serif;
    font-size: 10px;
    font-style: normal;
    font-weight: 700;
    line-height: 0; /* 0% */
    letter-spacing: 0.896px;
    text-transform: uppercase;
}

/* ============================================
   MOBILE
   ============================================ */

@media (max-width: 768px) {

    body {
        display: block;
        min-height: 100vh;
        margin: 0;
    }

    .chat-wrapper {
        width: 100%;
        height: 100vh;
        margin: 0;
        flex-direction: column;
    }

    .chat-banner {
        height: 64px;
        padding: 12px 16px;
        margin-bottom: 20px;
    }

    /* --- Sidebar mobile --- */
    .chat-wrapper.has-history .chat-history {
        flex-direction: column;
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        min-height: 100vh;
        z-index: 9999;
        transform: translateX(-105%);
        transition: transform 0.25s ease;
        width: 327px;
        max-width: 90vw;
        padding: 0 20px;
    }

    .chat-wrapper.has-history .chat-history-content {
        margin-bottom: 44px;
    }

    .chat-wrapper.has-history.history-open .chat-history {
        transform: translateX(0);
    }

    .chat-wrapper.has-history.history-open .chat-mobile-back {
        display: inline-flex;
        margin: 16px 8px;
    }

    .chat-history-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.35);
        z-index: 9998;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    .chat-wrapper.has-history .chat-main {
        padding: 40px 20px 40px 20px;
    }

    .chat-wrapper.has-history.history-open .chat-history-overlay {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }

    .chat-mobile-bar {
        background: #F5F5F5;
        display: flex;
        margin-bottom: 10px;
    }

    .chat-mobile-toggle {
        border: none;
        background: transparent;
        cursor: pointer;
        padding: 8px 0;
        color: #909090;
        font-family: "Proxima Nova", serif;
        font-size: 12px;
        font-style: normal;
        font-weight: 600;
        line-height: normal;
        letter-spacing: 0.24px;
        text-transform: uppercase;
    }

    .chat-history-header {
        border-bottom: none;
        flex: 0 0 auto;
        background: #FFF;
        box-shadow: 0 0 10px 0 rgba(51, 51, 51, 0.10);
        display: flex;
        padding: 24px 16px;
        align-items: center;
        align-self: stretch;
    }

    .expert-mode .chat-history-list {
        padding-bottom: 44px;
        box-sizing: border-box;
    }
}