/* ========================================
   SMOOTH SCROLL & WHITE BOX FIXES
   Fixes for carousel scroll and white boxes in dashboard/consejos
   ======================================== */

/* ========================================
   1. SMOOTH SCROLL FOR LEVEL CAROUSEL
   ======================================== */

/* Enable smooth scrolling globally */
html {
    scroll-behavior: smooth;
}

/* Level Carousel Container */
.levels-carousel-container,
.carousel-container {
    position: relative;
    padding: 20px 0;
}

.levels-carousel-container .levels-grid,
.carousel-container .levels-grid,
.carousel-container .features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    padding: 0 20px;
}

/* Desktop: Grid layout */
@media (min-width: 769px) {
    .levels-carousel-container .levels-grid {
        display: grid !important;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 25px;
        overflow: visible !important;
    }

    /* Hide carousel indicators on desktop */
    .carousel-indicators {
        display: none !important;
    }
}

/* Mobile: Smooth Scrolling Carousel */
@media (max-width: 768px) {

    .levels-carousel-container .levels-grid,
    .carousel-container .levels-grid,
    .carousel-container .features-grid {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch !important;
        scroll-behavior: smooth !important;
        gap: 15px !important;
        padding: 10px 15px 25px 15px !important;
        margin: 0 -15px !important;
        width: calc(100% + 30px) !important;

        /* Hide scrollbar but keep functionality */
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
    }

    .levels-carousel-container .levels-grid::-webkit-scrollbar,
    .carousel-container .levels-grid::-webkit-scrollbar,
    .carousel-container .features-grid::-webkit-scrollbar {
        display: none !important;
    }

    /* Card sizing for smooth scroll */
    .levels-carousel-container .level-card:not(.special),
    .carousel-container .level-card:not(.special),
    .carousel-container .feature-card {
        flex: 0 0 85% !important;
        min-width: 280px !important;
        max-width: 350px !important;
        scroll-snap-align: center;
        scroll-snap-stop: always;
        transition: transform 0.3s ease, box-shadow 0.3s ease !important;
    }

    /* Add subtle scroll padding */
    .levels-carousel-container .levels-grid,
    .carousel-container .levels-grid {
        scroll-padding: 15px;
    }

    /* Fade edges */
    .levels-carousel-container .levels-grid,
    .carousel-container .levels-grid {
        -webkit-mask-image: linear-gradient(to right,
                transparent 0px,
                black 20px,
                black calc(100% - 20px),
                transparent 100%) !important;
        mask-image: linear-gradient(to right,
                transparent 0px,
                black 20px,
                black calc(100% - 20px),
                transparent 100%) !important;
    }

    /* Carousel indicators removed to favor progress bar */
}

/* ========================================
   2. FIX WHITE BOXES IN DARK MODE
   Dashboard and Consejos pages
   ======================================== */

/* Hero Section */
.hero-dashboard,
.hero-section {
    background: transparent !important;
    padding: 40px 30px;
}

html.dark-mode .hero-dashboard,
html.dark-mode .hero-section {
    background: transparent !important;
}

/* Mission Section */
.mission-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 30px;
    transition: all 0.3s ease;
}

html.dark-mode .mission-section {
    background: #334155 !important;
    border-color: #475569 !important;
}

/* Features Dashboard */
.features-dashboard {
    padding: 40px 30px;
    background: transparent !important;
}

html.dark-mode .features-dashboard {
    background: transparent !important;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 30px;
    transition: all 0.3s ease;
}

html.dark-mode .feature-card {
    background: #334155 !important;
    border-color: #475569 !important;
}

html.dark-mode .feature-card:hover {
    background: #475569 !important;
    border-color: #64748b !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4) !important;
}

/* Developer Section */
.developer-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 30px;
}

html.dark-mode .developer-section {
    background: #334155 !important;
    border-color: #475569 !important;
}

.developer-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 25px;
}

html.dark-mode .developer-card {
    background: #1e293b !important;
    border-color: #475569 !important;
}

/* Roadmap Section */
.roadmap-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 30px;
}

html.dark-mode .roadmap-section {
    background: #334155 !important;
    border-color: #475569 !important;
}

.roadmap-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
}

html.dark-mode .roadmap-item {
    background: #1e293b !important;
    border-color: #475569 !important;
}

/* Support Section */
.support-project-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 30px;
}

html.dark-mode .support-project-section {
    background: #334155 !important;
    border-color: #475569 !important;
}

.donation-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 30px;
}

html.dark-mode .donation-card {
    background: #1e293b !important;
    border-color: #475569 !important;
}

