/* Responsive Styles for LiveTV */

/* Large screens (desktop) */
@media (min-width: 992px) {
    .header-container {
        padding: 15px 0;
    }

    .main-menu-wrapper {
        padding: 0;
    }

    /* Hide mobile-only elements on desktop */
    .mobile-search-toggle,
    .mobile-search-panel,
    .mobile-overlay {
        display: none !important;
    }

    /* Ensure desktop menu is always visible regardless of mobile menu state */
    .main-menu {
        max-height: none !important;
        overflow: visible !important;
        transform: none !important;
        position: static !important;
        width: auto !important;
        height: auto !important;
        box-shadow: none !important;
    }
}

/* Medium screens (tablets) */
@media (max-width: 991px) {
    .animated-slogan {
        display: none;
    }

    .header-container {
        padding: 10px 0;
    }

    .logo img {
        max-height: 35px;
    }

    .social-icons a {
        margin-right: 10px;
    }

    .static-link {
        padding: 5px 8px;
        font-size: 0.85rem;
    }

    /* Hide mobile-only elements on tablet */
    .mobile-search-toggle,
    .mobile-search-panel,
    .mobile-overlay {
        display: none !important;
    }
}

/* Small screens (mobile) */
@media (max-width: 767px) {

    /* Prevent horizontal scrolling */
    html,
    body {
        overflow-x: hidden;
        overflow-y: auto !important;
        width: 100%;
        height: auto;
        min-height: 100%;
        position: static;
        -webkit-overflow-scrolling: touch;
    }

    /* Article detail content mobile layout */
    .article-detail-content {
        padding: 15px !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Video responsive styles for mobile - more conservative sizing */
    .article-detail-content .video-auto-responsive {
        width: 100% !important;
        max-width: 100% !important;
        margin: 10px 0 15px 0 !important;
        border-radius: 4px !important;
        padding-bottom: 75% !important;
        /* More reasonable aspect ratio for mobile */
        box-sizing: border-box !important;
    }

    .article-detail-content .video-auto-responsive[style*="padding-bottom"] {
        padding-bottom: 75% !important;
    }

    .article-detail-content .video-auto-responsive iframe[src*="facebook.com"] {
        width: 100% !important;
        height: 100% !important;
    }

    /* Ensure proper text flow around videos */
    .article-detail-content p {
        margin: 10px 0 !important;
        line-height: 1.5 !important;
        word-wrap: break-word !important;
    }

    /* Prevent video iframes from affecting content-wrapper layout */
    .content-wrapper {
        overflow-x: hidden !important;
        overflow-y: visible !important;
        position: relative !important;
        z-index: 1 !important;
    }

    .content-wrapper .article-detail-content {
        position: relative !important;
        z-index: 2 !important;
    }

    .content-wrapper .article-detail-content .video-auto-responsive {
        position: relative !important;
        z-index: 3 !important;
        overflow: hidden !important;
        contain: layout !important;
    }

    .content-wrapper .article-detail-content .video-auto-responsive iframe {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        z-index: 1 !important;
        pointer-events: auto !important;
    }

    /* Header adjustments */
    header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background-color: #222;
        width: 100%;
    }

    .header-container {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 15px;
        background-color: #222;
        color: white;
        width: 100%;
        max-width: 100%;
    }

    /* Logo centered but hidden on mobile */
    .logo {
        flex: 0 0 auto;
        text-align: center;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        background-color: transparent !important;
    }

    /* Light logo visible on mobile (colorful logo) */
    .light-logo {
        display: block !important;
        max-height: 30px;
        background-color: transparent !important;
    }

    /* Dark logo hidden on mobile */
    .dark-logo {
        display: none !important;
    }

    /* Hide animated slogan on mobile */
    .animated-slogan {
        display: none !important;
    }

    .logo img {
        max-height: 30px;
        background-color: transparent !important;
        mix-blend-mode: normal !important;
        -webkit-background-clip: initial !important;
        background-clip: initial !important;
        box-shadow: none !important;
    }

    /* Header right section with search */
    .header-right {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        flex: 1;
    }

    /* Hide elements on mobile */
    .animated-slogan,
    .weather-date,
    .social-icons,
    .static-link {
        display: none !important;
    }

    /* Mobile search panel */
    .mobile-search-panel {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        background-color: #222;
        padding: 15px;
        z-index: 998;
        transform: translateY(-100%);
        transition: transform 0.3s ease;
    }

    .mobile-search-panel.active {
        transform: translateY(0);
    }

    /* Mobile overlay */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 998;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .mobile-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Adjust main content to account for fixed header */
    main {
        padding-top: 50px;
        /* Reduced padding for better spacing */
        overflow-x: clip;
    }

    /* Prevent scrolling when menu is open */
    body.menu-open {
        overflow: hidden;
    }

    /* Container adjustments for mobile */
    .container {
        width: 100%;
        max-width: 100%;
        padding-left: 15px;
        padding-right: 15px;
    }

    /* Ensure all containers are properly sized */
    .container,
    .container-fluid,
    .container-sm,
    .container-md,
    .container-lg,
    .container-xl {
        width: 100%;
        padding-right: 15px;
        padding-left: 15px;
        margin-right: auto;
        margin-left: auto;
        max-width: 100%;
    }

    /* Article card adjustments */
    .article-card {
        margin-bottom: 15px;
    }

    .article-card .card-img-top {
        height: auto;
    }

    /* Row adjustments */
    .row {
        margin-right: -15px;
        margin-left: -15px;
    }

    /* Column adjustments */
    .col,
    .col-1,
    .col-2,
    .col-3,
    .col-4,
    .col-5,
    .col-6,
    .col-7,
    .col-8,
    .col-9,
    .col-10,
    .col-11,
    .col-12,
    .col-sm,
    .col-md,
    .col-lg,
    .col-xl {
        padding-right: 15px;
        padding-left: 15px;
    }

    /* Enhanced responsive section stylings */
    .section {
        margin-bottom: 20px;
        padding: 15px 0;
    }

    .section-title {
        font-size: 1.2rem;
        margin-bottom: 15px;
        padding-bottom: 10px;
        border-bottom: 2px solid #f0f0f0;
    }

    /* Convert multi-column layouts to single column on mobile */
    .main-content {
        flex-direction: column;
    }

    .main-column,
    .sidebar-column,
    .left-column,
    .right-column {
        width: 100% !important;
        padding: 0 !important;
        margin: 0 0 20px 0 !important;
    }

    /* Adjust position for fixed sidebar elements */
    .sidebar-fixed {
        position: static !important;
        top: auto !important;
        width: 100% !important;
    }

    /* Featured slider should be full width on mobile */
    .featured-slider {
        max-height: 300px;
    }

    .featured-slider-item {
        height: 300px;
    }

    /* Grid views should use one or two columns on mobile */
    .grid-container {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }

    /* Convert list view items to be more compact */
    .list-item {
        display: flex;
        margin-bottom: 15px;
        border-bottom: 1px solid #eee;
        padding-bottom: 15px;
    }

    .list-item .article-image {
        flex: 0 0 100px;
        margin-right: 15px;
    }

    .list-item .article-content h3 {
        font-size: 1rem;
        margin-top: 0;
        margin-bottom: 8px;
    }

    /* Card adjustments */
    .card {
        margin-bottom: 15px;
        border-radius: 0;
    }

    /* Image adjustments */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Carousel adjustments */
    .carousel-item {
        height: auto;
    }

    .carousel-caption {
        padding: 10px;
    }

    /* Table adjustments */
    table {
        width: 100%;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Footer adjustments */
    footer {
        padding: 20px 0;
        margin-top: 20px;
    }

    .footer-container {
        flex-direction: column;
        text-align: center;
    }

    .footer-logo {
        margin-bottom: 15px;
    }

    .footer-logo img {
        max-height: 30px;
    }

    .footer-nav ul {
        flex-direction: column;
        margin-bottom: 15px;
    }

    .footer-nav li {
        margin: 5px 0;
    }

    .footer-nav a {
        padding: 5px;
    }

    .footer-social {
        margin-top: 15px;
    }

    .footer-social a {
        margin: 0 10px;
    }
}

@media (max-width: 480px) {
    .logo img {
        max-height: 25px;
    }

    .header-container {
        padding: 8px 10px;
    }

    .footer-nav a {
        font-size: 0.9rem;
    }

    /* Further reduce container padding */
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }

    .section-title {
        font-size: 1.1rem;
    }

    /* Even smaller grid for very small screens */
    .grid-container {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 10px;
    }
}

