/**
 * Stylesheet for VN-Nexus ChatBot (EuroSmart Advisor)
 *
 * Fully responsive, mobile-first, draggable panel.
 */

#es-advisor {
    --es-blue: #0756b9;
    --es-deep: #063875;
    --es-red: #ed1c2e;
    --es-ink: #12264a;
    --es-muted: #637894;
    position: fixed;
    z-index: 999990;
    right: 24px;
    bottom: 22px;
    font: 14px/1.45 Inter, Arial, sans-serif;
    color: var(--es-ink);
}

/* Defensive override: Ensure any legacy top-bar inline advisor is hidden */
.top-bar #es-advisor,
#block-8 #es-advisor,
#es-advisor:not([data-vnspo-chatbot="1"]) {
    display: none !important;
}

#es-advisor * {
    box-sizing: border-box;
}

#es-advisor button,
#es-advisor input {
    font: inherit;
}

#es-advisor button {
    cursor: pointer;
}

#es-advisor-launch {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 3px solid #fff;
    border-radius: 999px;
    padding: 5px 15px 5px 5px;
    background: linear-gradient(135deg, #0877ed, #063f9e);
    color: #fff;
    box-shadow: 0 8px 26px #034aa88a;
    touch-action: none;
    user-select: none;
}

#es-advisor-launch img {
    width: 52px;
    height: 52px;
    object-fit: cover;
    object-position: 50% 24%;
    border-radius: 50%;
    border: 2px solid #d7e8ff;
}

#es-advisor-launch strong {
    font-size: 13px;
}

#es-advisor-launch small {
    display: block;
    font-size: 10px;
    opacity: .9;
}

#es-advisor-launch .es-unread {
    position: absolute;
    right: -4px;
    top: -4px;
    background: var(--es-red);
    border: 2px solid white;
    border-radius: 20px;
    padding: 1px 6px;
    font-weight: 800;
}

#es-advisor-panel {
    position: absolute;
    right: 0;
    bottom: 76px;
    width: 390px;
    height: min(620px, calc(100dvh - 110px));
    min-height: 440px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #d7e5f7;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 18px 60px #082b5b38;
}

#es-advisor-panel[hidden],
#es-advisor-launch[hidden] {
    display: none;
}

#es-advisor-head {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 13px 15px;
    background: linear-gradient(120deg, #073875, #0758ba);
    color: white;
    cursor: move;
    touch-action: none;
    user-select: none;
}

#es-advisor-head img {
    width: 46px;
    height: 46px;
    object-fit: cover;
    object-position: 50% 24%;
    border: 2px solid #d8ebff;
    border-radius: 50%;
}

#es-advisor-head strong {
    font-size: 15px;
}

#es-advisor-head small {
    display: block;
    color: #d4e5ff;
    font-size: 11px;
}

.es-online {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: 4px;
    border-radius: 50%;
    background: #39de75;
}

#es-advisor-controls {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

#es-advisor-controls button {
    width: 31px;
    height: 31px;
    border: 0;
    border-radius: 50%;
    background: #ffffff1c;
    color: #fff;
    font-size: 18px;
}

#es-advisor-log {
    flex: 1;
    overflow: auto;
    padding: 16px 14px;
    scroll-behavior: smooth;
}

#es-advisor-disclosure {
    margin: 0 0 12px;
    padding: 8px 10px;
    border-radius: 9px;
    background: #f0f6ff;
    color: #526b8d;
    font-size: 10px;
}

#es-advisor-welcome {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-bottom: 12px;
}

#es-advisor-welcome img {
    width: 37px;
    height: 37px;
    border-radius: 50%;
    object-fit: cover;
    object-position: 50% 24%;
}

#es-advisor-welcome p,
.es-bot-message {
    margin: 0;
    padding: 10px 12px;
    border-radius: 4px 14px 14px;
    background: #f0f5fb;
    color: #1b3152;
    font-size: 13px;
    white-space: pre-line;
}

#es-advisor-choices {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 8px 0 14px 45px;
}

#es-advisor-choices button {
    min-height: 70px;
    padding: 8px 5px;
    border: 1px solid #dbe8f7;
    border-radius: 12px;
    background: #fff;
    color: var(--es-blue);
    font-size: 11px;
    font-weight: 700;
    box-shadow: 0 3px 12px #0e4d8b0d;
}

#es-advisor-choices button span {
    display: block;
    margin-bottom: 4px;
    font-size: 20px;
}

