/* Modern Popular Page Design (inheriting from index.php styles) */
:root {
    --primary-blue: #4f46e5;
    --primary-dark: #3730a3;
    --secondary-gray: #64748b;
    --light-bg: #f8fafc;
    --card-bg: #ffffff;
    --border-light: #e2e8f0;
    --text-dark: #0f172a;
    --text-light: #64748b;
    --success-green: #059669;
    --warning-orange: #d97706;
    --error-red: #dc2626;
    --accent-purple: #7c3aed;
    --fire-red: #ef4444;
    --fire-orange: #f97316;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    min-height: 100vh;
}

/* Homepage Advertisement Styles */
.homepage-ad-container {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 2rem;
    margin: 2rem 0;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.homepage-ad-container:hover {
    box-shadow: var(--shadow-md);
}

.homepage-ad-container iframe,
.homepage-ad-container img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
}

.homepage-ad-placeholder {
    background: var(--light-bg);
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-sm);
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-light);
    transition: var(--transition);
}

.homepage-ad-placeholder:hover {
    background: rgba(124, 58, 237, 0.05);
    border-color: var(--accent-purple);
}

.homepage-ad-placeholder i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.homepage-ad-placeholder p {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 500;
}

.homepage-ad-placeholder small {
    font-size: 0.9rem;
    opacity: 0.7;
    display: block;
    margin-top: 0.5rem;
}

/* Sidebar Ad Styles */
.sidebar-ad-section {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.sidebar-ad-section .homepage-ad-placeholder {
    padding: 2rem 1rem;
}

.sidebar-ad-section .homepage-ad-placeholder i {
    font-size: 2rem;
}

/* Main Layout */
.popular-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Popular Hero Section */
.popular-hero-section {
    background: linear-gradient(135deg, var(--fire-red) 0%, var(--fire-orange) 100%);
    color: white;
    padding: 3rem 0 4rem;
    position: relative;
    overflow: hidden;
}

.popular-hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000"><polygon fill="rgba(255,255,255,0.1)" points="0,0 1000,300 1000,1000 0,700"/></svg>');
    background-size: cover;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.hero-title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    letter-spacing: -0.02em;
}

.hero-subtitle {
    font-size: 1.3rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto 2.5rem;
    line-height: 1.5;
}

/* Fixed Hero Stats Section for Better Visibility */
.hero-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    max-width: 800px;
    margin: 0 auto;
}

.hero-stat {
    background: rgba(255, 255, 255, 0.95); /* Much more opaque for better contrast */
    backdrop-filter: blur(20px);
    border-radius: var(--radius);
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.hero-stat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--fire-red), var(--fire-orange));
}

.hero-stat:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    background: rgba(255, 255, 255, 1);
}

.stat-number {
    display: block;
    font-size: 2.5rem;
    font-weight: 900;
    margin-bottom: 0.5rem;
    color: #1a202c !important; /* Dark text for contrast */
    text-shadow: none;
    line-height: 1;
}

.stat-label {
    font-size: 1rem;
    opacity: 1;
    color: #4a5568 !important; /* Dark gray for labels */
    font-weight: 600;
    letter-spacing: 0.025em;
    text-transform: uppercase;
    font-size: 0.85rem;
}

/* Search Section */
.search-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-light);
    padding: 2rem 0;
    position: sticky;
    top: 70px;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.search-container {
    display: flex;
    gap: 1rem;
    align-items: end;
    flex-wrap: wrap;
}

.search-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 200px;
}

.search-label {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-input, .search-select {
    padding: 0.875rem 1rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--text-dark);
    font-size: 1rem;
    transition: var(--transition);
    width: 100%;
}

.search-input:focus, .search-select:focus {
    outline: none;
    border-color: var(--fire-red);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.search-btn {
    padding: 0.875rem 2rem;
    background: var(--fire-red);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-md);
}

.search-btn:hover {
    background: var(--fire-orange);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Breadcrumbs */
.breadcrumb-section {
    background: var(--light-bg);
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 0;
}

.breadcrumb {
    margin: 0;
}

.breadcrumb-list {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
}

.breadcrumb-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--fire-red);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.1);
}

.breadcrumb-link:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    transform: translateY(-1px);
    text-decoration: none;
}

.breadcrumb-current {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--fire-red);
    color: white;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: var(--shadow-md);
}

.breadcrumb-separator {
    color: var(--text-light);
    font-size: 0.8rem;
    opacity: 0.6;
}

/* Results Info */
.results-info {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.results-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.results-count {
    color: var(--text-light);
    font-size: 0.95rem;
}

.active-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-tag {
    background: var(--fire-red);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.filter-tag .remove {
    cursor: pointer;
    opacity: 0.7;
    transition: var(--transition);
}

.filter-tag .remove:hover {
    opacity: 1;
}

/* Main Content */
.main-content {
    padding: 2rem 0;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 3rem;
    align-items: start;
}

.primary-content {
    min-width: 0;
}

.sidebar {
    position: sticky;
    top: 180px;
}

/* Software Grid */
.software-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.software-card {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: var(--transition);
    position: relative;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    min-height: 240px;
    max-width: 280px;
    justify-self: center;
}

.software-card:hover {
    border-color: var(--fire-red);
    box-shadow: var(--shadow-lg), 0 0 20px rgba(239, 68, 68, 0.15);
    transform: translateY(-4px);
}

.rank-badge {
    position: absolute;
    top: -1px;
    left: -1px;
    background: linear-gradient(135deg, var(--fire-red), var(--fire-orange));
    color: white;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: var(--radius) 0 var(--radius-sm) 0;
    z-index: 1;
    box-shadow: var(--shadow-sm);
}

.software-icon {
    width: 80px;
    height: 80px;
    border-radius: var(--radius);
    object-fit: cover;
    background: var(--light-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: var(--text-light);
    border: 1px solid var(--border-light);
    overflow: hidden;
    margin-bottom: 1rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.software-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius);
}

.software-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    overflow: hidden;
}

.software-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.3;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    word-break: break-word;
    margin-bottom: 0.75rem;
}

