/* ===========================
   RESPONSIVE STYLES
   Mobile-First Design
   =========================== */

/* Tablet - 768px and below */
@media (max-width: 768px) {
    /* Header Unified Layout */
    .header-unified {
        flex-wrap: wrap;
        padding: var(--spacing-sm) 0;
        position: relative;
    }

    .header-unified .logo {
        order: 1;
        flex: 1;
    }

    .logo-image {
        height: 40px;
        max-width: 180px;
    }

    .header-unified .header-controls {
        order: 2;
        flex-shrink: 0;
        display: flex;
        gap: var(--spacing-sm);
    }

    .header-unified .main-nav {
        order: 3;
        width: 100%;
        flex: none;
        margin-top: var(--spacing-sm);
        justify-content: flex-start;
    }

    /* Header */
    .header-top {
        flex-direction: column;
        gap: var(--spacing-md);
        align-items: center;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    .header-controls {
        justify-content: center;
    }

    .header-controls button {
        padding: 0.5rem;
        font-size: 1.1rem;
    }

    /* Navigation - Right Side Slide-in Menu */
    .main-nav ul {
        position: fixed;
        top: 0;
        right: -280px;
        width: 280px;
        height: 100vh;
        display: flex;
        flex-direction: column;
        gap: 0;
        background: var(--white);
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
        overflow-y: auto;
        z-index: 9999;
        transition: right 0.3s ease-in-out;
        padding-top: 60px;
    }

    .main-nav ul.mobile-active {
        right: 0;
    }

    .main-nav li {
        width: 100%;
    }

    .main-nav a {
        display: block;
        padding: var(--spacing-lg) var(--spacing-md);
        border-bottom: 1px solid var(--gray-200);
        font-size: 1rem;
        color: var(--gray-800);
        text-decoration: none;
        transition: all 0.2s ease;
    }

    .main-nav a:hover {
        background: var(--gray-50);
        padding-right: 1.5rem;
        color: var(--primary-blue);
    }

    .main-nav a.active {
        background: var(--light-blue);
        color: var(--primary-blue);
        border-right: 4px solid var(--primary-blue);
        font-weight: 600;
    }

    .main-nav li:last-child a {
        border-bottom: none;
    }

    /* Overlay for mobile menu */
    .main-nav ul.mobile-active::before {
        content: '';
        position: fixed;
        top: 0;
        right: 280px;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }

    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: var(--gray-100);
        border: 1px solid var(--gray-300);
        border-radius: var(--radius-md);
        cursor: pointer;
        font-size: 1.2rem;
        color: var(--gray-700);
        transition: all 0.3s ease;
    }

    .mobile-menu-toggle:hover {
        background: var(--gray-200);
    }

    /* Dark Mode for Mobile Menu */
    body.dark-mode .main-nav ul {
        background: var(--gray-800);
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.5);
    }

    body.dark-mode .main-nav a {
        color: var(--gray-100);
        border-bottom-color: var(--gray-700);
    }

    body.dark-mode .main-nav a:hover {
        color: var(--light-blue);
        background: var(--gray-700);
    }

    body.dark-mode .main-nav a.active {
        background: var(--dark-blue);
        color: var(--white);
        border-right-color: var(--light-blue);
    }

    body.dark-mode .mobile-menu-toggle {
        background: var(--gray-700);
        border-color: var(--gray-600);
        color: var(--gray-200);
    }

    body.dark-mode .mobile-menu-toggle:hover {
        background: var(--gray-600);
    }

    /* Main Grid */
    .main-grid {
        grid-template-columns: 1fr;
    }

    /* Sidebar */
    .sidebar {
        position: static;
        order: 2;
    }

    /* Articles Grid */
    .articles-grid {
        grid-template-columns: 1fr;
    }

    .articles-grid.list-view .article-card {
        grid-template-columns: 1fr;
    }

    .articles-grid.list-view .article-card img {
        height: 200px;
    }

    /* Carousel */
    .featured-article {
        flex: 0 0 300px;
    }

    .featured-article img {
        height: 200px;
    }

    .carousel-btn {
        display: none;
    }

    /* Footer */
    .footer-content {
        grid-template-columns: 1fr;
    }

    /* Search */
    .search-container {
        flex-direction: column;
    }

    .search-container button {
        width: 100%;
    }

    /* Modal */
    .modal-content {
        margin: var(--spacing-md);
        padding: var(--spacing-lg);
    }

    /* Featured Section */
    .featured-section h2 {
        font-size: 1.5rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-md);
    }
}

