/* Draggable Elements Module */
.draggable-back-button {
    position: fixed !important;
    z-index: 9999 !important;
    cursor: grab;
    user-select: none;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    border-radius: 50px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8) !important;
    color: white !important;
    border: none;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    display: flex !important;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 14px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.1);
    /* Ensure visibility */
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    /* Default position - removed !important so JavaScript can override */
    top: 20px;
    left: 20px;
    right: auto;
    bottom: auto;
    /* Prevent hiding */
    display: flex !important;
    min-width: 180px;
    min-height: 48px;
    
    /* Mobile-specific improvements */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    
    /* Ensure proper sizing on mobile */
    max-width: calc(100vw - 40px);
    box-sizing: border-box;
}

.draggable-back-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
    cursor: grab;
}

.draggable-back-button:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.draggable-back-button.dragging {
    cursor: grabbing;
    transform: scale(0.95);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.5);
}

.draggable-back-button .arrow-left,
.draggable-back-button .arrow-right {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
}

.draggable-back-button:hover .arrow-left,
.draggable-back-button:hover .arrow-right {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.draggable-back-button .button-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.2;
}

.draggable-back-button .button-text .main-text {
    font-weight: 600;
    font-size: 16px;
}

.draggable-back-button .button-text .sub-text {
    font-size: 12px;
    opacity: 0.9;
}

/* Animation for button appearance */
@keyframes draggableButtonAppear {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.draggable-back-button {
    animation: draggableButtonAppear 0.3s ease-out;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .draggable-back-button {
        padding: 10px 20px;
        font-size: 12px;
        min-width: 150px;
        min-height: 40px;
    }
    
    .draggable-back-button .arrow-left,
    .draggable-back-button .arrow-right {
        width: 16px;
        height: 16px;
        font-size: 10px;
    }
    
    .draggable-back-button .button-text .main-text {
        font-size: 14px;
    }
    
    .draggable-back-button .button-text .sub-text {
        font-size: 10px;
    }
}

/* Dark mode support */
body.dark-mode .draggable-back-button {
    background: linear-gradient(135deg, #1e40af, #1e3a8a) !important;
    color: #f8fafc !important;
    box-shadow: 0 4px 15px rgba(30, 64, 175, 0.4);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .draggable-back-button {
        border: 3px solid white;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    }
}

/* Mobile-specific styles */
@media (max-width: 768px) {
    .draggable-back-button {
        padding: 10px 20px;
        font-size: 13px;
        min-width: 160px;
        min-height: 44px;
        border-radius: 40px;
        
        /* Better mobile positioning */
        top: 15px !important;
        left: 15px !important;
        
        /* Enhanced mobile visibility */
        box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
        border: 2px solid rgba(255, 255, 255, 0.2);
    }
    
    .draggable-back-button svg {
        width: 14px;
        height: 14px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .draggable-back-button {
        /* Larger touch target */
        min-height: 48px;
        padding: 12px 24px;
        
        /* Better touch feedback */
        transition: transform 0.15s ease, box-shadow 0.15s ease;
    }
    
    .draggable-back-button:active {
        transform: scale(0.95);
        box-shadow: 0 8px 25px rgba(59, 130, 246, 0.5);
    }
}
