:root {
    --epharm-ai-primary: #df7e12;
    --epharm-ai-primary-dark: #1b54a5;

    --epharm-ai-text: #20242a;
    --epharm-ai-muted: #727983;

    --epharm-ai-border: #e5e8ec;
    --epharm-ai-background: #ffffff;
    --epharm-ai-soft: #f5f7fa;
    --epharm-ai-promo: #d84f19;


    --epharm-ai-success: #15855c;
    --epharm-ai-danger: #c92b3f;

    --epharm-ai-radius: 5px;

    --epharm-ai-shadow:
        0 18px 55px rgba(20, 31, 50, .17);
}


div#epharm-ai-chat {
    display: none;
}


.epharm-ai-chat,
.epharm-ai-chat * {
    box-sizing: border-box;
}


.epharm-ai-chat {
    position: fixed;

    right: 22px;
    bottom: 22px;

    z-index: 999999;

    font-family: inherit;

    color:
        var(--epharm-ai-text);
}


/* ==========================================================
   LAUNCHER
   ========================================================== */

.epharm-ai-launcher {
    width: 62px;
    height: 62px;

    border: 0;
    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    position: relative;

    cursor: pointer;

    background:
        var(--epharm-ai-primary);

    color: #fff;

    box-shadow:
        0 10px 28px rgba(28, 82, 160, .28);

    transition:
        transform .18s ease,
        box-shadow .18s ease,
        background .18s ease;

    -webkit-tap-highlight-color:
        transparent;
}


.epharm-ai-launcher:hover {
    transform:
        translateY(-2px);

    background:
        var(--epharm-ai-primary-dark);

    box-shadow:
        0 13px 34px rgba(28, 82, 160, .34);
}


.epharm-ai-launcher:focus-visible {
    outline:
        3px solid rgba(36, 104, 201, .25);

    outline-offset:
        4px;
}


.epharm-ai-launcher-label {
    position: absolute;

    right: -3px;
    top: -3px;

    min-width: 24px;
    height: 20px;

    padding:
        0 6px;

    border-radius:
        10px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #fff;

    color:
        var(--epharm-ai-primary);

    font-size: 10px;
    font-weight: 800;

    box-shadow:
        0 2px 8px rgba(0, 0, 0, .15);
}


.epharm-ai-launcher-icon {
    display: flex;
}


/* ==========================================================
   PANEL
   ========================================================== */

.epharm-ai-panel {
    position: absolute;

    right: 0;
    bottom: 78px;

    width: 410px;
    height: min(660px, calc(100vh - 125px));

    min-height: 470px;

    display: flex;
    flex-direction: column;

    overflow: hidden;

    border:
        1px solid var(--epharm-ai-border);

    border-radius:
        var(--epharm-ai-radius);

    background:
        var(--epharm-ai-background);

    box-shadow:
        var(--epharm-ai-shadow);

    transform-origin:
        bottom right;

    animation:
        epharm-ai-open .18s ease-out;
}


.epharm-ai-panel[hidden] {
    display: none !important;
}


@keyframes epharm-ai-open {
    from {
        opacity: 0;

        transform:
            translateY(10px) scale(.98);
    }

    to {
        opacity: 1;

        transform:
            translateY(0) scale(1);
    }
}


/* ==========================================================
   HEADER
   ========================================================== */

.epharm-ai-header {
    min-height: 68px;

    padding:
        11px 12px 11px 14px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 15px;

    border-bottom:
        1px solid var(--epharm-ai-border);

    background: #fff;

    flex-shrink: 0;
}


.epharm-ai-header-brand {
    display: flex;
    align-items: center;

    min-width: 0;

    gap: 10px;
}


.epharm-ai-avatar {
    width: 42px;
    height: 42px;

    flex: 0 0 42px;

    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    background:
        var(--epharm-ai-primary);

    color: #fff;

    font-size: 13px;
    font-weight: 800;
}


.epharm-ai-header-text {
    min-width: 0;
}


.epharm-ai-title {
    font-size: 15px;
    font-weight: 700;

    line-height: 1.25;
}


.epharm-ai-subtitle {
    margin-top: 2px;

    font-size: 12px;

    color:
        var(--epharm-ai-muted);
}


