#saex-livechat-root {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#saex-livechat-root * {
    box-sizing: border-box;
}

.saex-widget-icon {
    width: 68px;
    height: 68px;
    border: 0;
    border-radius: 999px;
    background-color: var(--saex-livechat-theme-color);
    box-shadow: 0 12px 26px -12px rgba(0, 0, 0, 0.45);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
}

.saex-widget-icon:hover, .saex-widget-icon:focus {
    background-color: var(--saex-livechat-secondary-color);
}

.saex-widget-icon img {
    width: 40px;
    height: 40px;
}

.saex-chat-widget {
    width: 360px;
    max-height: min(680px, calc(100vh - 120px));
    border-radius: 14px;
    background-image: var(--saex-livechat-bg-main);
    background-size: cover;
    box-shadow: 0 28px 40px -28px rgba(0, 0, 0, 0.55);
    overflow: hidden;
    position: absolute;
    right: 0;
    bottom: 84px;
    display: flex;
    flex-direction: column;
}

#saex-livechat-close {
    position: absolute;
    right: 0;
    top: 0;
    border: 0;
    background: rgba(255 255 255 / 20%);
    border-bottom-left-radius: 10px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.saex-chat-header {
    background: linear-gradient(330deg, #40c351, #268232);
    color: #ffffff;
    padding: 12px 14px;
    position: relative;
    min-height: 96px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

.saex-selected-contact {
    display: flex;
    padding: 0;
}

.saex-selected-contact .saex-contact-name {
    color: white;
}
.saex-selected-contact .saex-contact-role,
.saex-selected-contact .saex-contact-state {
    color: rgba(255 255 255 / 80%);
    font-weight: 600;
}

.saex-selected-contact .saex-contact-related {
    color: rgba(255, 255, 255, 0.9);
    max-width: 220px;
}

.saex-contact-related-pills {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
}

.saex-related-prefix {
    font-size: 11px;
    color: #5e7563;
    flex: 0 0 auto;
}

.saex-related-pill {
    display: inline-flex;
    align-items: center;
    max-width: 140px;
    padding: 2px 7px;
    border-radius: 999px;
    border: 1px solid #b7d9bf;
    background: #eef8f1;
    color: #2d6f3b;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saex-related-pill.is-topic {
    border-color: #8bcf9a;
    background: #e4f7ea;
    color: #1f6631;
}

.saex-related-pill.is-count {
    border-color: #a8cbb0;
    background: #edf3ef;
    color: #42684b;
    max-width: none;
}

#saex-livechat-back {
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 6px 10px;
}

.saex-selected-contact-info {
    display: flex;
    flex-direction: row;
    gap: 2px;
    min-width: 0;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
}

.saex-online-contacts {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.saex-online-contacts.is-loading {
    gap: 8px;
}

.saex-online-contacts img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    margin: 0 -3px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.saex-avatar-placeholder {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.32);
    animation: saexPulse 1.1s ease-in-out infinite;
}

.saex-online-contacts img.contact-focus {
    width: 42px;
    height: 42px;
    margin: 0 4px;
}

.saex-chat-header.is-active .saex-online-contacts img {
    width: 42px;
    height: 42px;
    margin: 0;
    cursor: default;
    pointer-events: none;
}

.saex-chat-header.is-active {
    min-height: 72px;
}

.saex-chat-header.is-active .saex-online-contacts {
    display: none;
}

.saex-chat-header.is-active .saex-selected-contact {
    align-items: center;
    gap: 8px;
    padding-right: 50px;
}

.saex-selected-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    object-fit: cover;
    flex: 0 0 34px;
}

.saex-chat-header.is-active .saex-selected-contact-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    min-width: 0;
}

.saex-chat-header.is-active .saex-selected-contact .saex-contact-name {
    flex: none;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saex-contact-message {
    text-align: center;
    font-size: 12px;
    line-height: 1.4;
}

.saex-selected-contact .saex-contact-name {
    font-size: 14px;
    font-weight: 700;
    flex: 1 0 100%;
}

.saex-selected-contact .saex-contact-role,
.saex-selected-contact .saex-contact-state {
    font-size: 12px;
}

.saex-selected-contact .saex-contact-related-pills .saex-related-prefix {
    color: rgba(255, 255, 255, 0.88);
}

.saex-selected-contact .saex-contact-related-pills .saex-related-pill {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.45);
    color: #ffffff;
}