/* ========================================
   3. CONSEJOS PAGE WHITE BOXES
   ======================================== */

/* Schedule Section */
.schedule-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 30px;
}

html.dark-mode .schedule-section {
    background: #334155 !important;
    border-color: #475569 !important;
}

.time-block {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 20px;
}

html.dark-mode .time-block {
    background: #1e293b !important;
    border-color: #475569 !important;
}

.time-period {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    margin-bottom: 15px;
}

html.dark-mode .time-period {
    background: linear-gradient(135deg, #475569 0%, #64748b 100%) !important;
}

.activity-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 10px;
}

html.dark-mode .activity-item {
    background: #334155 !important;
    border-color: #475569 !important;
}

html.dark-mode .activity-item:hover {
    background: #475569 !important;
}

/* YouTube Channels */
.youtube-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 30px;
}

html.dark-mode .youtube-section {
    background: #334155 !important;
    border-color: #475569 !important;
}

.channel-category {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 20px;
}

html.dark-mode .channel-category {
    background: #1e293b !important;
    border-color: #475569 !important;
}

.channel-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
}

html.dark-mode .channel-item {
    background: #334155 !important;
    border-color: #475569 !important;
}

html.dark-mode .channel-item:hover {
    background: #ef4444 !important;
    border-color: #ef4444 !important;
    color: white !important;
}

/* ========================================
   4. GENERAL TEXT COLOR FIXES
   ======================================== */

/* Ensure all text is visible in dark mode */
html.dark-mode h1,
html.dark-mode h2,
html.dark-mode h3,
html.dark-mode h4,
html.dark-mode h5,
html.dark-mode h6 {
    color: #f1f5f9 !important;
}

html.dark-mode p,
html.dark-mode li,
html.dark-mode span:not(.icon) {
    color: #cbd5e1 !important;
}

html.dark-mode .section-title {
    color: #f1f5f9 !important;
    border-bottom-color: #475569 !important;
}

html.dark-mode .section-title i {
    color: #818cf8 !important;
}

/* ========================================
   5. MOBILE SPACING FIXES
   ======================================== */

@media (max-width: 768px) {

    /* Consistent section spacing */
    .hero-dashboard,
    .mission-section,
    .features-dashboard,
    .developer-section,
    .roadmap-section,
    .support-project-section,
    .schedule-section,
    .youtube-section {
        padding: 25px 20px !important;
        margin-bottom: 20px !important;
    }

    /* Card spacing */
    .feature-card,
    .developer-card,
    .donation-card,
    .time-block,
    .channel-category {
        padding: 20px !important;
    }

    /* Remove extra margins */
    .content>* {
        margin-bottom: 0 !important;
    }

    /* Section gaps */
    .content>section,
    .content>div {
        margin-bottom: 20px;
    }

    .content>section:last-child,
    .content>div:last-child {
        margin-bottom: 0;
    }
}

/* ========================================
   6. SMOOTH TRANSITIONS
   ======================================== */

/* Smooth transitions for all interactive elements */
.level-card,
.feature-card,
.grammar-card,
.action-card,
.developer-card,
.donation-card,
.time-block,
.activity-item,
.channel-item {
    transition:
        transform 0.3s ease,
        box-shadow 0.3s ease,
        background-color 0.3s ease,
        border-color 0.3s ease !important;
}

/* Prevent layout shift during transitions */
@media (max-width: 768px) {

    .carousel-container .level-card,
    .carousel-container .feature-card {
        transition:
            transform 0.3s ease,
            box-shadow 0.3s ease !important;
        /* NO width/height transitions */
    }
}

/* ========================================
   7. IOS SAFARI FIXES
   ======================================== */

@supports (-webkit-touch-callout: none) {
    @media (max-width: 768px) {

        /* Fix iOS scroll */
        .levels-carousel-container .levels-grid,
        .carousel-container .levels-grid {
            -webkit-overflow-scrolling: touch !important;
        }

        /* Fix iOS mask */
        .levels-carousel-container .levels-grid,
        .carousel-container .levels-grid {
            -webkit-mask-image: -webkit-linear-gradient(left,
                    transparent 0px,
                    black 20px,
                    black 90%,
                    transparent 100%) !important;
            mask-image: linear-gradient(to right,
                    transparent 0px,
                    black 20px,
                    black 90%,
                    transparent 100%) !important;
        }
    }
}

/* ========================================
   8. ACCESSIBILITY
   ======================================== */

/* Focus states */
.carousel-indicator:focus {
    outline: 2px solid #818cf8;
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {

    .level-card,
    .feature-card,
    .grammar-card {
        border: 2px solid currentColor !important;
    }
}