.software-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    align-items: center;
    margin-top: auto;
}

.software-category {
    font-size: 0.85rem;
    color: var(--text-light);
    text-align: center;
    opacity: 0.8;
    transition: var(--transition);
    cursor: pointer;
}

.software-category:hover {
    color: var(--fire-red);
    opacity: 1;
}

.software-downloads {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--fire-red);
    font-weight: 600;
    font-size: 0.9rem;
}

/* Sidebar Styles */
.sidebar-section {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.sidebar-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.category-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.category-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-dark);
    transition: var(--transition);
    border: 1px solid transparent;
}

.category-item:hover {
    background: var(--light-bg);
    border-color: var(--border-light);
    text-decoration: none;
    color: var(--text-dark);
}

.category-item.active {
    background: var(--fire-red);
    color: white;
    box-shadow: var(--shadow-md);
}

.category-icon {
    width: 32px;
    height: 32px;
    background: var(--light-bg);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
    font-size: 0.9rem;
    color: var(--fire-red);
    border: 1px solid var(--border-light);
}

.category-item.active .category-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.category-name {
    flex: 1;
    font-weight: 500;
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: center;
    margin: 3rem auto;
    padding: 0 1rem;
    width: 100%;
    clear: both;
}

.pagination {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 1rem 1.5rem;
    gap: 0.5rem;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    justify-content: center;
}

.page-item {
    display: flex;
    align-items: center;
}

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-sm);
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.1);
    min-width: 40px;
}

.page-link:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    transform: translateY(-1px);
    text-decoration: none;
    color: var(--text-dark);
}

.page-link.active {
    background: var(--fire-red);
    color: white;
    border-color: var(--fire-red);
    box-shadow: var(--shadow-md);
}

.page-link.active:hover {
    background: var(--fire-orange);
    color: white;
}

.page-link.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--light-bg);
    border-color: var(--border-light);
    color: var(--text-light);
    pointer-events: none;
}

.page-separator {
    color: var(--text-light);
    font-size: 0.75rem;
    opacity: 0.6;
    padding: 0 0.25rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.empty-icon {
    font-size: 3rem;
    color: var(--text-light);
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.empty-description {
    color: var(--text-light);
    margin-bottom: 2rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* Enhanced responsive styles for stats */
@media (max-width: 768px) {
    .popular-hero-section {
        padding: 2rem 0 3rem;
    }
    
    .hero-title {
        font-size: 2.5rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .hero-subtitle {
        font-size: 1.1rem;
    }
    
    .hero-stats {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        max-width: 400px;
    }
    
    .hero-stat {
        padding: 1.5rem;
    }
    
    .stat-number {
        font-size: 2.2rem;
        color: #1a202c !important;
    }
    
    .stat-label {
        font-size: 0.8rem;
        color: #4a5568 !important;
    }
    
    .search-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .search-field {
        min-width: auto;
    }
    
    .software-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1.2rem;
    }
    
    .software-card {
        min-height: 200px;
        max-width: 220px;
    }
    
    .software-icon {
        width: 64px;
        height: 64px;
        font-size: 2rem;
    }
    
    .software-title {
        font-size: 1rem;
    }
    
    .homepage-ad-container {
        padding: 1.5rem;
        margin: 1.5rem 0;
    }
}

@media (max-width: 480px) {
    .popular-container {
        padding: 0 0.75rem;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .hero-stats {
        gap: 1rem;
        max-width: 320px;
    }
    
    .hero-stat {
        padding: 1.25rem;
    }
    
    .stat-number {
        font-size: 2rem;
        color: #1a202c !important;
    }
    
    .stat-label {
        font-size: 0.75rem;
        color: #4a5568 !important;
    }
    
    .software-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1rem;
    }
    
    .software-card {
        padding: 1.2rem 0.8rem;
        min-height: 180px;
        max-width: 180px;
    }
    
    .software-icon {
        width: 56px;
        height: 56px;
        font-size: 1.8rem;
    }
    
    .software-title {
        font-size: 0.95rem;
    }
    
    .homepage-ad-container {
        padding: 1.2rem;
        margin: 1.2rem 0;
    }
    
    .homepage-ad-placeholder {
        padding: 2rem 1rem;
    }
    
    .homepage-ad-placeholder i {
        font-size: 2rem;
    }
}

/* Responsive Design for larger screens */
@media (max-width: 1200px) {
    .content-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .sidebar {
        position: static;
        order: -1;
    }
    
    .sidebar-section {
        display: block;
    }
    
    .software-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}