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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --bg-color: #ffffff;
    --text-color: #1e293b;
    --text-secondary: #64748b;
    --card-bg: #ffffff;
    --header-bg: #ffffff;
    --border-color: #e2e8f0;
    --hover-bg: #f8fafc;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --primary-color-rgb: 37, 99, 235; /* RGB for primary-color */
}

[data-theme="dark"] {
    --bg-color: #0f172a;
    --text-color: #f1f5f9;
    --text-secondary: #94a3b8;
    --card-bg: #1e293b;
    --header-bg: #1e293b;
    --border-color: #334155;
    --hover-bg: #334155;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3);
    --primary-color-rgb: 37, 99, 235; /* Same RGB for dark mode */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: all 0.3s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background-color: var(--header-bg);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.mobile-menu-toggle:hover {
    background-color: var(--hover-bg);
}

.logo {
    display: flex;
    align-items: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    text-decoration: none;
    cursor: pointer;
}

.logo svg {
    width: 32px;
    height: 32px;
    margin-right: 0.5rem;
}

.search-container {
    flex: 1;
    max-width: 500px;
    margin: 0 2rem;
    position: relative;
}

.search-box {
    width: 100%;
    padding: 0.625rem 2.5rem 0.625rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--card-bg);
    color: var(--text-color);
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.search-box:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.search-btn:hover {
    background-color: var(--primary-hover);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.theme-toggle {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-color);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-toggle:hover {
    border-color: var(--primary-color);
}

/* Navigation */
nav {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.nav-list {
    display: flex;
    list-style: none;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.75rem 0;
    scrollbar-width: thin;
}

.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1500;
}

.mobile-nav-menu {
    display: none;
    position: fixed;
    top: 0;
    right: -300px;
    width: 280px;
    height: 100%;
    background: var(--card-bg);
    z-index: 1600;
    transition: right 0.3s ease;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.mobile-nav-menu.active {
    right: 0;
}

.mobile-nav-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-nav-close {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.mobile-nav-close:hover {
    background-color: var(--hover-bg);
}

.mobile-nav-list {
    list-style: none;
    padding: 1rem 0;
}

.mobile-nav-list li {
    margin: 0;
}

.mobile-nav-list a {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.mobile-nav-list a:hover,
.mobile-nav-list a.active {
    background-color: var(--hover-bg);
    border-left-color: var(--primary-color);
    color: var(--primary-color);
}

.mobile-search {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.mobile-search .search-box {
    width: 100%;
    margin-bottom: 1rem;
}

.nav-item a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.3s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    font-size: 0.9rem;
}

.nav-item a:hover,
.nav-item a.active {
    background-color: var(--hover-bg);
    color: var(--primary-color);
}

/* Page Container */
.page {
    display: none;
    flex: 1;
}

.page.active {
    display: block;
}

/* Hero Section */
.hero {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.hero-banner {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border-radius: 12px;
    padding: 2rem;
    color: white;
    position: relative;
    overflow: hidden;
    text-align: center;
}

.hero-banner::before {
    content: '';
    position: absolute;
    right: -100px;
    top: -100px;
    width: 300px;
    height: 300px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-content h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.hero-content p {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    opacity: 0.95;
}

.download-btn {
    background-color: white;
    color: var(--primary-color);
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Main Content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    flex: 1;
}

.section {
    margin-bottom: 3rem;
}

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

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
}

.view-all {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
}

.view-all:hover {
    text-decoration: underline;
}

/* App Grid */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
    padding: 0.5rem;
}

.app-card {
    background-color: transparent;
    padding: 0.35rem;
    text-align: center;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.app-card:hover {
    transform: scale(1.05);
    background-color: var(--hover-bg);
}

.app-icon {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    flex-shrink: 0;
    object-fit: cover; /* For images */
    box-shadow: var(--shadow);
}

.app-icon:empty {
    background: var(--hover-bg);
}

.app-icon:hover {
    box-shadow: none;
}

.app-name {
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-rating {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-top: 0.35rem;
}

.app-category {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-top: 0.35rem;
}

.star {
    color: var(--warning-color);
}

/* Categories */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.category-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.category-card:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.category-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: var(--hover-bg);
    flex-shrink: 0;
}

.category-info h3 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.category-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Breadcrumb */
.breadcrumb {
    padding: 1rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.breadcrumb a {
    color: var(--primary-color);
    text-decoration: none;
    cursor: pointer;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

/* Filter Bar */
.filter-bar {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stats-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    text-align: center;
    transition: all 0.3s ease;
}

.stats-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stats-number {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stats-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Footer */
footer {
    background-color: var(--header-bg);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    padding: 2rem 0 1rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.footer-section h3 {
    margin-bottom: 1rem;
    color: var(--text-color);
    font-size: 1.1rem;
}

.footer-section ul {
    list-style: none;
}

.footer-section li {
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.footer-section a:hover {
    color: var(--primary-color);
}

.footer-bottom {
    text-align: center;
    padding: 1.5rem 1rem 0.5rem;
    border-top: 1px solid var(--border-color);
    margin-top: 2rem;
    color: var(--text-secondary);
}

.footer-logo {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}

/* Enhanced Mobile Responsiveness */
@media (max-width: 768px) {
    .header-content {
        padding: 0.75rem;
    }

    .search-container {
        display: none;
    }

    .mobile-menu-toggle {
        display: block;
    }

    .header-actions {
        gap: 0.5rem;
    }

    .theme-toggle span {
        display: none;
    }

    nav {
        display: none;
    }

    .mobile-nav-overlay.active {
        display: block;
    }

    .mobile-nav-menu {
        display: block;
    }

    .hero {
        padding: 0 1rem;
        margin: 1rem auto;
    }

    .hero-banner {
        padding: 1.5rem;
    }

    .hero-content h1 {
        font-size: 1.8rem;
        margin-bottom: 0.75rem;
    }

    .hero-content p {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }

    .main-content {
        padding: 1rem;
    }

    .section {
        margin-bottom: 2rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

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

    .app-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 140px));
        gap: 0.4rem;
        padding: 0.4rem;
        justify-content: center;
        justify-items: center;
    }

    .app-card {
        padding: 0.3rem;
    }

    .app-icon {
        width: 72px;
        height: 72px;
        font-size: 2rem;
        border-radius: 6px;
    }

    .app-name {
        font-size: 0.9rem;
    }

    .app-rating {
        font-size: 0.7rem;
    }

    .app-category {
        font-size: 0.65rem;
    }

    .category-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .category-card {
        padding: 1rem;
    }

    .category-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .filter-bar {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .filter-btn {
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .stats-card {
        padding: 1rem;
    }

    .stats-number {
        font-size: 1.5rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .footer-bottom {
        padding: 1rem 1rem 0.5rem;
        font-size: 0.85rem;
    }

    .breadcrumb {
        padding: 0.75rem 0;
        font-size: 0.85rem;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .app-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 110px)); /* Smaller cards for more items */
        gap: 0.3rem; /* Reduced gap */
        padding: 0.2rem; /* Reduced padding */
        justify-content: start; /* Align left to reduce wasted space */
        overflow-x: auto; /* Allow horizontal scrolling if needed */
        scrollbar-width: thin; /* Thin scrollbar for Firefox */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }

    .app-card {
        padding: 0.2rem; /* Minimal padding */
        min-height: 90px; /* Ensure touch-friendly height */
        min-width: 100px; /* Ensure touch-friendly width */
    }

    .app-icon {
        width: 56px; /* Smaller icon */
        height: 56px;
        font-size: 1.6rem; /* Adjusted for smaller icon */
        border-radius: 8px; /* Slightly larger radius for modern look */
    }

    .app-name {
        font-size: 0.78rem; /* Slightly smaller text */
        line-height: 1.1;
        max-height: 2.2em; /* Limit to two lines */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .app-rating {
        font-size: 0.6rem; /* Smaller rating */
        gap: 0.15rem;
    }

    .app-category {
        font-size: 0.55rem; /* Smaller category text */
        display: none; /* Hide to save space */
    }

    .hero-content h1 {
        font-size: 1.5rem;
    }

    .hero-content p {
        font-size: 0.9rem;
    }

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

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

    .category-grid {
        gap: 0.5rem;
    }

    .category-card {
        padding: 0.75rem;
        flex-direction: column;
        text-align: center;
    }

    .category-info h3 {
        font-size: 1rem;
    }

    .category-info p {
        font-size: 0.8rem;
    }
}

/* Touch improvements for mobile */
@media (hover: none) and (pointer: coarse) {
    .app-card:hover {
        transform: none;
        background-color: transparent;
    }

    .app-card:active {
        transform: scale(0.98);
        background-color: rgba(var(--primary-color-rgb), 0.1);
    }

    .app-card {
        min-height: 110px;
        min-width: 110px;
    }

    .category-card:hover {
        transform: none;
        box-shadow: var(--shadow);
    }

    .category-card:active {
        transform: scale(0.98);
        background-color: var(--hover-bg);
    }

    .filter-btn:hover {
        background: var(--bg-color);
        color: var(--text-color);
        border-color: var(--border-color);
    }

    .filter-btn:active {
        background: var(--primary-color);
        color: white;
        border-color: var(--primary-color);
    }

    .nav-item a {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .search-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .theme-toggle {
        min-height: 44px;
        padding: 0.75rem;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.app-card,
.category-card {
    animation: fadeIn 0.4s ease-in-out forwards;
}