/* Mobile - 480px and below */
@media (max-width: 480px) {
    /* Typography adjustments */
    :root {
        --font-size-base: 14px;
    }

    .logo h1 {
        font-size: 1.25rem;
    }

    .logo-image {
        height: 32px;
        max-width: 140px;
    }

    .featured-section h2,
    .section-header h2 {
        font-size: 1.25rem;
    }

    .sidebar h3 {
        font-size: 1.1rem;
    }

    /* Spacing adjustments */
    .container {
        padding: 0 var(--spacing-sm);
    }

    .main-content {
        padding: var(--spacing-md) 0;
    }

    /* Header unified for small mobile */
    .header-unified {
        padding: var(--spacing-xs) 0;
        gap: var(--spacing-xs);
    }

    /* Header controls */
    .header-controls {
        gap: 0.25rem;
    }

    .header-controls button {
        width: 36px;
        height: 36px;
        padding: 0.4rem;
        font-size: 1rem;
    }

    .mobile-menu-toggle {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .font-size-controls {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    /* Search bar */
    .search-container {
        margin-top: var(--spacing-sm);
        margin-bottom: var(--spacing-sm);
    }

    .search-container input {
        font-size: 0.9rem;
        padding: 0.6rem;
    }

    /* Featured carousel */
    .featured-article {
        flex: 0 0 280px;
    }

    .featured-article img {
        height: 180px;
    }

    /* Article cards */
    .article-card {
        margin-bottom: var(--spacing-md);
    }

    .article-card img {
        height: 200px;
    }

    .article-content {
        padding: var(--spacing-md);
    }

    .article-card h3 {
        font-size: 0.95rem;
        line-height: 1.4;
    }

    .article-card .description {
        font-size: 0.85rem;
        line-height: 1.5;
    }

    .article-footer {
        flex-direction: column;
        gap: var(--spacing-sm);
        align-items: flex-start;
        font-size: 0.8rem;
    }

    .article-meta {
        font-size: 0.8rem;
    }

    /* Trending items */
    .trending-item {
        flex-direction: row;
        gap: var(--spacing-sm);
    }

    .trending-item img {
        width: 80px;
        height: 60px;
        flex-shrink: 0;
    }

    /* Newsletter */
    .newsletter-section {
        padding: var(--spacing-lg);
    }

    .newsletter-section input,
    .newsletter-section button {
        font-size: 0.875rem;
        padding: 0.6rem;
    }

    /* Breaking news banner */
    .breaking-news-banner {
        padding: var(--spacing-sm);
    }

    .breaking-news-banner .container {
        flex-direction: row;
        text-align: left;
        font-size: 0.85rem;
    }

    .breaking-label {
        font-size: 0.75rem;
        padding: 0.2rem 0.5rem;
        flex-shrink: 0;
    }

    .close-banner {
        padding: 0 var(--spacing-xs);
        font-size: 1.25rem;
    }

    /* Ad containers */
    .ad-container {
        padding: var(--spacing-sm);
    }

    /* Video section */
    .live-video-section {
        padding: var(--spacing-md);
    }

    .video-card {
        margin-bottom: var(--spacing-md);
    }

    .video-title {
        font-size: 0.9rem;
    }

    /* Modal */
    .modal-content {
        margin: var(--spacing-sm);
        padding: var(--spacing-md);
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-header h2 {
        font-size: 1.1rem;
    }

    .modal-body {
        font-size: 0.9rem;
    }
}

/* Large Desktop - 1440px and above */
@media (min-width: 1440px) {
    :root {
        --container-max-width: 1400px;
    }

    .featured-article {
        flex: 0 0 450px;
    }

    .articles-grid {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    }
}

/* Extra Large Desktop - 1920px and above */
@media (min-width: 1920px) {
    :root {
        --container-max-width: 1600px;
    }

    .main-grid {
        grid-template-columns: 1fr 400px;
    }
}

/* Print Styles */
@media print {
    .header,
    .main-nav,
    .search-container,
    .sidebar,
    .footer,
    .ad-container,
    .share-buttons,
    .load-more-container,
    .breaking-news-banner,
    .carousel-btn,
    .mobile-menu-toggle,
    .dark-mode-toggle,
    .font-size-controls,
    .language-switcher {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .main-content {
        padding: 0;
    }

    .main-grid {
        grid-template-columns: 1fr;
    }

    .article-card,
    .featured-article {
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
        margin-bottom: 1cm;
    }

    a {
        text-decoration: underline;
    }

    a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .carousel-container {
        scroll-behavior: auto;
    }

    html {
        scroll-behavior: auto;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --primary-red: #FF0000;
        --primary-blue: #0000FF;
        --gray-600: #000000;
        --gray-800: #000000;
        --gray-900: #000000;
    }

    .article-card,
    .featured-article,
    .sidebar section {
        border: 2px solid #000000;
    }

    body.dark-mode {
        --gray-900: #FFFFFF;
        --gray-800: #FFFFFF;
        --gray-600: #FFFFFF;
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .featured-article img {
        height: 180px;
    }

    .article-card img {
        height: 150px;
    }

    .modal-content {
        max-height: 80vh;
    }
}
