:root {
    /* Light mode colors */
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #fafafa;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --border-color: #e0e0e0;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
    --overlay: rgba(0, 0, 0, 0.5);
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --skeleton-from: #e0e0e0;
    --skeleton-to: #f5f5f5;
}

[data-theme="dark"] {
    /* Dark mode colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --accent-primary: #818cf8;
    --accent-secondary: #a78bfa;
    --border-color: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.4);
    --overlay: rgba(0, 0, 0, 0.7);
    --skeleton-from: #1e293b;
    --skeleton-to: #334155;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: white;
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px var(--shadow);
    transition: box-shadow 0.3s ease;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo h1 {
    font-size: 24px;
    font-weight: bold;
}

.theme-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 18px;
    transition: background 0.3s ease, transform 0.2s ease;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.nav-links {
    display: flex;
    gap: 20px;
    align-items: center;
}

.nav-link {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    transition: background 0.3s ease, color 0.3s ease, transform 0.2s ease;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: translateY(-2px);
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.nav-link-console {
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    transition: background 0.3s ease, transform 0.2s ease;
}

.nav-link-console:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.search-bar {
    display: flex;
    background: var(--bg-secondary);
    border-radius: 25px;
    overflow: hidden;
    width: 300px;
    box-shadow: 0 2px 8px var(--shadow);
}

.search-bar input {
    flex: 1;
    border: none;
    padding: 10px 15px;
    outline: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.search-bar button {
    background: none;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 18px;
    transition: transform 0.2s ease;
}

.search-bar button:hover {
    transform: scale(1.1);
}

/* Main Content */
.main-content {
    padding: 40px 0;
    min-height: calc(100vh - 200px);
}

.section {
    margin-bottom: 60px;
}

.section h2 {
    font-size: 28px;
    margin-bottom: 25px;
    color: var(--text-primary);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 20px;
}

/* Advanced Filters */
.filters-container {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-toggle {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.filter-toggle:hover {
    background: var(--accent-secondary);
    transform: translateY(-2px);
}

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filters select {
    padding: 8px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.filters select:hover,
.filters select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.advanced-filters {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--bg-secondary);
    box-shadow: -2px 0 20px var(--shadow);
    padding: 30px;
    overflow-y: auto;
    transition: right 0.3s ease;
    z-index: 2000;
}

.advanced-filters.active {
    right: 0;
}

.advanced-filters-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay);
    display: none;
    z-index: 1999;
}

.advanced-filters-overlay.active {
    display: block;
}

.filter-group {
    margin-bottom: 25px;
}

.filter-group h3 {
    margin-bottom: 12px;
    color: var(--text-primary);
    font-size: 16px;
}

.filter-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    color: var(--text-secondary);
}

.filter-group input[type="checkbox"],
.filter-group input[type="radio"] {
    cursor: pointer;
}

.range-input {
    width: 100%;
}

.range-values {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 5px;
}

.filter-actions {
    display: flex;
    gap: 10px;
    margin-top: 30px;
}

.filter-actions button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.apply-filters {
    background: var(--accent-primary);
    color: white;
}

.apply-filters:hover {
    background: var(--accent-secondary);
}

.reset-filters {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.reset-filters:hover {
    background: var(--border-color);
}

.close-filters {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.close-filters:hover {
    color: var(--text-primary);
}

/* Categories Grid */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px;
}

.category-card {
    background: var(--bg-secondary);
    padding: 30px 20px;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--shadow);
    border: 1px solid var(--border-color);
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px var(--shadow-hover);
    border-color: var(--accent-primary);
}

.category-card .icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.category-card h3 {
    font-size: 16px;
    color: var(--text-primary);
}

.category-card p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 5px;
}

/* Apps Grid */
.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px;
}

.app-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--shadow);
    border: 1px solid var(--border-color);
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.app-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px var(--shadow-hover);
    border-color: var(--accent-primary);
}

