/* ============================================================
   Floating Button Styles - Flowbite Speed Dial Design
   ============================================================ */

.magiccl-speed-dial-container {
    position: fixed;
    z-index: 999998;
    pointer-events: none;
}

/* ============================================================
   Multi-Button Speed Dial Positioning
   ============================================================ */

.magiccl-speed-dial-container.magiccl-multi-fab.position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.magiccl-speed-dial-container.magiccl-multi-fab.position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.magiccl-speed-dial-container.magiccl-multi-fab.position-top-right {
    top: 20px;
    right: 20px;
}

.magiccl-speed-dial-container.magiccl-multi-fab.position-top-left {
    top: 20px;
    left: 20px;
}

/* ============================================================
   Single Button Positioning
   ============================================================ */

.magiccl-speed-dial-container.magiccl-single-fab.position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.magiccl-speed-dial-container.magiccl-single-fab.position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.magiccl-speed-dial-container.magiccl-single-fab.position-top-right {
    top: 20px;
    right: 20px;
}

.magiccl-speed-dial-container.magiccl-single-fab.position-top-left {
    top: 20px;
    left: 20px;
}

/* ============================================================
   Draggable Containers - Fixed positioning
   ============================================================ */

.magiccl-speed-dial-container.has-draggable,
.magiccl-speed-dial-container.has-draggable-fab {
    /* Start at default bottom-right position for draggable items */
    bottom: 20px;
    right: 20px;
    top: auto;
    left: auto;
    width: auto;
    height: auto;
    pointer-events: none; /* Container itself should not block interactions */
}

/* ============================================================
   Admin Bar Adjustments
   ============================================================ */

body.admin-bar .magiccl-speed-dial-container.position-top-left,
body.admin-bar .magiccl-speed-dial-container.position-top-right {
    margin-top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar .magiccl-speed-dial-container.position-top-left,
    body.admin-bar .magiccl-speed-dial-container.position-top-right {
        margin-top: 46px;
    }
}

/* ============================================================
   Speed Dial Wrapper
   ============================================================ */

.magiccl-speed-dial-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: auto;
}

/* Draggable speed dial wrapper positioning */
.magiccl-speed-dial-wrapper[data-draggable="true"] {
    cursor: grab;
    user-select: none;
    touch-action: manipulation;
}

/* ============================================================
   Speed Dial Menu (Items Container)
   ============================================================ */

.magiccl-speed-dial-menu {
    position: absolute;
    bottom: 65px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 1;
}

.magiccl-speed-dial-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Position adjustments for top containers */
.magiccl-speed-dial-container.position-top-right .magiccl-speed-dial-menu,
.magiccl-speed-dial-container.position-top-left .magiccl-speed-dial-menu,
.magiccl-speed-dial-container.has-draggable-fab.magiccl-positioned-top .magiccl-speed-dial-menu {
    bottom: auto;
    top: 70px;
    flex-direction: column-reverse;
}

/* ============================================================
   Speed Dial Items
   ============================================================ */

.magiccl-speed-dial-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.magiccl-speed-dial-item .magiccl-speed-dial-button {
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
    transition: all 0.2s ease !important;
}

@media (hover: hover) {
    .magiccl-speed-dial-item .magiccl-speed-dial-button:hover {
        transform: scale(1.1);
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
    }
}

/* ============================================================
   Speed Dial Icon Animation
   ============================================================ */

.magiccl-speed-dial-icon {
    transition: transform 0.2s ease;
}

.magiccl-speed-dial-icon.open {
    transform: rotate(45deg);
}

/* ============================================================
   Single Button Wrapper
   ============================================================ */

.magiccl-single-button-wrapper {
    pointer-events: auto;
}

.magiccl-single-button-wrapper[data-draggable="true"] {
    cursor: grab;
    user-select: none;
    touch-action: manipulation;
}

.magiccl-single-floating-button {
    width: 56px !important;
    height: 56px !important;
    min-width: 56px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
    transition: all 0.2s ease !important;
}

@media (hover: hover) {
    .magiccl-single-floating-button:hover {
        transform: scale(1.05);
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
    }
}

/* ============================================================
   Button Content Layout
   ============================================================ */

.magiccl-button-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.magiccl-checklist-icon {
    display: block;
    flex-shrink: 0;
    object-fit: contain;
}

/* ============================================================
   Priority Indicator
   ============================================================ */

.magiccl-priority-indicator {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    z-index: 2;
}

/* ============================================================
   Tooltip Styles
   ============================================================ */

.magiccl-tooltip {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(100% + 8px);
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 1000;
    pointer-events: none;
}

