/* Wrapper */
#c2-boxy-plus-wrapper {
    position: relative;
    z-index: 9998;
}

/* === Trigger groups (one per side) === */

.c2-boxy-trigger-group {
    position: fixed;
    z-index: 9999;
    display: flex;
}

/* Left/right: vertical stack with gap */
.c2-boxy-trigger-group-left {
    left: var(--c2-boxy-trigger-edge-offset, 0);
    top: 50%;
    transform: translateY(-50%);
    flex-direction: column;
    gap: var(--c2-boxy-stack-gap, 0.5rem); /* spacing between bubbles on left side */
    align-items: flex-start; /* keep items pinned to the left edge */
}

.c2-boxy-trigger-group-right {
    right: var(--c2-boxy-trigger-edge-offset, 0);
    top: 50%;
    transform: translateY(-50%);
    flex-direction: column;
    gap: var(--c2-boxy-stack-gap, 0.5rem); /* spacing between bubbles on right side */
    align-items: flex-end; /* keep items pinned to the right edge */
}

/* Top/bottom: horizontal stack with gap */
.c2-boxy-trigger-group-top {
    top: 0.5rem;
    right: 20%;
    flex-direction: row;
    gap: var(--c2-boxy-stack-gap, 0.5rem);
}

.c2-boxy-trigger-group-bottom {
    bottom: 0.5rem;
    right: 20%;
    flex-direction: row;
    gap: var(--c2-boxy-stack-gap, 0.5rem);
}

/* === Trigger (edge tab) === */

.c2-boxy-trigger {
    position: static; /* positioning controlled by the group */
    flex: 0 0 auto;
}

/* Trigger look */