#es-advisor-messages {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.es-user-message {
    align-self: flex-end;
    max-width: 86%;
    padding: 9px 12px;
    border-radius: 14px 5px 14px 14px;
    background: #0963cc;
    color: white;
    overflow-wrap: anywhere;
}

.es-bot-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.es-bot-row img {
    width: 31px;
    height: 31px;
    border-radius: 50%;
    object-fit: cover;
    object-position: 50% 24%;
}

.es-bot-message {
    max-width: 88%;
}

.es-citations {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed #d0deee;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.es-citations-title {
    font-size: 10px;
    font-weight: 700;
    color: #4b6485;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.es-citation-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 6px;
    background: #ffffff;
    border: 1px solid #dce8f6;
    text-decoration: none !important;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.es-citation-item:hover {
    background: #eaf2fc;
    border-color: #9ac2f4;
}

.es-citation-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
    background: #e2eaf5;
    color: #2b4c7e;
    white-space: nowrap;
}

.es-citation-item.is-verified .es-citation-badge {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.es-citation-text {
    font-size: 11px;
    font-weight: 500;
    color: #0d4290;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.es-product-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 9px 0 3px 39px;
}

.es-product {
    overflow: hidden;
    border: 1px solid #dce8f6;
    border-radius: 11px;
    background: #fff;
}

.es-product img {
    width: 100%;
    height: 82px;
    object-fit: cover;
    background: #edf4fb;
}

.es-product div {
    padding: 8px;
}

.es-product strong {
    display: block;
    font-size: 11px;
    color: #083f91;
}

.es-product small {
    display: block;
    min-height: 29px;
    color: #62748d;
    font-size: 10px;
}

.es-product b {
    display: block;
    margin: 4px 0;
    color: #083f91;
    font-size: 11px;
}

.es-product a {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 20px;
    background: #0756b9;
    color: #fff;
    text-decoration: none;
    font-size: 10px;
}

.es-followups {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0 5px 39px;
}

.es-followups button {
    border: 1px solid #c6dbf7;
    border-radius: 20px;
    padding: 6px 9px;
    background: #fff;
    color: #0756b9;
    font-size: 10px;
}

.es-contact {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 8px 0 5px 39px;
}

.es-contact a {
    padding: 8px 11px;
    border-radius: 20px;
    background: #0756b9;
    color: white !important;
    text-decoration: none;
    font-size: 11px;
    font-weight: 700;
}

.es-contact a.es-zalo {
    background: #0088ff;
}

.es-contact a.es-messenger {
    background: #0866ff;
}

#es-advisor-compose {
    display: flex;
    gap: 7px;
    padding: 10px 12px;
    border-top: 1px solid #e8eff8;
    background: #fff;
}

#es-advisor-input {
    min-width: 0;
    flex: 1;
    border: 1px solid #ccdaed;
    border-radius: 22px;
    padding: 10px 14px;
    outline: none;
}

#es-advisor-input:focus {
    border-color: #438ce1;
    box-shadow: 0 0 0 3px #438ce122;
}

#es-advisor-send {
    width: 42px;
    border: 0;
    border-radius: 13px;
    background: #0756b9;
    color: white;
    font-size: 19px;
}

#es-advisor-footnote {
    padding: 0 10px 9px;
    text-align: center;
    color: #7587a0;
    font-size: 9px;
}

#es-advisor-toast {
    position: fixed;
    right: 25px;
    bottom: 95px;
    padding: 8px 12px;
    border-radius: 9px;
    background: #12264a;
    color: #fff;
    font-size: 11px;
}

#es-advisor-toast[hidden] {
    display: none;
}

#es-advisor:focus-visible button:focus-visible {
    outline: 3px solid #ffb400;
    outline-offset: 2px;
}

@media(max-width: 600px) {
    #es-advisor {
        right: 14px;
        bottom: max(14px, env(safe-area-inset-bottom));
    }
    #es-advisor-launch img {
        width: 48px;
        height: 48px;
    }
    #es-advisor-panel {
        position: fixed;
        inset: auto 0 0;
        width: 100%;
        height: min(78dvh, 680px);
        min-height: 390px;
        border-radius: 20px 20px 0 0;
        border-bottom: 0;
    }
    #es-advisor-head {
        padding: 11px 13px;
    }
    #es-advisor-log {
        padding: 13px 11px;
    }
    #es-advisor-compose {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
    .es-product img {
        height: 74px;
    }
    #es-advisor-toast {
        right: 12px;
        bottom: 84px;
    }
}

@media(prefers-reduced-motion: reduce) {
    #es-advisor-log {
        scroll-behavior: auto;
    }
}
