/**
 * Modal Scroll Improvements
 * Makes scrolling more obvious to customers on both desktop and mobile
 * Addresses the issue where customers don't realize they need to scroll
 */

/* ========================================
   SCROLL INDICATOR STYLES
   ======================================== */

/* Scroll hint element */
.esim-scroll-hint {
    position: sticky !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background: linear-gradient(to top, rgba(255,255,255,0.95), transparent) !important;
    padding: 12px 0 8px 0 !important;
    text-align: center !important;
    font-size: 13px !important;
    color: #6b7280 !important;
    font-weight: 500 !important;
    z-index: 10 !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease !important;
    border-top: 1px solid rgba(226, 232, 240, 0.5) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
}

/* Animated scroll arrow */
.esim-scroll-hint::before {
    content: '↓' !important;
    display: inline-block !important;
    margin-right: 6px !important;
    animation: scrollBounce 2s infinite !important;
    font-size: 16px !important;
    color: #3b82f6 !important;
}

@keyframes scrollBounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-4px);
    }
    60% {
        transform: translateY(-2px);
    }
}

/* Hide scroll hint when scrolled to bottom */
.esim-modal-body.scrolled-bottom .esim-scroll-hint {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ========================================
   VISUAL SCROLL INDICATORS
   ======================================== */

/* Add shadow gradient at top when scrolled */
.esim-modal-body.has-scroll::before {
    content: '' !important;
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 20px !important;
    background: linear-gradient(to bottom, rgba(255,255,255,1), transparent) !important;
    z-index: 5 !important;
    pointer-events: none !important;
    opacity: 0 !important;
    transition: opacity 0.3s ease !important;
}

/* Show top shadow when scrolled */
.esim-modal-body.has-scroll.scrolled::before {
    opacity: 1 !important;
}

/* Bottom fade gradient when more content below */
.esim-modal-body.has-scroll:not(.scrolled-bottom)::after {
    content: '' !important;
    position: sticky !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 30px !important;
    background: linear-gradient(to top, rgba(255,255,255,0.9), transparent) !important;
    z-index: 4 !important;
    pointer-events: none !important;
}

/* ========================================
   SCROLLBAR STYLING
   ======================================== */

/* Custom scrollbar for modal body */
.esim-modal-body::-webkit-scrollbar {
    width: 8px !important;
    background: transparent !important;
}

.esim-modal-body::-webkit-scrollbar-track {
    background: rgba(243, 244, 246, 0.5) !important;
    border-radius: 4px !important;
}

.esim-modal-body::-webkit-scrollbar-thumb {
    background: #94a3b8 !important;
    border-radius: 4px !important;
    transition: background 0.2s ease !important;
}

.esim-modal-body::-webkit-scrollbar-thumb:hover {
    background: #64748b !important;
}

/* Firefox scrollbar */
.esim-modal-body {
    scrollbar-width: thin !important;
    scrollbar-color: #94a3b8 rgba(243, 244, 246, 0.5) !important;
}

/* ========================================
   MODAL BODY SCROLL ENHANCEMENTS
   ======================================== */

/* Ensure modal body is scrollable */
.esim-modal-body {
    max-height: calc(85vh - 120px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 24px 28px !important;
    position: relative !important;
    scroll-behavior: smooth !important;
}

/* Add scroll momentum on iOS */
.esim-modal-body {
    -webkit-overflow-scrolling: touch !important;
}

/* ========================================
   SCROLL POSITION INDICATOR
   ======================================== */

/* Scroll progress bar */
.esim-modal-content::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    height: 3px !important;
    background: #3b82f6 !important;
    z-index: 100 !important;
    transition: width 0.1s ease !important;
    width: 0% !important;
}

.esim-modal-content.has-scroll::before {
    width: var(--scroll-progress, 0%) !important;
}

/* ========================================
   MOBILE SPECIFIC IMPROVEMENTS
   ======================================== */

@media (max-width: 768px) {
    /* Larger scroll hint on mobile */
    .esim-scroll-hint {
        font-size: 14px !important;
        padding: 16px 0 12px 0 !important;
    }
    
    .esim-scroll-hint::before {
        font-size: 18px !important;
        margin-right: 8px !important;
    }
    
    /* More prominent scrollbar on mobile */
    .esim-modal-body::-webkit-scrollbar {
        width: 12px !important;
    }
    
    .esim-modal-body::-webkit-scrollbar-thumb {
        background: #64748b !important;
        border-radius: 6px !important;
    }
    
    /* Touch-friendly scroll area */
    .esim-modal-body {
        padding: 20px 20px 60px 20px !important; /* Extra bottom padding for scroll hint */
    }
    
    /* Mobile scroll bounce */
    .esim-modal-body.has-scroll .esim-scroll-hint::before {
        animation: scrollBounceMobile 1.5s infinite !important;
    }
    
    @keyframes scrollBounceMobile {
        0%, 100% { transform: translateY(0); }
        50% { transform: translateY(-6px); }
    }
}

/* ========================================
   CONTENT LENGTH INDICATORS
   ======================================== */

/* Show approximate content length */
.esim-modal-body.has-scroll::after {
    content: attr(data-scroll-hint) !important;
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    background: rgba(0, 0, 0, 0.8) !important;
    color: white !important;
    padding: 6px 12px !important;
    border-radius: 20px !important;
    font-size: 11px !important;
    z-index: 1000 !important;
    opacity: 0 !important;
    transition: opacity 0.3s ease !important;
    pointer-events: none !important;
}

.esim-modal-body.has-scroll.show-scroll-hint::after {
    opacity: 1 !important;
}

/* ========================================
   IMPROVED MODAL BEHAVIOR
   ======================================== */

/* Ensure modal content is properly sized */
.esim-modal-content {
    max-height: 85vh !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Header stays fixed */
.esim-modal-header {
    flex-shrink: 0 !important;
    position: relative !important;
    z-index: 10 !important;
}

/* Body is scrollable */
.esim-modal-body {
    flex: 1 !important;
    min-height: 0 !important;
}

/* Footer stays fixed if exists */
.esim-modal-footer {
    flex-shrink: 0 !important;
    position: relative !important;
    z-index: 10 !important;
    background: white !important;
    border-top: 1px solid #e2e8f0 !important;
    padding: 16px 28px !important;
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

/* Screen reader announcements */
.esim-modal-body[aria-label] {
    /* Screen readers will announce scroll status */
}

/* Focus management for scrollable content */
.esim-modal-body:focus {
    outline: 2px solid #3b82f6 !important;
    outline-offset: -2px !important;
}

/* Keyboard navigation hints */
.esim-modal-body::before {
    content: attr(data-keyboard-hint) !important;
    position: absolute !important;
    top: -30px !important;
    left: 0 !important;
    font-size: 11px !important;
    color: #6b7280 !important;
    opacity: 0 !important;
    transition: opacity 0.3s ease !important;
}

.esim-modal-body:focus::before {
    opacity: 1 !important;
}

/* ========================================
   ANIMATION AND INTERACTION
   ======================================== */

/* Smooth scroll behavior */
.esim-modal-body {
    scroll-behavior: smooth !important;
}

/* Pulse effect for scroll hint when modal opens */
.esim-scroll-hint.just-opened {
    animation: scrollHintPulse 3s ease-out !important;
}

@keyframes scrollHintPulse {
    0% { opacity: 0; transform: translateY(10px); }
    20% { opacity: 1; transform: translateY(0); }
    80% { opacity: 1; }
    100% { opacity: 0.8; }
}

/* Gentle scroll nudge on hover */
.esim-modal-body:hover .esim-scroll-hint::before {
    animation-duration: 1s !important;
}

/* ========================================
   FALLBACK FOR OLDER BROWSERS
   ======================================== */

/* For browsers that don't support backdrop-filter */
@supports not (backdrop-filter: blur(4px)) {
    .esim-scroll-hint {
        background: linear-gradient(to top, rgba(255,255,255,0.98), rgba(255,255,255,0.8)) !important;
    }
}