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

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #ec4899;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 60px 0;
    text-align: center;
}

.header-content h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.logo-icon {
    font-size: 3rem;
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    font-weight: 300;
}

/* Stats Section */
.stats {
    padding: 40px 0;
    background: var(--surface);
    margin: -30px 20px 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 30px;
    text-align: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Filter Section */
.filter-section {
    margin-bottom: 40px;
}

.filter-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.search-box {
    position: relative;
    max-width: 400px;
    margin: 0 auto;
}

.search-box i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 12px 16px 12px 45px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: var(--transition);
}

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

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.filter-btn {
    padding: 8px 16px;
    border: 2px solid var(--border);
    background: var(--surface);
    border-radius: 25px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.filter-btn:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

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

/* Websites Grid */
.websites-section {
    margin-bottom: 60px;
}

.websites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.website-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.website-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.website-header {
    margin-bottom: 16px;
}

.website-info {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.website-logo {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: contain;
    background: var(--background);
    border: 1px solid var(--border);
    flex-shrink: 0;
    align-self: center;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: auto;
    backface-visibility: hidden;
    transform: translateZ(0);
    image-rendering: -webkit-smooth;
    image-rendering: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.website-text {
    flex: 1;
    min-width: 0;
}

.website-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    transition: var(--transition);
    display: inline-block;
}

.website-title:hover {
    color: var(--primary-color);
}

.website-url {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-decoration: none;
    word-break: break-all;
    margin-top: 4px;
}

.website-description {
    color: var(--text-secondary);
    margin-bottom: 16px;
    flex-grow: 1;
    line-height: 1.5;
}

.website-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.tag {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Language Badge */
.language-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 8px;
    vertical-align: middle;
    text-transform: uppercase;
}

.language-zh {
    background: linear-gradient(135deg, #ff4757, #ff6b81);
    color: white;
}

.language-en {
    background: linear-gradient(135deg, #3742fa, #5352ed);
    color: white;
}

.language-ja {
    background: linear-gradient(135deg, #ff9ff3, #ee5a6f);
    color: white;
}

.language-ko {
    background: linear-gradient(135deg, #48dbfb, #0abde3);
    color: white;
}

.language-es {
    background: linear-gradient(135deg, #f9ca24, #f0932b);
    color: white;
}

.language-fr {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: white;
}

.language-de {
    background: linear-gradient(135deg, #fd79a8, #fdcb6e);
    color: white;
}

.language-ru {
    background: linear-gradient(135deg, #636e72, #2d3436);
    color: white;
}

.language-ar {
    background: linear-gradient(135deg, #00b894, #00cec9);
    color: white;
}

.language-pt {
    background: linear-gradient(135deg, #00b894, #55efc4);
    color: white;
}

.language-it {
    background: linear-gradient(135deg, #e17055, #fab1a0);
    color: white;
}

.language-default {
    background: linear-gradient(135deg, #b2bec3, #636e72);
    color: white;
}

.category-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border-bottom-left-radius: var(--radius);
}

.website-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
}

.submitter-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

.submitter-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.submitter-link:hover {
    text-decoration: underline;
}

.added-date {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 400;
}

.visit-btn {
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.visit-btn:hover {
    background: var(--primary-dark);
    transform: translateX(2px);
}

/* Loading and No Results */
.loading, .no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.loading i {
    font-size: 2rem;
    margin-bottom: 16px;
}

.no-results i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* CTA Section */
.cta-section {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 60px 40px;
    border-radius: var(--radius);
    text-align: center;
    margin-bottom: 60px;
}

.cta-content h2 {
    font-size: 2rem;
    margin-bottom: 16px;
}

.cta-content p {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 24px;
}

.cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: white;
    color: var(--primary-color);
    padding: 12px 24px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

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

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-3px) scale(1.1);
    box-shadow: 0 6px 30px rgba(99, 102, 241, 0.4);
    background: linear-gradient(135deg, var(--primary-dark), var(--secondary-color));
}

.back-to-top:active {
    transform: translateY(-1px) scale(0.95);
}

.back-to-top i {
    transition: transform 0.3s ease;
}

.back-to-top:hover i {
    transform: translateY(-2px);
}

/* Footer */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 40px 0;
    margin-top: 60px;
}

.footer-content {
    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;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

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

.heart {
    color: #ef4444;
}

.codebuddy-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: var(--transition);
}

.codebuddy-link:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    transform: translateY(-1px);
}

.codebuddy-link:focus {
    outline: none;
}

/* 移除所有链接的焦点轮廓 */
a:focus {
    outline: none;
}

/* 可选：为键盘导航用户提供更好的焦点指示 */
a:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 4px;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .header-content h1 {
        font-size: 2rem;
        flex-direction: column;
        gap: 8px;
    }
    
    .stats {
        margin: 20px 10px 30px;
        padding: 30px 20px;
    }
    
    .filter-controls {
        align-items: center;
    }
    
    .filter-buttons {
        justify-content: center;
    }
    
    .websites-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .website-card {
        padding: 20px;
    }
    
    .cta-section {
        padding: 40px 20px;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .header {
        padding: 40px 0;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .filter-buttons {
        gap: 8px;
    }
    
    .filter-btn {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
}

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

.website-card {
    animation: fadeIn 0.5s ease-out;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Focus styles for accessibility */
button:focus,
input:focus,
a:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}