.five9-frame {
    right: 0% !important;
    z-index: 2147483647 !important; /* ensure on top */
}

.five9-chat-button {
    background: #a6192e !important;
    z-index: 2147483647 !important;
}

.five9-header {
    color: #fff !important;
    font-weight: 600 !important;
    text-align: center !important;
    border-radius: 10px 10px 0 0 !important;
}

.five9-frame-minimized {
    position: fixed !important;
    background: #a6192e !important;
    rotate: -90deg !important;
    bottom: 30% !important;
    right: -33px !important;
    width: 100px !important;
    border-radius: 10px 10px 0 0 !important;
    box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.5) !important;
    z-index: 2147483647 !important;
}

/* Full frame - slide in horizontally from right */
.five9-frame-full {
    position: fixed !important;
    right: 0 !important;
    top: 73% !important;
    transform: translateY(-73%) translateX(100%) !important;
    transition: transform 0.3s ease-in-out !important;
    z-index: 2147483647 !important;
    border-radius: 8px 0 0 8px !important;
    overflow: visible !important;
}

.five9-frame-full[style*="display: block"],
.five9-frame-full:not([style*="display: none"]),
.five9-frame-full[style*="visibility: visible"] {
    transform: translateY(-50%) translateX(0%) !important;
}

/* Embedded container */
.five9-embedded-container {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    padding-left: 60px !important;
}

/* Header attached to left edge of embedded container - multiple selectors to catch different structures */
.five9-embedded-container .five9-header,
.five9-embedded-container > div:first-child[class*="header"],
.five9-embedded-container > div:first-child:not([class*="embedded"]):not([class*="content"]):not([class*="iframe"]) {
    position: absolute !important;
    left: 0 !important;
    top: 70% !important;
    transform: translateY(-70%) !important;
    background: #a6192e !important;
    color: #fff !important;
    font-weight: 600 !important;
    padding: 20px 12px !important;
    border-radius: 8px 0 0 8px !important;
    white-space: nowrap !important;
    transition: all 0.3s ease-in-out !important;

    z-index: 2147483648 !important;
    writing-mode: vertical-rl !important;
    text-orientation: mixed !important;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.2) !important;
    width: 60px !important;
    min-height: 120px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-left: -60px !important;
}

/* Also handle header if it's directly in frame-full */
.five9-frame-full > .five9-header,
.five9-frame-full > div:first-child[class*="header"]:not([class*="embedded"]) {
    position: absolute !important;
    left: -28% !important;
    top: 40% !important;
    rotate: -90deg !important;
    transform: translateY(-50%) !important;
    transition: all 0.3s ease-in-out !important;
    background: #a6192e !important;
    color: #fff !important;
    font-weight: 600 !important;
    padding: 20px 12px !important;
    border-radius: 10px 10px 0 0 !important;
    white-space: nowrap !important;
    z-index: 2147483648 !important;
    text-orientation: mixed !important;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.2) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Scope high stacking to Five9 only */
.five9-frame iframe,
.five9-chat-button iframe {
    z-index: 2147483647 !important;
}
