/* --- Container Positioning & Global Styles --- */
.roularta-floating-region {
    position: fixed !important;
    z-index: 999 !important;
    
    /* ANCHOR TO BOTTOM EDGE */
    /* This ensures the background touches the very bottom of the screen */
    bottom: 0 !important;
    
    /* Full Width */
    width: 100% !important;
    left: 0 !important;
    right: 0 !important;
    
    /* Flex Layout */
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    
    /* VERTICAL PADDING (The "Lift") */
    /* padding-bottom: 40px -> Pushes buttons up to their original position 
       padding-top: 5px     -> Adds a small amount of breathing room above */
    padding-top: 5px !important;
    padding-bottom: 40px !important;
    
    /* Remove default region styles */
    border: none !important;
    margin: 0 !important;
    
    /* INTERACTION LOGIC: 
       Users click THROUGH the background, but catch the buttons (pointer-events: auto below) */
    pointer-events: none; 

    /* --- BACKGROUND (Applies to Desktop & Mobile, ALWAYS) --- */
    border-radius: var(--border-radius-panel-no-radius, 0);
    background: radial-gradient(64.25% 56.88% at 76.2% 58.4%, #FFF 0%, rgba(255, 255, 255, 0.00) 100%);
}

/* HIDE GHOST BUTTONS */
.roularta-floating-region + table,
.roularta-floating-region ~ table {
    display: none !important;
}

/* --- Desktop Specifics (Align Right + Pills) --- */
@media (min-width: 641px) {
    .roularta-floating-region {
        /* Align buttons to the right */
        justify-content: flex-end !important;
        /* Horizontal padding */
        padding-right: 40px !important; 
    }
}

/* --- Mobile Specifics (Align Center + Circles) --- */
@media (max-width: 640px) {
    .roularta-floating-region {
        /* Default alignment: Center (for 3+ buttons) */
        justify-content: center !important;
        /* Horizontal Padding */
        padding-left: 20px !important;
        padding-right: 20px !important;
    }
}

/* --- Button Styling (Base Styles) --- */
.roularta-floating-region button.t-Button {
    /* Visuals - Force Brand Colors */
    background-color: var(--color-bg-fill-fill-brand, #121212) !important;
    color: white !important;
    border: none !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2) !important;
    
    /* Typography */
    font-size: 12px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    line-height: 1 !important;
    
    /* Layout overrides */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 48px !important;
    min-width: 50px !important;
    padding: 0 24px !important;
    margin: 0 !important; 
    
    /* Reset standard APEX button gradients/shadows */
    text-shadow: none !important;
    background-image: none !important;
    
    /* Interaction - Re-enable clicking on the buttons! */
    cursor: pointer !important;
    pointer-events: auto !important;
    transition: background-color 0.2s, transform 0.2s !important;
}

/* Hover Effect */
.roularta-floating-region button.t-Button:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3) !important;
}

/* Icon Spacing */
.roularta-floating-region .t-Button-label {
    display: inline-block !important;
    margin-left: 8px !important;
}

/* Clean up Icon alignment */
.roularta-floating-region .t-Icon {
    margin-right: 0 !important;
    vertical-align: middle !important;
    line-height: 1 !important;
}

/* --- Desktop Button Logic (Connected Pills) --- */
@media (min-width: 641px) {
    
    /* Spacing Between Buttons */
    .roularta-floating-region button.t-Button + button.t-Button {
        margin-left: 2px !important;
    }

    /* 1. Only one button? Full Pill */
    .roularta-floating-region button.t-Button:only-child {
        border-radius: 9999px !important;
    }

    /* 2. Multiple Buttons logic */
    /* Leftmost Button */
    .roularta-floating-region button.t-Button:first-child:not(:last-child) {
        border-radius: 9999px 0 0 9999px !important;
        padding-left: 24px !important;
        padding-right: 16px !important; 
    }

    /* Rightmost Button */
    .roularta-floating-region button.t-Button:last-child:not(:first-child) {
        border-radius: 0 9999px 9999px 0 !important;
        padding-left: 16px !important;
        padding-right: 24px !important;
    }

    /* Middle Buttons */
    .roularta-floating-region button.t-Button:not(:first-child):not(:last-child) {
        border-radius: 0 !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
}

/* --- Mobile Button Logic (Circles + Smart Alignment) --- */
@media (max-width: 640px) {

    /* 1. Hide the text label */
    .roularta-floating-region .t-Button-label {
        display: none !important;
    }

    /* 2. Turn buttons into perfect circles */
    .roularta-floating-region button.t-Button {
        width: 48px !important;
        min-width: 48px !important;
        padding: 0 !important;
        border-radius: 50% !important; 
    }

    /* 3. Spacing between circles */
    .roularta-floating-region button.t-Button + button.t-Button {
        margin-left: 12px !important;
    }

    /* ------------------------------------------------ */
    /* SMART ALIGNMENT LOGIC (Quantity Queries)         */
    /* ------------------------------------------------ */

    /* SCENARIO A: Exactly 1 Button */
    /* Logic: Push it to the left */
    .roularta-floating-region button.t-Button:only-child {
        margin-right: auto !important; 
        margin-left: 0 !important;
    }

    /* SCENARIO B: Exactly 2 Buttons */
    /* Logic: Target the FIRST button of a group of 2. 
       Push it to the left (margin-right: auto forces the next sibling to the far end) */
    .roularta-floating-region button.t-Button:first-child:nth-last-child(2) {
        margin-right: auto !important; 
        margin-left: 0 !important;
    }
}