﻿/* Floating Modal Positioning Fixes */

/* Base floating button positioning - respecting footer content */
.sticky-search-actions {
    position: fixed;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    /* Default positioning - will be overridden by responsive rules */
    bottom: 80px; /* Start higher to avoid footer */
    right: 20px;
    left: auto;
    width: auto;
    max-width: 300px;
}

/* Ensure footer has enough space */
.public-footer {
    margin-bottom: env(safe-area-inset-bottom, 0px);
    padding-bottom: 0.5rem;
}

/* Better positioning on large screens */
@media (min-width: 992px) {
    .sticky-search-actions {
        bottom: 20px;
        right: 20px;
        left: auto;
        width: auto;
        max-width: 280px;
        flex-direction: row;
    }

    /* When footer is visible, position higher */
    body:has(.public-footer) .sticky-search-actions {
        bottom: 100px; /* Space for footer + some margin */
    }
}

/* Medium screens (tablets) */
@media (min-width: 769px) and (max-width: 991px) {
    .sticky-search-actions {
        bottom: 90px; /* Higher positioning for footer */
        left: 50%;
        transform: translateX(-50%);
        right: auto;
        width: auto;
        max-width: 400px;
        flex-direction: row;
    }
}

/* Mobile responsive - avoid footer overlap */
@media (max-width: 768px) {
    .sticky-search-actions {
        bottom: 90px; /* Higher to clear footer */
        left: 10px;
        right: 10px;
        width: auto;
        max-width: none;
        flex-direction: row;
        padding: 0.75rem;
        gap: 0.5rem;
    }

        .sticky-search-actions .btn {
            flex: 1;
            font-size: 0.9rem;
            padding: 0.75rem 0.5rem;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 0.375rem;
            min-height: 44px;
        }

            /* Ensure button text is visible */
            .sticky-search-actions .btn .btn-icon {
                font-size: 0.95rem;
                flex-shrink: 0;
            }

            .sticky-search-actions .btn .btn-text {
                display: inline-block !important;
                font-weight: 500;
                font-size: 0.85rem;
            }
}

/* Compact mobile screens */
@media (max-width: 480px) {
    .sticky-search-actions {
        bottom: 85px; /* Slightly higher for very small screens */
        padding: 0.5rem;
        gap: 0.375rem;
        border-radius: 8px;
    }

        .sticky-search-actions .btn {
            padding: 0.625rem 0.75rem;
            font-size: 0.8rem;
            gap: 0.25rem;
            min-height: 40px;
        }

            .sticky-search-actions .btn .btn-icon {
                font-size: 0.85rem;
            }

            .sticky-search-actions .btn .btn-text {
                font-size: 0.75rem !important;
                display: inline-block !important;
            }
}

/* Extra small screens - stack buttons if needed */
@media (max-width: 360px) {
    .sticky-search-actions {
        flex-direction: column;
        gap: 0.375rem;
        padding: 0.5rem;
        bottom: 90px; /* Even higher for very small screens */
    }

        .sticky-search-actions .btn {
            width: 100%;
            padding: 0.75rem;
            gap: 0.375rem;
        }

            .sticky-search-actions .btn .btn-text {
                font-size: 0.8rem !important;
            }
}

/* Adaptive positioning based on footer visibility */
.sticky-search-actions.footer-visible {
    bottom: 120px; /* Extra space when footer is definitely visible */
}

/* Button styling improvements */
.sticky-search-actions .btn {
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.sticky-search-actions .btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

    .sticky-search-actions .btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
    }

.sticky-search-actions .btn-secondary {
    background: #6b7280;
    color: white;
    box-shadow: 0 4px 12px rgba(107, 114, 128, 0.2);
}

    .sticky-search-actions .btn-secondary:hover {
        background: #4b5563;
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(107, 114, 128, 0.3);
    }

/* Animation for appearance */
.sticky-search-actions {
    animation: slideInFromBottom 0.3s ease-out;
}

@keyframes slideInFromBottom {
    from {
        opacity: 0;
        transform: translateY(100%) translateX(var(--translate-x, 0));
    }

    to {
        opacity: 1;
        transform: translateY(0) translateX(var(--translate-x, 0));
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .sticky-search-actions {
        border: 2px solid #000;
        background: #fff;
    }

        .sticky-search-actions .btn {
            border: 2px solid;
        }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .sticky-search-actions {
        animation: none;
    }

        .sticky-search-actions .btn:hover {
            transform: none;
        }
}

/* Safe area support for devices with notches/dynamic islands */
@supports (bottom: env(safe-area-inset-bottom)) {
    .sticky-search-actions {
        bottom: calc(80px + env(safe-area-inset-bottom));
    }

    @media (max-width: 768px) {
        .sticky-search-actions {
            bottom: calc(90px + env(safe-area-inset-bottom));
        }
    }
}

/* Hide floating buttons when printing */
@media print {
    .sticky-search-actions {
        display: none !important;
    }
}

/* Focus management for accessibility */
.sticky-search-actions .btn:focus {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
}

    .sticky-search-actions .btn:focus:not(:focus-visible) {
        outline: none;
    }

/* Backdrop for very small screens when needed */
@media (max-width: 320px) {
    .sticky-search-actions {
        background: rgba(255, 255, 255, 0.98);
        border: 2px solid #e2e8f0;
    }
}
