/**
 * ParentProof - Mobile Experience Improvements
 * Optimized layouts and interactions for mobile devices
 */

/* ============================================
   BROWSE PAGE - MOBILE IMPROVEMENTS
   ============================================ */

/* Clean up results header on mobile */
@media (max-width: 767.98px) {
    /* Make the entire results header more compact */
    .d-flex.justify-content-between.align-items-center.mb-3 {
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-bottom: 1rem !important;
    }
    
    /* View toggle - smaller and cleaner */
    .view-toggle {
        order: 1;
        flex: 0 0 auto;
    }
    
    .view-toggle .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
        border: 1px solid var(--border-color, #E2E8F0);
        background: var(--bg-white, #FFFFFF);
        color: var(--text-primary, #1E293B);
    }
    
    .view-toggle .btn.active {
        background: var(--gradient-primary-start, #009969);
        color: var(--bg-white, #FFFFFF);
        border-color: var(--gradient-primary-start, #009969);
    }
    
    .view-toggle .btn i {
        font-size: 0.875rem;
    }
    
    /* Hide "All Channels" heading on mobile */
    .d-flex.justify-content-between.align-items-center.mb-3 h4 {
        display: none;
    }
    
    /* Action area - stack compactly */
    .d-flex.justify-content-between.align-items-center.mb-3 > div:last-child {
        order: 2;
        flex: 1 1 auto;
        justify-content: flex-end;
        gap: 0.5rem !important;
    }
    
    .d-flex.justify-content-between.align-items-center.mb-3 .btn-primary {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
        white-space: nowrap;
    }
    
    .d-flex.justify-content-between.align-items-center.mb-3 .badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
}

/* Hide filter sidebar by default on mobile, show toggle button */
@media (max-width: 991.98px) {
    /* Filter sidebar - collapsed by default on mobile */
    #filterSidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 350px;
        height: 100vh;
        background: var(--bg-white, #FFFFFF);
        z-index: 1050;
        overflow-y: auto;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    #filterSidebar.show {
        left: 0;
    }
    
    /* Overlay when filters are open */
    .filter-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
    }
    
    .filter-overlay.show {
        display: block;
    }
    
    /* Mobile filter toggle button */
    #mobileFilterToggle {
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 1000;
        width: 60px;
        height: 60px;
        border-radius: 50%;
        background: #0d6efd;
        color: white;
        border: none;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
    }
    
    /* Table/Card view toggles - make more visible on mobile */
    .view-toggle-buttons {
        position: sticky;
        top: 70px;
        z-index: 100;
        background: var(--bg-white, #FFFFFF);
        padding: 10px 0;
        margin-bottom: 15px;
        border-bottom: 2px solid var(--border-color, #E2E8F0);
    }
}

/* ============================================
   CHANNEL PAGE - MOBILE IMPROVEMENTS
   ============================================ */

@media (max-width: 767.98px) {
    /* 3. Stimulation badge - allow wrapping to two lines */
    .channel-header .badge.fs-6 {
        white-space: normal !important;
        line-height: 1.4;
        padding: 0.5rem 0.75rem;
        max-width: 100%;
        word-wrap: break-word;
    }
    
    
    /* 6. Age Bracket Scores - show overall, collapse others */
    .age-bracket-card:not(.bracket-overall) .card-body .border-top {
        display: none;
    }
    
    .age-bracket-card:not(.bracket-overall) .expand-bracket-btn {
        display: block !important;
        margin-top: 10px;
    }
    
    .age-bracket-card:not(.bracket-overall).expanded .card-body .border-top {
        display: block;
    }
    
    .age-bracket-card:not(.bracket-overall).expanded .expand-bracket-btn i {
        transform: rotate(180deg);
    }
    
    /* 9. Assessment Details - collapsed by default on mobile */
    .assessment-details-card .card-body {
        display: none;
    }
    
    .assessment-details-card.expanded .card-body {
        display: block;
    }
    
    .assessment-details-card .card-header {
        cursor: pointer;
        user-select: none;
    }
    
    .assessment-details-card .card-header::after {
        content: '\f282';
        font-family: 'bootstrap-icons';
        float: right;
        transition: transform 0.3s;
    }
    
    .assessment-details-card.expanded .card-header::after {
        transform: rotate(180deg);
    }
    
    /* 10. Community Voting Activity - collapsed by default on mobile */
    .community-voting-card .card-body {
        display: none;
    }
    
    .community-voting-card.expanded .card-body {
        display: block;
    }
    
    .community-voting-card .card-header {
        cursor: pointer;
        user-select: none;
    }
    
    .community-voting-card .card-header::after {
        content: '\f282';
        font-family: 'bootstrap-icons';
        float: right;
        transition: transform 0.3s;
    }
    
    .community-voting-card.expanded .card-header::after {
        transform: rotate(180deg);
    }
}

/* 7. Score Change History - collapsed by default on ALL devices */
.score-history-card .card-body {
    display: none;
}

.score-history-card.expanded .card-body {
    display: block;
}

.score-history-card .card-header {
    cursor: pointer;
    user-select: none;
}

.score-history-card .card-header::after {
    content: '\f282';
    font-family: 'bootstrap-icons';
    float: right;
    transition: transform 0.3s;
}

.score-history-card.expanded .card-header::after {
    transform: rotate(180deg);
}

/* 11. Parent Friendliness - hide multi-model consensus by default on mobile */
@media (max-width: 767.98px) {
    /* Hide multi-model consensus section by default on mobile */
    .parent-friendliness-consensus {
        display: none;
    }

    .parent-friendliness-consensus.show {
        display: block;
    }

    .consensus-toggle-link {
        cursor: pointer;
        color: #0d6efd;
        text-decoration: none;
        font-size: 0.875rem;
        display: inline-block;
        margin-top: 10px;
    }

    .consensus-toggle-link:hover {
        text-decoration: underline;
    }

    .consensus-toggle-link i {
        transition: transform 0.3s;
    }

    .consensus-toggle-link.expanded i {
        transform: rotate(180deg);
    }
}

/* On desktop, always show consensus */
@media (min-width: 768px) {
    .parent-friendliness-consensus {
        display: block !important;
    }
    
    .consensus-toggle-link {
        display: none !important;
    }
}

/* 12. Top Videos - hide duration */
.top-videos-duration {
    display: none;
}

/* ============================================
   VIDEO PAGE - MOBILE IMPROVEMENTS
   ============================================ */

@media (max-width: 767.98px) {
    /* 14. Stimulation Level Details - collapsed by default on mobile */
 
    
    .video-stimulation-details.expanded .card-body {
        display: block;
    }
    
    .video-stimulation-details .card-header {
        cursor: pointer;
        user-select: none;
    }
    
    .video-stimulation-details .card-header::after {
        content: '\f282';
        font-family: 'bootstrap-icons';
        float: right;
        transition: transform 0.3s;
    }
    
    .video-stimulation-details.expanded .card-header::after {
        transform: rotate(180deg);
    }
    
    /* 15. Video Age Bracket Scores - show overall, collapse others */
    .video-bracket-card:not(.bracket-overall) .card-body .border-top {
        display: none;
    }
    
    .video-bracket-card:not(.bracket-overall) .expand-bracket-btn {
        display: block !important;
        margin-top: 10px;
    }
    
    .video-bracket-card:not(.bracket-overall).expanded .card-body .border-top {
        display: block;
    }
    
    .video-bracket-card:not(.bracket-overall).expanded .expand-bracket-btn i {
        transform: rotate(180deg);
    }
}

/* ============================================
   EDUCATIONAL SUBJECTS & BADGES
   ============================================ */

@media (max-width: 767.98px) {
    .badge {
        white-space: normal !important;
        word-wrap: break-word;
        text-align: center;
        line-height: 1.3;
    }
    
    .parent-friendliness-consensus {
        display: none;
    }
    
    .parent-friendliness-consensus.show {
        display: block;
    }
    
    /* Make view toggle buttons more prominent on mobile */
    #viewToggle {
        position: sticky;
        top: 60px;
        z-index: 100;
        background: var(--bg-white, #FFFFFF);
        padding: 0.75rem 0;
        margin-bottom: 1rem;
        border-bottom: 2px solid var(--border-color, #E2E8F0);
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    #viewToggle .btn-group {
        width: 100%;
    }
    
    #viewToggle .btn {
        flex: 1;
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
    }
}

/* ============================================
   GENERAL MOBILE IMPROVEMENTS
   ============================================ */

@media (max-width: 767.98px) {
    /* Better spacing for mobile */
    .card {
        margin-bottom: 1rem;
    }
    
    /* Make badges more readable on mobile */
    .badge {
        padding: 0.35em 0.65em;
        font-size: 0.875rem;
    }
    
    /* Improve button sizes for touch */
    .btn-sm {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Better table spacing on mobile */
    .table-sm > :not(caption) > * > * {
        padding: 0.5rem;
    }
    
    /* Collapsible section indicators */
    .collapsible-header {
        position: relative;
        padding-right: 2rem;
    }
    
    .expand-btn {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        cursor: pointer;
        color: #0d6efd;
        text-decoration: none;
        font-size: 0.875rem;
        margin-top: 0.5rem;
    }
    
    .expand-btn:hover {
        text-decoration: underline;
    }
    
    .expand-btn i {
        transition: transform 0.3s;
    }
    
    .expand-btn.expanded i {
        transform: rotate(180deg);
    }
}

/* Smooth transitions for all collapsible elements */
.card-body {
    transition: max-height 0.3s ease-out;
}

/* Hidden class for elements that should be completely hidden */
.mobile-hidden {
    display: none !important;
}

/* Desktop only class */
@media (max-width: 991.98px) {
    .desktop-only {
        display: none !important;
    }
}

/* Mobile only class */
@media (min-width: 992px) {
    .mobile-only {
        display: none !important;
    }
}

/* Utility classes for responsive visibility */
.expand-bracket-btn {
    display: none;
    width: 100%;
    text-align: center;
    padding: 0.5rem;
    background: transparent;
    border: 1px solid var(--border-color, #E2E8F0);
    border-radius: 0.25rem;
    cursor: pointer;
    color: var(--gradient-primary-start, #009969);
    font-size: 0.875rem;
}

.expand-bracket-btn:hover {
    background: var(--bg-page, #F8FAFC);
}

.expand-bracket-btn i {
    transition: transform 0.3s;
    margin-left: 0.25rem;
}

/* ============================================
   CHANNEL HEADER - MOBILE COMPACTNESS
   ============================================ */

@media (max-width: 767.98px) {
    /* Make channel thumbnail smaller on mobile */
    .card-body .d-flex.align-items-start img.rounded {
        width: 80px !important;
        height: 80px !important;
        margin-right: 0.75rem !important;
    }
    
    /* Reduce channel title font size */
    .card-body .h3 {
        font-size: 1.25rem !important;
        margin-bottom: 0.5rem !important;
        line-height: 1.3;
    }
    
    /* Reduce subscriber count text size and spacing */
    .card-body .text-muted.mb-3 {
        font-size: 0.875rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    /* Make primary score/stimulation badges more compact */
    .card-body .badge.fs-5 {
        font-size: 0.875rem !important;
        padding: 0.35rem 0.6rem !important;
    }
    
    /* Make secondary badges more compact */
    .card-body .badge.fs-6 {
        font-size: 0.75rem !important;
        padding: 0.3rem 0.5rem !important;
    }
    
    /* Reduce gap between badge groups */
    .card-body .d-flex.flex-wrap.gap-2 {
        gap: 0.5rem !important;
    }
    
    /* Make all badges in header area more compact */
    .card-body .badge {
        font-size: 0.75rem !important;
        padding: 0.25rem 0.5rem !important;
    }
}

/* ============================================
   AGE BRACKET CARDS - REMOVE WHITE BACKGROUND
   ============================================ */

/* Remove white background from age bracket score cards */
.age-bracket-card .card-body {
    background-color: transparent !important;
    background: none !important;
}

/* Ensure card itself has no white background */
.age-bracket-card {
    background-color: transparent !important;
}
