/* ========================================
   MOBILE & RESPONSIVE ENHANCEMENTS
   For news_home_improved.css
   ======================================== */

/* Mobile Filter Toggle Button */
.mobile-filter-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    box-shadow: var(--shadow-xl);
    cursor: pointer;
    transition: var(--transition-base);
    font-size: 24px;
    animation: pulse-button 2s ease-in-out infinite;
}

@keyframes pulse-button {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(102, 126, 234, 0);
    }
}

.mobile-filter-toggle:hover {
    transform: scale(1.1);
}

.mobile-filter-toggle:active {
    transform: scale(0.95);
}

.mobile-filter-toggle i {
    transition: var(--transition-base);
}

.mobile-filter-toggle.active i {
    transform: rotate(180deg);
}

/* Filter Counter Badge */
.filter-count-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-base);
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Close Button in Sidebar */
.sidebar-close {
    display: none;
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--gray-100);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 20px;
    color: var(--gray-600);
    cursor: pointer;
    transition: var(--transition-base);
    z-index: 10;
}

.sidebar-close:hover {
    background: var(--danger);
    color: white;
    transform: rotate(90deg);
}

.sidebar-close:active {
    transform: rotate(90deg) scale(0.9);
}

/* ========================================
   TABLET AND BELOW (1024px)
   ======================================== */
