/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
    background: #ffffff;
    color: #1d1d1f;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

/* Header */
.header {
    text-align: center;
    padding: 60px 20px 40px;
    border-bottom: 1px solid #f5f5f7;
}

.logo {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #1d1d1f;
    margin-bottom: 8px;
}

.tagline {
    font-size: 1.1rem;
    color: #86868b;
    font-weight: 400;
    letter-spacing: -0.2px;
}

/* Search */
.search-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 30px 0;
}

.search-box {
    width: 100%;
    max-width: 500px;
    padding: 12px 16px;
    border: 1px solid #e5e5e7;
    border-radius: 10px;
    font-size: 1rem;
    color: #1d1d1f;
    background: #f9f9fb;
    transition: all 0.3s ease;
    outline: none;
}

.search-box:focus {
    background: #ffffff;
    border-color: #a9abae;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.search-box::placeholder {
    color: #a1a1a6;
}

/* Main Content */
.main {
    padding: 20px 0 60px;
}

/* Categories */
.categories {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.category {
    border: 1px solid #f5f5f7;
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
    transition: box-shadow 0.3s ease;
}

.category:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

/* Category Header */
.category-header {
    padding: 16px 20px;
    background: #f9f9fb;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background 0.2s ease;
}

.category-header:hover {
    background: #f5f5f7;
}

.category-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1d1d1f;
    letter-spacing: -0.2px;
}

.category-count {
    font-size: 0.85rem;
    color: #86868b;
    background: #ffffff;
    padding: 4px 8px;
    border-radius: 6px;
    margin-left: 12px;
}

.expand-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a1a1a6;
    transition: transform 0.3s ease;
    font-size: 0.9rem;
}

.expand-icon.open {
    transform: rotate(180deg);
}

/* Apps Container */
.apps {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    padding: 20px;
    max-height: 2000px;
    opacity: 1;
    transition: all 0.3s ease;
    overflow: hidden;
}

.apps.collapsed {
    max-height: 0;
    padding: 0 20px;
    opacity: 0;
    overflow: hidden;
}

/* App Card */
.app-card {
    padding: 16px;
    background: #f9f9fb;
    border-radius: 10px;
    transition: all 0.2s ease;
    cursor: default;
    border: 1px solid transparent;
}

.app-card:hover {
    background: #ffffff;
    border: 1px solid #f5f5f7;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.app-name {
    font-size: 1rem;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 8px;
    letter-spacing: -0.3px;
}

.app-description {
    font-size: 0.85rem;
    color: #86868b;
    margin-bottom: 12px;
    line-height: 1.5;
}

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

.app-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #ffffff;
    border: 1px solid #e5e5e7;
    border-radius: 6px;
    text-decoration: none;
    color: #0071e3;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.app-link:hover {
    background: #0071e3;
    color: #ffffff;
    border-color: #0071e3;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.2);
}

/* Badge */
.badge {
    display: inline-block;
    padding: 2px 8px;
    background: #e8e8ed;
    border-radius: 4px;
    font-size: 0.75rem;
    color: #666666;
    margin-top: 8px;
}

/* Footer */
.footer {
    text-align: center;
    padding: 40px 20px;
    color: #a1a1a6;
    font-size: 0.9rem;
    border-top: 1px solid #f5f5f7;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #a1a1a6;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 1.1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .logo {
        font-size: 2rem;
    }

    .tagline {
        font-size: 0.95rem;
    }

    .header {
        padding: 40px 20px 30px;
    }

    .apps {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 12px;
        padding: 16px;
    }

    .search-box {
        padding: 10px 14px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .app-card {
        padding: 14px;
    }

    .category-header {
        padding: 14px 16px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 16px;
    }

    .logo {
        font-size: 1.75rem;
    }

    .tagline {
        font-size: 0.9rem;
    }

    .header {
        padding: 30px 16px 25px;
    }

    .apps {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 12px;
    }

    .search-wrapper {
        padding: 20px 0;
    }

    .app-card {
        padding: 12px;
    }

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

    .app-description {
        font-size: 0.8rem;
        margin-bottom: 10px;
    }

    .app-links {
        gap: 6px;
    }

    .app-link {
        padding: 5px 10px;
        font-size: 0.75rem;
    }
}

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

.category {
    animation: fadeIn 0.3s ease;
}