/* Hide sections on mobile when hide_on_mobile is checked */
@media (max-width: 767px) {
    .hide-on-mobile {
        display: none !important;
        margin: 0 !important;
        padding: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
    }

    /* Hide empty containers on mobile */
    .grid-layout:empty,
    .column:empty,
    .left-column:empty,
    .main-column:empty,
    .right-column:empty {
        display: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Mobile-specific right content styling */
    .right-content-mobile {
        width: 100% !important;
        position: static !important;
        top: auto !important;
        height: auto !important;
        overflow: visible !important;
        padding: 0 !important;
        margin: 8px 0 0 0 !important;
    }

    .sidebar-sections-mobile {
        position: static !important;
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        padding: 0 !important;
        margin: 0 !important;
        grid-template-columns: 1fr !important;
    }

    /* Reduce gaps on mobile to avoid empty spaces when sections are hidden */
    .main-content {
        gap: 0px !important;
    }

    .top-content-wrapper {
        gap: 8px !important;
    }

    .left-content,
    .content-wrapper,
    .grid-layout {
        gap: 8px !important;
    }

    .sidebar-sections {
        gap: 8px !important;
    }

    /* Remove bottom margins from sections on mobile */
    section {
        margin-bottom: 8px !important;
    }

    .section-list {
        margin-bottom: 8px !important;
    }

    /* Make columns stack on mobile and remove empty space */
    .column {
        margin-bottom: 8px !important;
    }

    .column:last-child {
        margin-bottom: 0 !important;
    }

    /* Compact section styling on mobile */
    .right-content-mobile .section-list {
        margin-bottom: 8px !important;
        border-radius: 6px !important;
    }

    .right-content-mobile .section-list:last-child {
        margin-bottom: 0 !important;
    }
}