.epharm-ai-close {
    width: 38px;
    height: 38px;

    flex: 0 0 38px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 50%;

    cursor: pointer;

    color:
        #555d67;

    background:
        transparent;

    transition:
        background .15s ease;
}


.epharm-ai-close:hover {
    background:
        var(--epharm-ai-soft);
}


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

.epharm-ai-messages {
    flex: 1 1 auto;

    overflow-y: auto;
    overflow-x: hidden;

    padding:
        18px 15px;

    background:
        #f7f8fa;

    scroll-behavior:
        smooth;

    overscroll-behavior:
        contain;
}


.epharm-ai-message-row {
    width: 100%;

    display: flex;

    margin-bottom:
        12px;
}


.epharm-ai-message-row--assistant {
    justify-content:
        flex-start;

    flex-direction:
        column;

    align-items:
        flex-start;
}


.epharm-ai-message-row--user {
    justify-content:
        flex-end;
}


.epharm-ai-message {
    max-width: 84%;

    padding:
        10px 13px;

    border-radius:
        14px;

    font-size: 14px;
    line-height: 1.48;

    white-space:
        pre-wrap;

    word-break:
        break-word;
}


.epharm-ai-message-row--assistant .epharm-ai-message {
    background: #fff;

    border:
        1px solid var(--epharm-ai-border);

    border-bottom-left-radius:
        5px;
}


.epharm-ai-message-row--user .epharm-ai-message {
    background:
        var(--epharm-ai-primary);

    color: #fff;

    border-bottom-right-radius:
        5px;
}


/* ==========================================================
   TYPING
   ========================================================== */

.epharm-ai-typing {
    min-width: 54px;

    display: flex;

    justify-content:
        center;

    gap: 5px;
}


.epharm-ai-typing-dot {
    width: 6px;
    height: 6px;

    border-radius: 50%;

    background:
        #949aa2;

    animation:
        epharm-ai-dot 1.15s infinite ease-in-out;
}


.epharm-ai-typing-dot:nth-child(2) {
    animation-delay:
        .14s;
}


.epharm-ai-typing-dot:nth-child(3) {
    animation-delay:
        .28s;
}


@keyframes epharm-ai-dot {

    0%,
    60%,
    100% {
        opacity: .4;

        transform:
            translateY(0);
    }

    30% {
        opacity: 1;

        transform:
            translateY(-3px);
    }
}


/* ==========================================================
   PRODUCT CARDS
   ========================================================== */

.epharm-ai-products {
    width: 100%;

    margin-top: 8px;

    display: grid;

    gap: 8px;
}


.epharm-ai-product-card {
    width: 100%;

    display: block;

    padding:
        12px;

    border:
        1px solid var(--epharm-ai-border);

    border-radius: 12px 12px 12px 0px;
     

    background: #fff;

    color:
        var(--epharm-ai-text);

    text-decoration:
        none;

    transition:
        border-color .15s ease,
        box-shadow .15s ease,
        transform .15s ease;
}


a.epharm-ai-product-card:hover {
    border-color:
        #cbd6e6;

    box-shadow:
        0 5px 18px rgba(20, 31, 50, .08);

    transform:
        translateY(-1px);
}


.epharm-ai-product-brand {
    margin-bottom: 3px;

    color:
        var(--epharm-ai-muted);

    font-size: 11px;
    font-weight: 600;

    text-transform:
        uppercase;

    letter-spacing:
        .02em;
}


.epharm-ai-product-name {
    display:
        -webkit-box;

    overflow:
        hidden;

    -webkit-box-orient:
        vertical;

    -webkit-line-clamp:
        2;

    font-size: 13px;
    font-weight: 600;

    line-height: 1.4;
}


.epharm-ai-product-price-row {
    margin-top: 9px;

    min-height: 25px;

    display: flex;
    align-items: baseline;

    gap: 7px;

    flex-wrap: wrap;
}


.epharm-ai-product-price {
    color:
        var(--epharm-ai-promo);

    font-size: 16px;
    font-weight: 800;
}


.epharm-ai-product-old-price {
    color: #9298a1;

    font-size: 12px;

    text-decoration:
        line-through;
}


.epharm-ai-product-promo {
    padding:
        3px 6px;

    border-radius:
        5px;

    background:
        #e8f6ee;

    color:
        var(--epharm-ai-success);

    font-size: 10px;
    font-weight: 700;

    text-transform:
        uppercase;
    display: none;
}