.app-icon {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.app-info {
    padding: 20px;
}

.app-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.app-developer {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
}

.app-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.app-rating {
    color: var(--warning);
    font-weight: 600;
}

.app-downloads {
    color: var(--text-tertiary);
}

.compare-checkbox {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    z-index: 10;
}

/* Loading Skeletons */
.skeleton {
    background: linear-gradient(90deg, var(--skeleton-from) 25%, var(--skeleton-to) 50%, var(--skeleton-from) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.skeleton-icon {
    width: 100%;
    height: 180px;
}

.skeleton-content {
    padding: 20px;
}

.skeleton-title {
    height: 20px;
    border-radius: 4px;
    margin-bottom: 10px;
    width: 80%;
}

.skeleton-text {
    height: 14px;
    border-radius: 4px;
    margin-bottom: 8px;
    width: 60%;
}

.skeleton-meta {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.skeleton-meta-item {
    height: 14px;
    border-radius: 4px;
    width: 40%;
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 40px auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-container {
    text-align: center;
    padding: 40px;
}

.loading-text {
    color: var(--text-secondary);
    margin-top: 15px;
}

/* Infinite Scroll Sentinel */
.scroll-sentinel {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

/* Pagination (fallback) */
.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 40px;
}

.page-btn {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.page-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

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

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: var(--overlay);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: block;
}

.modal-content {
    background-color: var(--bg-secondary);
    margin: 5% auto;
    padding: 0;
    border-radius: 16px;
    width: 90%;
    max-width: 900px;
    box-shadow: 0 10px 50px var(--shadow-hover);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

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

.close {
    position: sticky;
    top: 20px;
    right: 30px;
    color: var(--text-secondary);
    float: right;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    transition: color 0.3s ease;
}

.close:hover {
    color: var(--text-primary);
}

/* App Details */
.app-detail-header {
    display: flex;
    gap: 30px;
    padding: 40px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.app-detail-icon {
    width: 120px;
    height: 120px;
    border-radius: 24px;
    object-fit: cover;
    box-shadow: 0 4px 12px var(--shadow);
}

.app-detail-info {
    flex: 1;
}

.app-detail-name {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.app-detail-developer {
    color: var(--text-secondary);
    font-size: 18px;
    margin-bottom: 15px;
}

.app-detail-meta {
    display: flex;
    gap: 30px;
    margin-bottom: 20px;
}

.meta-item {
    display: flex;
    flex-direction: column;
}

.meta-label {
    color: var(--text-tertiary);
    font-size: 12px;
    text-transform: uppercase;
}

.meta-value {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    margin-top: 5px;
}

.app-actions {
    display: flex;
    gap: 15px;
}

.download-btn,
.compare-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.download-btn {
    background: var(--accent-primary);
    color: white;
}

.download-btn:hover {
    background: var(--accent-secondary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-hover);
}

.compare-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.compare-btn:hover {
    background: var(--bg-tertiary);
    transform: translateY(-2px);
}

.app-detail-body {
    padding: 40px;
}

.detail-section {
    margin-bottom: 40px;
}

.detail-section h3 {
    font-size: 22px;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.description {
    color: var(--text-secondary);
    line-height: 1.8;
    white-space: pre-wrap;
}

/* Screenshots Gallery */
.screenshots {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding: 10px 0;
}

.screenshot {
    min-width: 250px;
    height: 450px;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.3s ease;
    object-fit: cover;
    box-shadow: 0 4px 12px var(--shadow);
}

.screenshot:hover {
    transform: scale(1.05);
}

/* Gallery Modal */
.gallery-modal {
    display: none;
    position: fixed;
    z-index: 4000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
}

.gallery-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}

.gallery-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    font-size: 32px;
    padding: 20px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: background 0.3s ease;
}

.gallery-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.gallery-prev {
    left: -60px;
}

.gallery-next {
    right: -60px;
}

.gallery-close {
    position: absolute;
    top: -50px;
    right: 0;
    color: white;
    font-size: 40px;
    background: none;
    border: none;
    cursor: pointer;
}

.gallery-counter {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 16px;
}

/* Video Preview */
.video-preview {
    width: 100%;
    max-width: 700px;
    border-radius: 12px;
    margin-bottom: 20px;
}

/* Comparison View */
.comparison-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 2px solid var(--accent-primary);
    padding: 15px;
    display: none;
    box-shadow: 0 -4px 20px var(--shadow);
    z-index: 2000;
}

.comparison-bar.active {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.comparison-items {
    display: flex;
    gap: 10px;
    flex: 1;
}

.comparison-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.comparison-item img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
}

.comparison-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
}

.comparison-actions button {
    margin-left: 10px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.view-comparison {
    background: var(--accent-primary);
    color: white;
}

.clear-comparison {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.comparison-modal .modal-content {
    max-width: 1200px;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
}

.comparison-table th,
.comparison-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.comparison-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
}

.comparison-table td {
    color: var(--text-secondary);
}

.comparison-table .app-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.comparison-table .app-header img {
    width: 50px;
    height: 50px;
    border-radius: 8px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 100px;
    right: 20px;
    z-index: 5000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px var(--shadow-hover);
    min-width: 300px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease;
    pointer-events: all;
    border-left: 4px solid var(--accent-primary);
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

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

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--error);
}

.toast.warning {
    border-left-color: var(--warning);
}

.toast-icon {
    font-size: 24px;
}

.toast-message {
    flex: 1;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
}

/* Progress Indicators */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    transition: width 0.3s ease;
    border-radius: 3px;
}

.progress-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 6px solid var(--bg-tertiary);
    border-top-color: var(--accent-primary);
    animation: spin 1s linear infinite;
}

.progress-percentage {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 5px;
}

/* Footer */
.footer {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 40px 0;
    margin-top: 80px;
    border-top: 1px solid var(--border-color);
}

.footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-links {
    display: flex;
    gap: 20px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
}

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

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus styles for accessibility */
*:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

button:focus,
a:focus,
input:focus,
select:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
    }

    .nav-links {
        width: 100%;
        justify-content: center;
    }

    .search-bar {
        width: 100%;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .filters {
        width: 100%;
    }

    .filters select {
        flex: 1;
    }

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

    .app-detail-header {
        flex-direction: column;
        text-align: center;
    }

    .modal-content {
        width: 95%;
        margin: 20px auto;
    }

    .app-detail-body {
        padding: 20px;
    }

    .screenshots {
        flex-direction: column;
    }

    .screenshot {
        width: 100%;
        min-width: unset;
    }

    .advanced-filters {
        width: 100%;
        right: -100%;
    }

    .comparison-bar {
        flex-direction: column;
        gap: 10px;
    }

    .comparison-items {
        overflow-x: auto;
        width: 100%;
    }

    .gallery-prev {
        left: 10px;
    }

    .gallery-next {
        right: 10px;
    }

    .toast-container {
        left: 20px;
        right: 20px;
    }

    .toast {
        min-width: unset;
    }
}

/* Print styles */
@media print {

    .header,
    .footer,
    .filters,
    .modal,
    .toast-container,
    .comparison-bar {
        display: none !important;
    }
}