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

:root {
    --primary-color: #ff6b35;
    --secondary-color: #f7931e;
    --dark-color: #1a1a1a;
    --light-color: #f8f9fa;
    --gray-color: #6c757d;
    --border-color: #e0e0e0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
    --radius: 12px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    background-color: var(--light-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* Header */
.header {
    background: white;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    padding: 20px 0;
    text-align: center;
}

.logo {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

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

.tagline {
    color: var(--gray-color);
    font-size: 0.9rem;
    margin-top: 5px;
}

/* Category Navigation */
.category-nav {
    background: white;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 100px;
    z-index: 99;
}

.category-scroll {
    display: flex;
    gap: 10px;
    padding: 15px 0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.category-scroll::-webkit-scrollbar {
    display: none;
}

.category-btn {
    padding: 8px 20px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.category-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

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

/* View Toggle */
.view-toggle {
    background: white;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.toggle-buttons {
    display: flex;
    gap: 10px;
}

.toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.toggle-btn:hover {
    border-color: var(--primary-color);
}

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

.stats {
    color: var(--gray-color);
    font-size: 0.9rem;
}

/* Main Content */
.main {
    flex: 1;
    padding: 30px 0;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 60px 20px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}

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

/* Error State */
.error {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 20px;
}

.error h2 {
    color: var(--dark-color);
    margin-bottom: 10px;
}

.retry-btn {
    margin-top: 20px;
    padding: 10px 30px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.retry-btn:hover {
    background: var(--secondary-color);
}

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

.article-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
}

.article-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.article-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: linear-gradient(135deg, var(--border-color) 0%, #f0f0f0 100%);
}

.article-content {
    padding: 20px;
}

.article-source {
    display: inline-block;
    padding: 4px 12px;
    background: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    margin-bottom: 10px;
}

.article-title {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 10px;
    color: var(--dark-color);
}

.article-description {
    font-size: 0.9rem;
    color: var(--gray-color);
    line-height: 1.5;
    margin-bottom: 15px;
}

.article-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--gray-color);
}

.article-time {
    display: flex;
    align-items: center;
    gap: 5px;
}

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

.engagement-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Aggregator View */
.aggregator-view {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.source-group {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.source-header {
    background: var(--primary-color);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.source-name {
    font-size: 1.3rem;
    font-weight: 600;
}

.source-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.source-articles {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.source-article {
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: var(--transition);
    cursor: pointer;
}

.source-article:hover {
    border-color: var(--primary-color);
    background: #fff8f5;
}

/* Trending Sidebar */
.trending-sidebar {
    position: fixed;
    right: -400px;
    top: 0;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
}

.trending-sidebar.active {
    right: 0;
}

.trending-header {
    position: sticky;
    top: 0;
    background: white;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.trending-header h3 {
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-trending {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--gray-color);
    line-height: 1;
}

.trending-content {
    padding: 20px;
}

.trending-topic {
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 15px;
    transition: var(--transition);
    cursor: pointer;
}

.trending-topic:hover {
    border-color: var(--primary-color);
    background: #fff8f5;
}

.topic-name {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 5px;
    text-transform: capitalize;
}

.topic-count {
    color: var(--gray-color);
    font-size: 0.9rem;
}

.topic-score {
    float: right;
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
}

/* Floating Trending Button */
.trending-float-btn {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 60px;
    height: 60px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-hover);
    transition: var(--transition);
    z-index: 99;
}

.trending-float-btn:hover {
    transform: scale(1.1);
    background: var(--secondary-color);
}

/* Footer */
.footer {
    background: white;
    border-top: 1px solid var(--border-color);
    padding: 30px 0;
    margin-top: 50px;
}

.footer-content {
    text-align: center;
    color: var(--gray-color);
    font-size: 0.9rem;
}

.footer-content p {
    margin: 5px 0;
}

.footer-content a {
    color: var(--primary-color);
    text-decoration: none;
}

.footer-content a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        padding: 15px 0;
    }
    
    .logo {
        font-size: 1.5rem;
    }
    
    .logo-icon {
        font-size: 2rem;
    }
    
    .news-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .trending-sidebar {
        width: 100%;
        right: -100%;
    }
    
    .category-nav {
        top: 85px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .view-toggle .container {
        flex-direction: column;
        gap: 15px;
    }
    
    .toggle-buttons {
        width: 100%;
        justify-content: center;
    }
}