.epharm-ai-product-action {
    margin-top: 7px;

    color:
        var(--epharm-ai-primary);

    font-size: 12px;
    font-weight: 700;
}


/* ==========================================================
   STATUS
   ========================================================== */

.epharm-ai-status {
    min-height: 0;

    padding:
        0 14px;

    font-size: 12px;

    color:
        var(--epharm-ai-muted);

    background: #fff;
}


.epharm-ai-status:not(:empty) {
    padding-top: 7px;
}


.epharm-ai-status.is-error {
    color:
        var(--epharm-ai-danger);
}


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

.epharm-ai-form {
    padding:
        10px 12px;

    display: flex;
    align-items: flex-end;

    gap: 8px;

    border-top:
        1px solid var(--epharm-ai-border);

    background: #fff;

    flex-shrink: 0;
}


.epharm-ai-input {
    width: 100%;

    min-height: 42px;
    max-height: 120px;

    resize: none;

    overflow-y: auto;

    padding:
        10px 12px;

    border:
        1px solid #d8dde3;

    border-radius: 5px;

    outline: none;

    background: #fff;

    color:
        var(--epharm-ai-text);

    font: inherit;

    font-size: 14px;
    line-height: 1.4;

    transition:
        border-color .15s ease,
        box-shadow .15s ease;
}


.epharm-ai-input:focus {
    border-color:
        var(--epharm-ai-primary);

   
}


.epharm-ai-input::placeholder {
    color: #9ba1a9;
}


.epharm-ai-input:disabled {
    opacity: .65;
}


.epharm-ai-send {
    width: 43px;
    height: 43px;

    flex: 0 0 43px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 0;

    border-radius: 5px;
      

    cursor: pointer;

    background:
        var(--epharm-ai-primary);

    color: #fff;

    transition:
        background .15s ease,
        opacity .15s ease;
}


.epharm-ai-send:hover {
    background:
        var(--epharm-ai-promo);
}


.epharm-ai-send:disabled {
    cursor: default;

    opacity: .5;
}


/* ==========================================================
   DISCLAIMER
   ========================================================== */

.epharm-ai-disclaimer {
    padding:
        0 12px 9px;

    background: #fff;

    text-align: center;

    color:
        #9399a1;

    font-size: 10px;
    line-height: 1.3;

    flex-shrink: 0;
}


/* ==========================================================
   ACCESSIBILITY
   ========================================================== */

.epharm-ai-visually-hidden {
    position: absolute !important;

    width: 1px !important;
    height: 1px !important;

    padding: 0 !important;
    margin: -1px !important;

    overflow: hidden !important;

    clip:
        rect(0, 0, 0, 0) !important;

    white-space: nowrap !important;

    border: 0 !important;
}


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

@media (max-width: 600px) {

    html.epharm-ai-chat-open {
        overflow: hidden;
    }


    .epharm-ai-chat {
        right: 14px;
        bottom: 14px;
    }


    .epharm-ai-panel {
        position: fixed;

        left: 0;
        top: 0;
        right: 0;
        bottom: 0;

        width: 100vw;

        height: 100dvh;

        min-height: 0;

        border: 0;
        border-radius: 0;

        box-shadow: none;
    }


    .epharm-ai-chat.is-open .epharm-ai-launcher {
        display: none;
    }


    .epharm-ai-header {
        padding-top:
            max(11px,
                env(safe-area-inset-top));
    }


    .epharm-ai-messages {
        padding:
            15px 12px;
    }


    .epharm-ai-message {
        max-width: 88%;
    }


    .epharm-ai-form {
        padding-left:
            max(12px,
                env(safe-area-inset-left));

        padding-right:
            max(12px,
                env(safe-area-inset-right));
    }


    .epharm-ai-disclaimer {
        padding-bottom:
            max(9px,
                env(safe-area-inset-bottom));
    }
}


/* ==========================================================
   REDUCED MOTION
   ========================================================== */

@media (prefers-reduced-motion: reduce) {

    .epharm-ai-panel,
    .epharm-ai-launcher,
    .epharm-ai-product-card {
        animation: none;
        transition: none;
    }


    .epharm-ai-messages {
        scroll-behavior: auto;
    }
}