.saex-selected-contact .saex-contact-related-pills .saex-related-pill.is-count {
    background: rgba(255, 255, 255, 0.11);
    border-color: rgba(255, 255, 255, 0.35);
}

.saex-contact-list {
    overflow-y: auto;
    max-height: 320px;
    padding: 8px;
    background: #ffffff;
}

.saex-contact-bubble {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #e7f0ea;
    background: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.saex-contact-bubble:hover {
    background: #eff9f2;
    border-color: #cde9d5;
}

.saex-contact-bubble img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
}

.saex-contact-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.saex-contact-name {
    font-size: 14px;
    font-weight: 700;
    color: #243424;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saex-contact-role,
.saex-contact-state {
    font-size: 12px;
    color: #4d6150;
    display: flex;
    align-items: center;
    gap: 6px;
}

.saex-contact-related {
    font-size: 11px;
    color: #5e7563;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 210px;
    line-height: 1.2;
}

.saex-contact-status {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: 0 0 9px;
}

.saex-contact-status.online {
    background: #27c05f;
}

.saex-contact-status.offline {
    background: #d0d7d2;
}

.saex-chatnow-button {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 6px;
    border: 0;
    background: var(--saex-livechat-theme-color);
    color: #ffffff;
    font-size: 13px;
    cursor: pointer;
    padding: 6px 10px;
}

.saex-chat-bubbles {
    min-height: 210px;
    max-height: 230px;
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.saex-chat-bubble {
    max-width: 78%;
    margin: 5px 0;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
}

.saex-chat-bubble.incoming {
    align-self: flex-start;
    position: relative;
    background: #ffffff;
    color: #1f2d1f;
    border-top-left-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.saex-chat-bubble.incoming::before {
    content: "";
    position: absolute;
    left: -7px;
    top: 8px;
    width: 10px;
    height: 13px;
    background: #ffffff;
    clip-path: polygon(100% 0, 0 50%, 100% 100%);
    filter: drop-shadow(-1px 1px 1px rgba(0, 0, 0, 0.06));
    z-index: 1;
}

.saex-chat-bubble.incoming::after {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    width: 8px;
    height: 8px;
    background: var(--saex-livechat-chat-bg);
    border-radius: 50%;
    transform: translate(-52%, -52%);
    z-index: 2;
}

.saex-chat-bubble.outgoing {
    align-self: flex-end;
    background: var(--saex-livechat-theme-color);
    color: #ffffff;
}

.saex-topic-picker-bubble {
    padding: 8px 10px;
}

.saex-topic-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.saex-topic-pill {
    border: 1px solid #8bcf9a;
    background: #e8f8ed;
    color: #216536;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    padding: 6px 10px;
    cursor: pointer;
}

.saex-topic-pill:hover {
    color: #dcf5e5;
    background: #216536;
}

.saex-topic-pill:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.saex-topic-pill.is-active {
    border-color: #2fb857;
    background: #c7efd5;
    color: #0e5527;
}

.saex-coupon-wrapper {
    padding: 8px 10px 6px;
    background: rgba(255, 255, 255, 0.65);
    border-top: 1px solid #ecf3ee;
}

#saex-coupon-toggle {
    border: 0;
    background: transparent;
    color: #2f5a3a;
    text-align: left;
    width: 100%;
    height: 22px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
    cursor: default;
    padding: 0 2px;
    letter-spacing: 0.01em;
}

.saex-coupon-list {
    display: flex;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 0 2px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.saex-coupon-list::-webkit-scrollbar {
    height: 6px;
}

.saex-coupon-list::-webkit-scrollbar-thumb {
    background: #cfe4d5;
    border-radius: 999px;
}

.saex-coupon-item {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    flex: 0 0 auto;
    min-width: 190px;
    max-width: 210px;
    min-height: 84px;
    border: 1px solid #d7e8db;
    border-radius: 12px;
    padding: 9px 10px 8px;
    text-decoration: none;
    color: #1f2d1f;
    background: linear-gradient(180deg, #fbfffc 0%, #f7fdf9 100%);
    scroll-snap-align: start;
    position: relative;
    overflow: visible;
    box-shadow: 0 8px 18px -14px rgba(27, 76, 41, 0.45);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.saex-coupon-item::before,
.saex-coupon-item::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 12px;
    background: #f5faf7;
    border: 1px solid #d7e8db;
    z-index: 2;
    pointer-events: none;
}

.saex-coupon-item::before {
    left: -1px;
    border-left: 0;
    border-radius: 0 10px 10px 0;
}

.saex-coupon-item::after {
    right: -1px;
    border-right: 0;
    border-radius: 10px 0 0 10px;
}

.saex-coupon-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 22px -14px rgba(27, 76, 41, 0.6);
    border-color: #bcd8c4;
}

.saex-coupon-item:active {
    transform: translateY(0);
}

.saex-ticket-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: #eaf8ee;
    border: 1px solid #d2ecd9;
    border-radius: 7px;
    padding: 4px 7px;
    margin-bottom: 7px;
}

.saex-ticket-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #3e6f4b;
}

.saex-ticket-value {
    font-size: 12px;
    font-weight: 800;
    color: #1f7e41;
}

.saex-ticket-code-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: flex-start;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
    font-weight: 800;
    color: #135f31;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px dashed #7eb893;
    background: #ffffff;
    border-radius: 6px;
    padding: 3px 7px;
    margin-bottom: 5px;
}

