/* Homepage-only scroll button container */
.homepage-scroll-button-container {
    position: fixed;
    right: 20px;
    bottom: 80px;
    z-index: 9999;
    transition: all 0.3s ease;
    pointer-events: none;
}

/* Single scroll button */
.scroll-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    top:-50px;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    background: linear-gradient(135deg, #e91e63 0%, #5d1ead 50%, #8a4b3c 100%);
    color: white;
    pointer-events: auto;
    display: none;
}

.scroll-toggle-btn.visible {
    opacity: 1;
    transform: translateY(0);
    display: flex;
}

/* Button hover effects */
.scroll-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.3);
}

.scroll-toggle-btn:active {
    transform: scale(0.95);
}

/* Button pulse animation */
@keyframes pulse {
    0% { box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2); }
    50% { box-shadow: 0 8px 20px rgba(138, 43, 226, 0.4); }
    100% { box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2); }
}

.scroll-toggle-btn.pulse {
    animation: pulse 2s infinite;
}

/* Button inner ring effect */
.scroll-toggle-btn::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s ease;
}

.scroll-toggle-btn:hover::after {
    opacity: 1;
    transform: scale(1.1);
}

/* Button icon animation */
.scroll-toggle-btn i {
    transition: transform 0.3s ease;
}

.scroll-toggle-btn:hover i {
    transform: scale(1.2);
}

/* Responsive styles */
@media (max-width: 768px) {
    .homepage-scroll-button-container {
        right: 15px;
        bottom: 70px;
    }
    
    .scroll-toggle-btn {
        width: 55px;
        height: 55px;
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .homepage-scroll-button-container {
        right: 10px;
        bottom: 65px;
    }
    
    .scroll-toggle-btn {
        width: 50px;
        height: 50px;
        font-size: 18px;
    }
}

/* Hide scroll button when modals are open */
.modal-open .homepage-scroll-button-container {
    display: none !important;
}

/* Animation for button appearance */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.scroll-toggle-btn.visible {
    animation: slideInUp 0.3s ease forwards;
}

/* Fix for touch devices */
@media (hover: none) and (pointer: coarse) {
    .scroll-toggle-btn {
        min-width: 50px;
        min-height: 50px;
    }
}

/* Inner page scrollable areas */
.inner-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f0f2f5; /* Match body background */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 1500;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: none;
}

.inner-page.active {
    transform: translateX(0);
    display: block;
    overflow-y: auto;
}

/* FIXED: Ensure inner page header has proper background color */
.inner-page .inner-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: white; /* Solid white background for inner page headers */
    backdrop-filter: none; /* Remove blur effect */
    margin: 0 !important; /* Remove negative margins */
    border-bottom: 1px solid #eee;
}

/* FIXED: Ensure inner header stays within bounds */
.inner-page.active .inner-header {
    margin: 0;
    padding: 1rem;
    width: 100%;
    box-sizing: border-box;
}

/* Podcast page specific scrollable area */
#podcastPage .podcast-content {
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    padding-bottom: 20px;
    position: relative;
}

/* All News page scrollable area */
#allNewsPage .all-news-container {
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    padding-bottom: 20px;
    position: relative;
}

/* Saved Articles page scrollable area */
#savedArticlesPage .saved-articles-container {
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    padding-bottom: 20px;
    position: relative;
}

/* Notifications page scrollable area */
#notificationsPage .notifications-container {
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    padding-bottom: 20px;
    position: relative;
}

/* Categories page scrollable area */
#categoriesPage .categories-management {
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    padding-bottom: 20px;
    position: relative;
}

/* Live TV page scrollable area */
#livePage .live-container {
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    padding-bottom: 20px;
    position: relative;
}

/* Watch page scrollable area */
#watchPage .watch-grid {
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    padding-bottom: 20px;
    position: relative;
}

/* Settings page scrollable area */
#settingsPage .settings-grid {
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    padding-bottom: 20px;
    position: relative;
}

/* Make sure all container elements within inner pages are properly scrollable */
.inner-page > .inner-content {
    height: calc(100% - 60px);
    overflow-y: auto;
    position: relative;
}

/* Hide scroll button when modals are open */
.modal-open .homepage-scroll-button-container {
    display: none !important;
}

body.modal-open > .homepage-scroll-button-container {
    display: none !important;
}

.article-modal.active ~ .homepage-scroll-button-container,
.podcast-modal.active ~ .homepage-scroll-button-container,
.podcast-player-modal.active ~ .homepage-scroll-button-container {
    display: none !important;
}

/* Ensure scroll button is only visible on active pages */
.inner-page:not(.active) .homepage-scroll-button-container {
    display: none !important;
}

/* Main page scroll button visibility */
main:not([style*="display: none"]) ~ .homepage-scroll-button-container {
    display: block !important;
}

/* Ensure proper stacking context */
.homepage-scroll-button-container * {
    pointer-events: auto;
}

/* Arrow rotation states */
.scroll-toggle-btn i.fa-arrow-up {
    transform: rotate(0deg);
}

.scroll-toggle-btn i.fa-arrow-down {
    transform: rotate(0deg);
}

/* Fix for inner page header backgrounds in dark mode */
@media (prefers-color-scheme: dark) {
    .inner-page {
        background-color: #0f172a;
    }
    
    .inner-page .inner-header {
        background: #1e293b; /* Dark mode header background */
        border-bottom: 1px solid #334155;
    }
}
