:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f0f0f0;
    --text-primary: #000000;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --border-color: #e0e0e0;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
    --accent: #000000;
    --accent-hover: #333333;
}

[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-tertiary: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #999999;
    --text-tertiary: #666666;
    --border-color: #2a2a2a;
    --shadow: rgba(255, 255, 255, 0.1);
    --shadow-hover: rgba(255, 255, 255, 0.15);
    --accent: #ffffff;
    --accent-hover: #cccccc;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: 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;
}

/* Navbar */
.navbar {
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.95);
}

[data-theme="dark"] .navbar {
    background-color: rgba(0, 0, 0, 0.95);
}

.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand a {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 18px;
}

.nav-links {
    display: flex;
    gap: 32px;
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    transition: color 0.2s;
    position: relative;
}

.nav-link:hover,
.nav-link.active {
    color: var(--text-primary);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--accent);
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s;
}

.theme-toggle:hover {
    background-color: var(--bg-secondary);
}

.theme-toggle .sun-icon {
    display: none;
}

.theme-toggle .moon-icon {
    display: block;
}

[data-theme="dark"] .theme-toggle .sun-icon {
    display: block;
}

[data-theme="dark"] .theme-toggle .moon-icon {
    display: none;
}

/* Page Header */
.page-header {
    padding: 60px 0 40px;
    text-align: center;
}

.page-header h1 {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 18px;
    color: var(--text-secondary);
}

/* Filters */
.filters {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
    display: flex;
    align-items: center;
}

.search-box svg {
    position: absolute;
    left: 16px;
    color: var(--text-tertiary);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 12px 16px 12px 48px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    transition: all 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--shadow);
}

.filter-group {
    display: flex;
    gap: 12px;
}

.filter-select {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-select:hover {
    border-color: var(--accent);
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--shadow);
}

/* Stats Bar */
.stats-bar {
    padding: 16px 0;
    margin-bottom: 32px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

/* Apps Grid */
.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 80px;
}

.app-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
    display: flex;
    gap: 16px;
}

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

.app-icon {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
}

.app-icon img {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    object-fit: cover;
}

.app-info {
    flex: 1;
    min-width: 0;
}

.app-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.app-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.app-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.category-badge,
.version-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* Loading & Error States */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

.error,
.no-results {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}

/* App Detail Page */
.breadcrumb {
    padding: 24px 0;
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

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

.app-detail {
    margin-bottom: 80px;
}

.app-header {
    display: flex;
    gap: 32px;
    align-items: flex-start;
    padding: 32px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 48px;
    flex-wrap: wrap;
}

.app-header-main {
    flex: 1;
    display: flex;
    gap: 24px;
    min-width: 300px;
}

.app-header-icon {
    width: 120px;
    height: 120px;
    border-radius: 24px;
    flex-shrink: 0;
}

.app-header-info h1 {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.app-developer-link a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.app-developer-link a:hover {
    color: var(--text-primary);
}

.app-badges {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.app-header-actions {
    display: flex;
    align-items: center;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background-color: var(--accent);
    color: var(--bg-primary);
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

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

.app-body {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 48px;
}

.app-section {
    margin-bottom: 48px;
}

.app-section h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 20px;
}

.app-description {
    color: var(--text-secondary);
    line-height: 1.8;
}

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

.screenshot-thumb {
    width: 100%;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border-color);
}

.screenshot-thumb:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px var(--shadow-hover);
}

.version-notes {
    color: var(--text-secondary);
    line-height: 1.8;
}

.permissions-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.permission-item {
    padding: 16px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.permission-item strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.permission-item p {
    font-size: 14px;
    color: var(--text-secondary);
}

.related-apps {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}

.related-app-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
    text-align: center;
}

.related-app-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-hover);
    border-color: var(--accent);
}

.related-app-card img {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    margin-bottom: 12px;
}

.related-app-card h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.related-app-card p {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Sidebar */
.app-sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.info-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
}

.info-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.info-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.info-list dt {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.info-list dd {
    font-size: 14px;
    color: var(--text-primary);
}

.info-list dd a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s;
}

.info-list dd a:hover {
    color: var(--text-secondary);
}

.bundle-id,
.source-url {
    word-break: break-all;
    font-size: 13px;
}

/* Authors Page */
.authors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 80px;
}

.author-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.author-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow-hover);
    border-color: var(--accent);
}

.author-apps-preview {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.author-apps-preview img {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    object-fit: cover;
}

.author-name {
    font-size: 20px;
    font-weight: 600;
}

.author-stats {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Author Detail */
.author-detail {
    margin-bottom: 80px;
}

.author-header {
    display: flex;
    gap: 24px;
    align-items: center;
    padding: 32px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 48px;
}

.author-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
}

.author-header-info h1 {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 8px;
}

.author-apps-section h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 24px;
}

/* Screenshot Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 32px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-prev {
    left: 20px;
}

.modal-next {
    right: 20px;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.modal-content img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 8px;
}

.modal-counter {
    color: white;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 20px;
}

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

.footer-content {
    text-align: center;
}

.footer-content p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 8px;
}

.footer-note {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Responsive Design */
@media (max-width: 768px) {
    .page-header h1 {
        font-size: 36px;
    }

    .filters {
        flex-direction: column;
    }

    .filter-group {
        flex-direction: column;
    }

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

    .app-body {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        order: -1;
    }

    .app-header {
        flex-direction: column;
    }

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

    .app-header-icon {
        margin: 0 auto;
    }

    .nav-links {
        gap: 20px;
    }

    .nav-link {
        font-size: 14px;
    }

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

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

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

    .modal-nav {
        display: none;
    }
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-primary: #000000;
        --bg-secondary: #0a0a0a;
        --bg-tertiary: #1a1a1a;
        --text-primary: #ffffff;
        --text-secondary: #999999;
        --text-tertiary: #666666;
        --border-color: #2a2a2a;
        --shadow: rgba(255, 255, 255, 0.1);
        --shadow-hover: rgba(255, 255, 255, 0.15);
        --accent: #ffffff;
        --accent-hover: #cccccc;
    }

    :root:not([data-theme="light"]) .navbar {
        background-color: rgba(0, 0, 0, 0.95);
    }
}