.saex-ticket-owner {
    font-size: 11px;
    color: #4f6c57;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saex-ticket-status {
    display: block;
    margin-top: 4px;
    min-height: 14px;
    font-size: 10px;
    font-weight: 700;
    color: #3f6850;
}

.saex-ticket-status:empty {
    display: none;
}

.saex-coupon-item:focus-visible {
    outline: 2px solid #1f7e41;
    outline-offset: 2px;
}

.saex-coupon-item.is-applying {
    border-color: #9eceac;
    box-shadow: 0 12px 22px -14px rgba(39, 136, 73, 0.6);
}

.saex-coupon-item.is-applying .saex-ticket-status {
    color: #2f7d47;
}

.saex-coupon-item.is-applied {
    border-color: #72bd8a;
    background: linear-gradient(180deg, #f4fff8 0%, #eefdf3 100%);
}

.saex-coupon-item.is-applied .saex-ticket-status {
    color: #1f7e41;
}

.saex-coupon-item.is-failed {
    border-color: #e5b3b3;
    background: linear-gradient(180deg, #fffafa 0%, #fff5f5 100%);
}

.saex-coupon-item.is-failed .saex-ticket-status {
    color: #b43d3d;
}

@media (prefers-reduced-motion: reduce) {
    .saex-coupon-item {
        transition: none;
    }
}

.saex-chat-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #ecf3ee;
    background: #ffffff;
}

#saex-chat-reply {
    flex: 1;
    min-height: 36px;
    max-height: 92px;
    border-radius: 18px;
    border: 1px solid #dbe8de;
    background: #f9fcfa;
    padding: 8px 12px;
    font-size: 13px;
    resize: vertical;
}

#saex-chat-reply:focus {
    border-color: var(--saex-livechat-theme-color);
    outline: none;
}

#saex-send-chat {
    border-radius: 18px;
    border: 0;
    background: var(--saex-livechat-theme-color);
    color: #ffffff;
    cursor: pointer;
    padding: 6px 10px
}

#saex-send-chat:disabled,
#saex-chat-reply:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.saex-empty-state {
    text-align: center;
    font-size: 13px;
    color: #59705c;
    padding: 24px 12px;
}

.saex-loading-state {
    font-style: italic;
}

@keyframes saexPulse {
    0% {
        opacity: 0.45;
    }
    50% {
        opacity: 0.95;
    }
    100% {
        opacity: 0.45;
    }
}

@media (max-width: 480px) {
    #saex-livechat-root {
        right: 12px;
        bottom: 12px;
    }

    .saex-chat-widget {
        width: min(360px, calc(100vw - 24px));
        bottom: 80px;
    }

    .saex-widget-icon {
        width: 62px;
        height: 62px;
    }
}