@media (max-width: 1024px) {
    /* Show mobile controls */
    .mobile-filter-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .sidebar-overlay {
        display: block;
    }
    
    .sidebar-close {
        display: block;
    }
    
    /* Layout */
    .content-wrapper {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    /* Sidebar becomes slide-in panel */
    .news-sidebar {
        position: fixed;
        left: -100%;
        width: 85%;
        max-width: 400px;
        height: 100vh;
        max-height: 100vh;
        top: 0;
        background: white;
        z-index: 1001;
        padding: 5rem 1.5rem 2rem 1.5rem;
        overflow-y: auto;
        box-shadow: 10px 0 30px rgba(0,0,0,0.3);
        display: block !important;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .news-sidebar.active {
        left: 0;
    }
    
    .sidebar-widget {
        margin-bottom: 1.5rem;
    }
    
    /* Grid adjustments */
    .news-grid.view-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .news-grid.view-list .news-card {
        flex-direction: column;
    }
    
    .news-grid.view-list .news-image {
        width: 100%;
        height: 220px;
    }
    
    /* Hero section */
    .news-hero {
        height: 320px;
    }
    
    .hero-title {
        font-size: 2.75rem;
    }
    
    .hero-stats {
        flex-wrap: wrap;
        gap: 1rem;
    }
}

/* ========================================
   MOBILE LANDSCAPE (768px)
   ======================================== */
@media (max-width: 768px) {
    /* Container padding */
    .main-container {
        padding: 1.5rem 0;
    }
    
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Hero Section - Компактнее для мобильных */
    .news-hero {
        height: 280px;
        padding: 1.5rem 0;
    }
    
    .hero-badge {
        font-size: 0.75rem;
        padding: 0.5rem 1rem;
        margin-bottom: 1rem;
    }
    
    .hero-badge span {
        display: none; /* Скрываем длинный текст */
    }
    
    .hero-badge i {
        font-size: 0.95rem;
        margin: 0;
    }
    
    .hero-content {
        text-align: center;
        padding: 1rem;
    }
    
    .hero-title {
        font-size: 1.85rem;
        margin-bottom: 0.75rem;
        line-height: 1.3;
    }
    
    .hero-icon {
        font-size: 2.25rem;
        margin-right: 0.5rem;
    }
    
    .hero-subtitle {
        font-size: 0.95rem;
        margin-bottom: 1.25rem;
        flex-direction: row;
        gap: 0.5rem;
    }
    
    .hero-subtitle i {
        font-size: 1rem;
    }
    
    /* Статистика - две колонки в ряд */
    .hero-stats {
        flex-direction: row;
        gap: 0.75rem;
        margin-top: 1.5rem;
    }
    
    .stat-item {
        padding: 1rem 1.25rem;
        min-width: 140px;
        flex: 1;
        border-radius: 14px;
    }
    
    .stat-number {
        font-size: 1.85rem;
    }
    
    .stat-label {
        font-size: 0.75rem;
        letter-spacing: 0.5px;
    }
    
    .stat-divider {
        display: none;
    }
    
    /* Sidebar Mobile */
    .news-sidebar {
        width: 90%;
        max-width: 100%;
        padding: 4.5rem 1.25rem 2rem 1.25rem;
    }
    
    .sidebar-widget {
        padding: 1.5rem;
        margin-bottom: 1.25rem;
        border-radius: var(--radius);
    }
    
    .widget-title {
        font-size: 1rem;
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }
    
    /* View mode buttons */
    .view-mode-buttons {
        gap: 0.5rem;
    }
    
    .view-mode-btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    /* Filter options */
    .filter-option {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    /* Popular/Latest widgets */
    .popular-item,
    .latest-item {
        padding: 0.75rem;
    }
    
    .popular-title,
    .latest-title {
        font-size: 0.9rem;
    }
    
    /* Search form */
    .search-input {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }
    
    .search-btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.95rem;
    }
    
    /* Main content */
    .news-grid.view-grid,
    .news-grid.view-compact {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
    
    .news-grid.view-list {
        gap: 1.25rem;
    }
    
    /* News cards */
    .news-card {
        border-radius: var(--radius);
    }
    
    .news-image {
        height: 200px;
    }
    
    .news-content {
        padding: 1.25rem;
    }
    
    .news-title {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
    }
    
    .news-excerpt {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }
    
    .news-meta-top {
        gap: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .news-date,
    .reading-time {
        font-size: 0.85rem;
    }
    
    .news-stats {
        gap: 1rem;
    }
    
    .stat-item {
        font-size: 0.85rem;
    }
    
    .read-more {
        padding: 0.65rem 1.25rem;
        font-size: 0.9rem;
    }
    
    /* Active filters */
    .active-filters {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 1rem;
    }
    
    .filters-label {
        width: 100%;
        margin-bottom: 0.25rem;
        font-size: 0.9rem;
    }
    
    .filter-badge {
        font-size: 0.85rem;
        padding: 0.4rem 0.75rem;
    }
    
    .clear-all-filters {
        width: 100%;
        justify-content: center;
        margin-left: 0;
        margin-top: 0.5rem;
        font-size: 0.9rem;
    }
    
    /* Results header */
    .results-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        padding: 1rem;
    }
    
    .results-count {
        font-size: 0.95rem;
    }
    
    .per-page-selector {
        width: 100%;
        justify-content: space-between;
    }
    
    .per-page-select {
        flex: 1;
        max-width: 120px;
    }
    
    /* Pagination */
    .pagination-wrapper {
        padding: 1.5rem 0;
    }
    
    .pagination {
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: center;
    }
    
    .pagination-btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }
    
    .pagination-first,
    .pagination-last {
        display: none; /* Hide on mobile to save space */
    }
    
    .pagination-pages {
        order: 3;
        width: 100%;
        justify-content: center;
        margin-top: 0.5rem;
        gap: 0.25rem;
    }
    
    .pagination-page {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        min-width: 36px;
    }
    
    .pagination-info {
        font-size: 0.85rem;
        margin-top: 0.75rem;
    }
    
    /* Mobile filter button */
    .mobile-filter-toggle {
        bottom: 80px; /* Account for potential footer/nav */
        right: 16px;
        width: 52px;
        height: 52px;
        font-size: 22px;
    }
    
    /* Scroll to top button */
    #scrollToTop {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
        font-size: 18px;
    }
}

/* ========================================
   SMALL MOBILE (480px)
   ======================================== */
@media (max-width: 480px) {
    /* Hero максимально компактный */
    .news-hero {
        height: 220px;
        padding: 0.75rem 0;
    }
    
    .hero-badge {
        padding: 0.4rem 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .hero-content {
        padding: 0.75rem;
    }
    
    .hero-title {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
        line-height: 1.25;
    }
    
    .hero-icon {
        font-size: 1.75rem;
        margin-right: 0.35rem;
        display: inline-block;
    }
    
    .hero-subtitle {
        font-size: 0.85rem;
        margin-bottom: 1rem;
    }
    
    .hero-subtitle i {
        font-size: 0.9rem;
    }
    
    /* Статистика в одну линию */
    .hero-stats {
        gap: 0.5rem;
        margin-top: 1rem;
    }
    
    .stat-item {
        padding: 0.75rem 1rem;
        min-width: 0;
        flex: 1;
        border-radius: 12px;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
        letter-spacing: 0.3px;
    }
    
    /* Sidebar full width on tiny screens */
    .news-sidebar {
        width: 100%;
        padding: 4rem 1rem 2rem 1rem;
    }
    
    .sidebar-widget {
        padding: 1.25rem;
    }
    
    .widget-title {
        font-size: 0.95rem;
    }
    
    /* Cards stack better */
    .news-card {
        border-radius: 10px;
    }
    
    .news-image {
        height: 180px;
        border-radius: 10px 10px 0 0;
    }
    
    .news-content {
        padding: 1rem;
    }
    
    .news-title {
        font-size: 1rem;
        line-height: 1.5;
    }
    
    .news-excerpt {
        font-size: 0.875rem;
        line-height: 1.6;
    }
    
    .news-meta-top {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .news-badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.625rem;
    }
    
    .read-more {
        padding: 0.6rem 1rem;
        font-size: 0.875rem;
        width: 100%;
        justify-content: center;
    }
    
    /* Buttons smaller */
    .view-mode-btn {
        padding: 0.625rem 0.875rem;
    }
    
    .filter-option {
        padding: 0.625rem 0.875rem;
    }
    
    .search-btn {
        width: 100%;
        margin-top: 0.5rem;
    }
    
    /* Pagination very compact */
    .pagination-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .pagination-prev,
    .pagination-next {
        flex: 1;
    }
    
    .pagination-page {
        padding: 0.4rem 0.6rem;
        min-width: 32px;
        font-size: 0.8rem;
    }
    
    /* Mobile button positioning */
    .mobile-filter-toggle {
        bottom: 70px;
        right: 12px;
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
    
    #scrollToTop {
        bottom: 12px;
        right: 12px;
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
    
    /* Results header compact */
    .results-header {
        padding: 0.75rem;
    }
    
    .results-count {
        font-size: 0.875rem;
    }
    
    .per-page-selector label {
        font-size: 0.875rem;
    }
    
    .per-page-select {
        font-size: 0.875rem;
    }
    
    /* Active filters compact */
    .active-filters {
        padding: 0.75rem;
    }
    
    .filter-badge {
        font-size: 0.8rem;
        padding: 0.35rem 0.65rem;
    }
    
    .filter-remove {
        font-size: 1rem;
        width: 18px;
        height: 18px;
    }
}

/* ========================================
   LANDSCAPE MODE OPTIMIZATIONS
   ======================================== */
@media (max-width: 896px) and (orientation: landscape) {
    .news-hero {
        height: 220px;
    }
    
    .hero-stats {
        flex-direction: row;
        gap: 1rem;
    }
    
    .stat-divider {
        display: block;
        width: 2px;
        height: 30px;
    }
    
    .news-sidebar {
        padding-top: 3.5rem;
    }
    
    .sidebar-widget {
        padding: 1rem;
        margin-bottom: 1rem;
    }
}

/* ========================================
   TOUCH OPTIMIZATIONS
   ======================================== */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .filter-option,
    .view-mode-btn,
    .pagination-btn,
    .pagination-page {
        min-height: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .news-card:hover {
        transform: none;
    }
    
    .filter-option:hover {
        transform: none;
    }
    
    /* But keep active/tap effects */
    .news-card:active {
        transform: scale(0.98);
    }
    
    .filter-option:active {
        transform: scale(0.98);
    }
    
    .view-mode-btn:active {
        transform: scale(0.95);
    }
}

/* ========================================
   PRINT STYLES - MOBILE FRIENDLY
   ======================================== */
@media print {
    .mobile-filter-toggle,
    .sidebar-overlay,
    .news-sidebar,
    #scrollToTop,
    .pagination-wrapper,
    .active-filters {
        display: none !important;
    }
    
    .news-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .news-card {
        page-break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}