.magiccl-tooltip-arrow {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid rgba(0, 0, 0, 0.9);
}

.magiccl-speed-dial-item:hover .magiccl-tooltip {
    opacity: 1;
    visibility: visible;
}

/* For top positioned containers, show tooltip below */
.magiccl-speed-dial-container.position-top-right .magiccl-tooltip,
.magiccl-speed-dial-container.position-top-left .magiccl-tooltip,
.magiccl-speed-dial-container.has-draggable-fab.magiccl-positioned-top .magiccl-tooltip {
    bottom: auto;
    top: calc(100% + 8px);
}

.magiccl-speed-dial-container.position-top-right .magiccl-tooltip-arrow,
.magiccl-speed-dial-container.position-top-left .magiccl-tooltip-arrow,
.magiccl-speed-dial-container.has-draggable-fab.magiccl-positioned-top .magiccl-tooltip-arrow {
    top: auto;
    bottom: 100%;
    border-top: none;
    border-bottom: 5px solid rgba(0, 0, 0, 0.9);
}

/* ============================================================
   Dragging States
   ============================================================ */

.magiccl-speed-dial-wrapper.magiccl-dragging,
.magiccl-single-button-wrapper.magiccl-dragging {
    cursor: grabbing !important;
    opacity: 0.8;
    z-index: 999999;
}

.magiccl-speed-dial-wrapper.magiccl-dragging .magiccl-speed-dial-trigger,
.magiccl-single-button-wrapper.magiccl-dragging .magiccl-single-floating-button {
    transform: scale(1.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
}

/* ============================================================
   Animation Delays for Speed Dial Items
   ============================================================ */

.magiccl-speed-dial-menu.open .magiccl-speed-dial-item {
    animation: magiccl-speed-dial-item-appear 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes magiccl-speed-dial-item-appear {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.magiccl-speed-dial-item:nth-child(1) { animation-delay: 0.05s; }
.magiccl-speed-dial-item:nth-child(2) { animation-delay: 0.1s; }
.magiccl-speed-dial-item:nth-child(3) { animation-delay: 0.15s; }
.magiccl-speed-dial-item:nth-child(4) { animation-delay: 0.2s; }
.magiccl-speed-dial-item:nth-child(5) { animation-delay: 0.25s; }

/* ============================================================
   Responsive Design
   ============================================================ */

@media (max-width: 768px) {
    .magiccl-speed-dial-container {
        /* Reduce spacing on mobile */
    }
    
    /* Touch experience improvements handled by global hover media queries */
    
    .magiccl-speed-dial-container.magiccl-multi-fab.position-bottom-right,
    .magiccl-speed-dial-container.magiccl-multi-fab.position-bottom-left,
    .magiccl-speed-dial-container.magiccl-single-fab.position-bottom-right,
    .magiccl-speed-dial-container.magiccl-single-fab.position-bottom-left,
    .magiccl-speed-dial-container.has-draggable,
    .magiccl-speed-dial-container.has-draggable-fab {
        bottom: 15px;
    }
    
    .magiccl-speed-dial-container.magiccl-multi-fab.position-bottom-right,
    .magiccl-speed-dial-container.magiccl-single-fab.position-bottom-right,
    .magiccl-speed-dial-container.has-draggable,
    .magiccl-speed-dial-container.has-draggable-fab {
        right: 15px;
    }
    
    .magiccl-speed-dial-container.magiccl-multi-fab.position-bottom-left,
    .magiccl-speed-dial-container.magiccl-single-fab.position-bottom-left {
        left: 15px;
    }
    
    
    .magiccl-speed-dial-item .magiccl-speed-dial-button {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
    }
    
    .magiccl-speed-dial-menu {
        bottom: 40px;
    }
    
    .magiccl-speed-dial-container.position-top-right .magiccl-speed-dial-menu,
    .magiccl-speed-dial-container.position-top-left .magiccl-speed-dial-menu,
    .magiccl-speed-dial-container.has-draggable-fab.magiccl-positioned-top .magiccl-speed-dial-menu {
        top: 60px;
    }
}

/* ============================================================
   Focus States for Accessibility
   ============================================================ */

.magiccl-speed-dial-trigger:focus-visible,
.magiccl-single-floating-button:focus-visible,
.magiccl-speed-dial-button:focus-visible {
    outline: 2px solid #3b82f6 !important;
    outline-offset: 2px !important;
}

/* ============================================================
   Screen Reader Only
   ============================================================ */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================================
   Hide elements during initialization
   ============================================================ */

.magiccl-speed-dial-wrapper.initializing,
.magiccl-single-button-wrapper.initializing {
    visibility: hidden;
    opacity: 0;
    transition: none !important;
}