/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #21262d;
    --bg-hover: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-color: #58a6ff;
    --accent-hover: #79c0ff;
    --border-color: #30363d;
    --rank-bg: #238636;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.logo-link {
    text-decoration: none;
    font-size: 24px;
    font-weight: 700;
}

.logo-text {
    color: var(--text-primary);
}

.logo-highlight {
    color: var(--accent-color);
}

.nav {
    display: flex;
    gap: 8px;
}

.nav-item {
    padding: 8px 16px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.nav-item:hover {
    color: var(--text-primary);
    background-color: var(--bg-hover);
}

.nav-item.active {
    color: var(--accent-color);
    background-color: rgba(88, 166, 255, 0.1);
}

/* Main Content Grid */
.main-content {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 20px;
}

/* Source Card Styles */
.source-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.source-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}

.source-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.source-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.update-time {
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px 8px;
    background-color: var(--bg-secondary);
    border-radius: 4px;
}

.refresh-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.refresh-btn:hover {
    color: var(--accent-color);
    background-color: var(--bg-hover);
}

.refresh-icon {
    width: 18px;
    height: 18px;
}

.refresh-icon.spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Card Body */
.card-body {
    padding: 12px 0;
}

.news-list {
    list-style: none;
}

.news-item {
    border-bottom: 1px solid var(--border-color);
}

.news-item:last-child {
    border-bottom: none;
}

.news-link {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 20px;
    text-decoration: none;
    color: var(--text-primary);
    transition: background-color 0.2s ease;
}

.news-link:hover {
    background-color: var(--bg-hover);
}

.news-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    background-color: var(--rank-bg);
    color: white;
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
    flex-shrink: 0;
}

.news-item:nth-child(1) .news-rank {
    background-color: #da3633;
}

.news-item:nth-child(2) .news-rank {
    background-color: #f0883e;
}

.news-item:nth-child(3) .news-rank {
    background-color: #58a6ff;
}

.news-title {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.news-link:hover .news-title {
    color: var(--accent-color);
}

/* Footer */
.footer {
    text-align: center;
    padding: 40px 0 20px;
    color: var(--text-muted);
    font-size: 12px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    .header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .main-content {
        grid-template-columns: 1fr;
    }

    .source-card {
        margin-bottom: 16px;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Loading Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}