/* Dark Mode Support (Optional) */
@media (prefers-color-scheme: dark) {
    body {
        background: #000000;
        color: #f5f5f7;
    }

    .header {
        border-bottom-color: #424245;
    }

    .logo {
        color: #f5f5f7;
    }

    .tagline {
        color: #a1a1a6;
    }

    .search-box {
        background: #1d1d1f;
        border-color: #424245;
        color: #f5f5f7;
    }

    .search-box:focus {
        background: #262627;
        border-color: #555555;
    }

    .category {
        background: #1d1d1f;
        border-color: #424245;
    }

    .category-header {
        background: #262627;
        border-bottom: 1px solid #424245;
    }

    .category-header:hover {
        background: #323234;
    }

    .category-title {
        color: #f5f5f7;
    }

    .category-count {
        background: #1d1d1f;
        color: #a1a1a6;
    }

    .app-card {
        background: #262627;
    }

    .app-card:hover {
        background: #323234;
    }

    .app-name {
        color: #f5f5f7;
    }

    .app-description {
        color: #a1a1a6;
    }

    .app-link {
        background: #1d1d1f;
        border-color: #424245;
    }

    .app-link:hover {
        background: #0071e3;
        border-color: #0071e3;
    }

    .badge {
        background: #424245;
        color: #a1a1a6;
    }

    .footer {
        border-top-color: #424245;
    }

    .empty-state {
        color: #86868b;
    }
}

/* Footer Links */
.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.footer-link {
    color: #0071e3;
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.footer-link:hover {
    text-decoration: underline;
    opacity: 0.8;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: #ffffff;
    border-radius: 16px;
    padding: 32px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 2rem;
    color: #a1a1a6;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #f5f5f7;
    color: #1d1d1f;
}

.modal-body {
    color: #1d1d1f;
    line-height: 1.6;
}

.modal-body h2 {
    font-size: 1.5rem;
    margin-bottom: 16px;
    color: #1d1d1f;
}

.modal-body p {
    margin-bottom: 12px;
    color: #555555;
}

.modal-body a {
    color: #0071e3;
}

.modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-btn-primary {
    background: #0071e3;
    color: #ffffff;
}

.modal-btn-primary:hover {
    background: #0066cc;
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
    transform: translateY(-1px);
}

.modal-btn-primary:active {
    transform: translateY(0);
}

.modal-btn-secondary {
    background: #f5f5f7;
    color: #1d1d1f;
    border: 1px solid #e5e5e7;
}

.modal-btn-secondary:hover {
    background: #ffffff;
    border-color: #a9abae;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.modal-btn-secondary:active {
    transform: translateY(0);
}

/* 最近更新应用项 */
.newest-app-item {
    padding: 16px;
    background: #f9f9fb;
    border-radius: 10px;
    margin-bottom: 12px;
    border: 1px solid #f5f5f7;
    transition: all 0.2s ease;
}

.newest-app-item:hover {
    background: #ffffff;
    border: 1px solid #e5e5e7;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.newest-app-name {
    font-size: 1rem;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 8px;
}

.newest-app-description {
    font-size: 0.85rem;
    color: #86868b;
    margin-bottom: 12px;
    line-height: 1.5;
}

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

/* Dark Mode - Modal */
@media (prefers-color-scheme: dark) {
    .modal-content {
        background: #1d1d1f;
        color: #f5f5f7;
    }

    .modal {
        background: rgba(0, 0, 0, 0.7);
    }

    .modal-close {
        color: #86868b;
    }

    .modal-close:hover {
        background: #262627;
        color: #f5f5f7;
    }

    .modal-body h2 {
        color: #f5f5f7;
    }

    .modal-body p {
        color: #a1a1a6;
    }

    .footer-link {
        color: #0a84ff;
    }

    .modal-btn-primary {
        background: #0a84ff;
        color: #ffffff;
    }

    .modal-btn-primary:hover {
        background: #0871e8;
    }

    .modal-btn-secondary {
        background: #262627;
        color: #f5f5f7;
        border-color: #424245;
    }

    .modal-btn-secondary:hover {
        background: #323234;
        border-color: #555555;
    }

    .newest-app-item {
        background: #262627;
        border-color: #424245;
    }

    .newest-app-item:hover {
        background: #323234;
        border-color: #555555;
    }

    .newest-app-name {
        color: #f5f5f7;
    }

    .newest-app-description {
        color: #a1a1a6;
    }
}

@media (max-width: 480px) {
    .modal-content {
        padding: 24px;
        border-radius: 12px;
    }

    .modal-body h2 {
        font-size: 1.2rem;
    }

    .footer-links {
        gap: 12px;
    }

    .footer-link {
        font-size: 0.8rem;
    }

    .modal-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
        flex: 1;
        min-width: 120px;
    }

    .newest-app-item {
        padding: 12px;
    }

    .newest-app-name {
        font-size: 0.95rem;
    }

    .newest-app-description {
        font-size: 0.8rem;
    }
}