.c2-boxy-trigger-button {
    display: flex;
    align-items: center;
    gap: var(--c2-boxy-icon-gap, 0.5rem);
    padding: 0.6rem 0.8rem;
    border-radius: var(--c2-boxy-trigger-radius, 0);
    border: none;
    background: var(--c2-boxy-trigger-bg, #111827);
    color: var(--c2-boxy-trigger-text, #f9fafb);
    cursor: pointer;
    font-size: var(--c2-boxy-trigger-font-size, 14px);
    line-height: 1;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.4);
    transition:
        max-width 0.25s ease,
        background-color 0.2s ease;
    max-width: var(--c2-boxy-trigger-collapsed, 3rem); /* collapsed width - icon only */
    overflow: hidden;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
}

/* Title on the LEFT of the icon for left side */
.c2-boxy-trigger.c2-boxy-position-left .c2-boxy-trigger-button {
    flex-direction: row-reverse;
}

/* Hover / active: expand to show title */
.c2-boxy-trigger-button:hover,
.c2-boxy-trigger.is-active .c2-boxy-trigger-button {
    max-width: none; /* Allow unlimited expansion to fit any title length */
    background-color: var(--c2-boxy-trigger-bg-hover, #1f2937);
}

/* Icon styles (dashicon or image) */

.c2-boxy-trigger-button .dashicons {
    font-size: var(--c2-boxy-icon-size, 20px);
    width: 1em;
    height: 1em;
}

.c2-boxy-icon-image {
    width: var(--c2-boxy-icon-size, 20px);
    height: var(--c2-boxy-icon-size, 20px);
    object-fit: contain;
    display: block;
}

/* Title: fully hidden when collapsed (icon-only) */

.c2-boxy-trigger-title {
    white-space: nowrap;
    overflow: hidden;
    max-width: 0;         /* take no horizontal space */
    opacity: 0;           /* not visible at all */
    transition: max-width 0.25s ease, opacity 0.15s ease;
}

/* When hovered / active, let the title expand and fade in */
.c2-boxy-trigger-button:hover .c2-boxy-trigger-title,
.c2-boxy-trigger.is-active .c2-boxy-trigger-title {
    max-width: none; /* No limit - title expands to fit content */
    opacity: 1;
}

/* === Overlay === */

.c2-boxy-overlay {
    position: fixed;
    inset: 0;
    background: var(--c2-boxy-overlay-bg, rgba(15, 23, 42, 0.45));
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
    z-index: 9998;
}

.c2-boxy-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

/* === Panel (bubble) === */

.c2-boxy-panel {
    position: fixed;
    z-index: 10000;
    width: min(var(--c2-boxy-panel-width, 420px), 94vw);
    max-height: var(--c2-boxy-panel-max-height, 85vh);
    background: var(--c2-boxy-panel-bg, #f9fafb);
    color: var(--c2-boxy-panel-text, #111827);
    border-radius: var(--c2-boxy-panel-radius, 18px);
    box-shadow: var(--c2-boxy-panel-shadow, 0 20px 40px rgba(15,23,42,0.35), 0 0 0 1px rgba(15,23,42,0.05));
    opacity: 0;
    pointer-events: none;
    transform: translate3d(0,0,0);
    transition:
        opacity 0.22s ease,
        transform 0.22s ease;

    /* let children handle scrolling */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.c2-boxy-panel-inner {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0; /* allows content to scroll instead of overflowing */
}

.c2-boxy-panel-title {
    font-size: var(--c2-boxy-title-font-size, 18px);
    font-weight: 600;
    padding: 1rem 1.25rem 0.45rem;
    margin: 0;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    flex-shrink: 0; /* fixed header */
}

.c2-boxy-panel-content {
    padding: 0.75rem 1.25rem 1.2rem;
    flex: 1 1 auto;
    min-height: 0;

    /* vertical scrollbar when needed */
    overflow-y: auto;
    overflow-x: hidden;

    /* normal text wrapping */
    white-space: normal;
    overflow-wrap: break-word;
    font-size: var(--c2-boxy-content-font-size, 14px);
}

/* Close button */

.c2-boxy-close {
    position: absolute;
    top: 0.55rem;
    right: 0.7rem;
    background: transparent;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: #6b7280;
    padding: 0;
}

.c2-boxy-close:hover {
    color: #111827;
}

/* === Panel positions & animations === */

/* Right edge bubble */
.c2-boxy-panel-right {
    top: 50%;
    right: 1.25rem;
    transform: translate(20px, -50%);
}

/* Left edge bubble */
.c2-boxy-panel-left {
    top: 50%;
    left: 1.25rem;
    transform: translate(-20px, -50%);
}

/* Top edge bubble */
.c2-boxy-panel-top {
    top: 1.25rem;
    left: 50%;
    transform: translate(-50%, -20px);
}

/* Bottom edge bubble */
.c2-boxy-panel-bottom {
    bottom: 1.25rem;
    left: 50%;
    transform: translate(-50%, 20px);
}

/* Active state: slide into place + show */

.c2-boxy-panel.is-active {
    opacity: 1;
    pointer-events: auto;
}

.c2-boxy-panel-right.is-active {
    transform: translate(0, -50%);
}

.c2-boxy-panel-left.is-active {
    transform: translate(0, -50%);
}

.c2-boxy-panel-top.is-active {
    transform: translate(-50%, 0);
}

.c2-boxy-panel-bottom.is-active {
    transform: translate(-50%, 0);
}

/* === Responsive tweaks === */

@media (max-width: 600px) {
    .c2-boxy-panel {
        width: 94vw;
        max-height: 90vh;
    }

    .c2-boxy-trigger-group-top {
        right: 10%;
    }

    .c2-boxy-trigger-group-bottom {
        right: 10%;
    }
}

/* Accessibility helper */

.screen-reader-text {
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
    clip: rect(1px,1px,1px,1px);
    white-space: nowrap;
}

/* When click is disabled, show default cursor instead of pointer */
.c2-boxy-trigger[data-boxy-disable-click="1"] .c2-boxy-trigger-button {
    cursor: default;
}

/* Link-Wrapper styling (when click is disabled and URL is set) */
.c2-boxy-trigger-link {
    display: flex;
    align-items: center;
    gap: var(--c2-boxy-icon-gap, 0.5rem);
    padding: 0.6rem 0.8rem;
    border-radius: var(--c2-boxy-trigger-radius, 0);
    border: none;
    background: var(--c2-boxy-trigger-bg, #111827);
    color: var(--c2-boxy-trigger-text, #f9fafb);
    cursor: pointer;
    font-size: var(--c2-boxy-trigger-font-size, 14px);
    line-height: 1;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.4);
    transition:
        max-width 0.25s ease,
        background-color 0.2s ease;
    max-width: var(--c2-boxy-trigger-collapsed, 3rem);
    overflow: hidden;
    text-decoration: none;
    box-sizing: border-box;
}

.c2-boxy-trigger.c2-boxy-position-left .c2-boxy-trigger-link {
    flex-direction: row-reverse;
}

.c2-boxy-trigger-link:hover {
    max-width: none; /* Allow unlimited expansion to fit any title length */
    background-color: var(--c2-boxy-trigger-bg-hover, #1f2937);
}

.c2-boxy-trigger-link .c2-boxy-trigger-title {
    white-space: nowrap;
    overflow: hidden;
    max-width: 0;
    opacity: 0;
    transition: max-width 0.25s ease, opacity 0.15s ease;
}

.c2-boxy-trigger-link:hover .c2-boxy-trigger-title {
    max-width: none; /* No limit - title expands to fit content */
    opacity: 1;
}

/* Hide mobile bar on desktop by default */
.c2-boxy-mobile-bar {
    display: none;
}

/* Mobile view: sticky bottom bar with icons */
@media (max-width: 781px) {
    /* Hide regular trigger groups on mobile */
    .c2-boxy-trigger-group-left,
    .c2-boxy-trigger-group-right,
    .c2-boxy-trigger-group-top,
    .c2-boxy-trigger-group-bottom {
        display: none !important;
    }
    
    /* Mobile trigger container */
    .c2-boxy-mobile-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--c2-boxy-trigger-bg, #111827);
        box-shadow: 0 -2px 10px rgba(15, 23, 42, 0.3);
        z-index: 9999;
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 1rem;
        padding: 0.75rem 1rem;
        min-height: 70px;
    }
    
    /* Mobile trigger items */
    .c2-boxy-mobile-bar .c2-boxy-trigger {
        position: static;
        flex: 0 0 auto;
    }
    
    /* Mobile trigger buttons (icon only, no expand) */
    .c2-boxy-mobile-bar .c2-boxy-trigger-button,
    .c2-boxy-mobile-bar .c2-boxy-trigger-link {
        max-width: 3.5rem !important;
        min-width: 3.5rem;
        height: 3.5rem;
        padding: 0.75rem;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--c2-boxy-trigger-bg-hover, #1f2937);
        transition: transform 0.2s ease, background-color 0.2s ease;
    }
    
    .c2-boxy-mobile-bar .c2-boxy-trigger-button:hover,
    .c2-boxy-mobile-bar .c2-boxy-trigger-link:hover,
    .c2-boxy-mobile-bar .c2-boxy-trigger.is-active .c2-boxy-trigger-button {
        transform: scale(1.1);
        background: var(--c2-boxy-trigger-bg-hover, #1f2937);
        max-width: 3.5rem !important; /* Prevent expansion on mobile hover */
    }
    
    /* Hide title on mobile (icon only) */
    .c2-boxy-mobile-bar .c2-boxy-trigger-title {
        display: none !important;
    }
    
    /* Icon sizing on mobile */
    .c2-boxy-mobile-bar .dashicons,
    .c2-boxy-mobile-bar .c2-boxy-icon-image {
        font-size: 24px;
        width: 24px;
        height: 24px;
    }
    
    /* Adjust panel position on mobile */
    .c2-boxy-panel {
        bottom: 80px !important;
        top: auto !important;
        left: 50% !important;
        right: auto !important;
        transform: translate(-50%, 20px) !important;
        width: calc(100vw - 2rem) !important;
        max-width: none !important;
    }
    
    .c2-boxy-panel.is-active {
        transform: translate(-50%, 0) !important;
    }
}