/* Linux Republic Styles - Full Featured Version */

/* ============ CSS Variables ============ */
:root {
    /* Dark theme (default) */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-hover: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-green: #3fb950;
    --accent-orange: #d29922;
    --accent-blue: #58a6ff;
    --accent-purple: #a371f7;
    --accent-red: #f85149;
    --accent-cyan: #39c5cf;
    --border-color: #30363d;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
}

/* Light theme */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f6f8fa;
    --bg-tertiary: #eaeef2;
    --bg-hover: #d0d7de;
    --text-primary: #1f2328;
    --text-secondary: #656d76;
    --text-muted: #8c959f;
    --border-color: #d0d7de;
    --shadow: 0 8px 24px rgba(140, 149, 159, 0.2);
    --shadow-lg: 0 16px 48px rgba(140, 149, 159, 0.3);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

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

/* ============ Header ============ */
header {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    border-bottom: 1px solid var(--border-color);
    padding: 30px 0;
}

.header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
    position: relative;
}

.theme-toggle-btn {
    position: absolute;
    right: 0;
}

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

.logo .tux {
    font-size: 2.5rem;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.logo h1 {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.icon-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    text-decoration: none;
    transition: all 0.3s;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
    text-align: center;
    margin-bottom: 20px;
}

/* Search */
.search-container {
    display: flex;
    max-width: 600px;
    margin: 0 auto;
}

#search-input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-right: none;
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: 25px 0 0 25px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

#search-input:focus {
    border-color: var(--accent-green);
}

#search-input::placeholder {
    color: var(--text-muted);
}

.search-btn {
    background: var(--accent-green);
    border: none;
    color: var(--bg-primary);
    padding: 12px 20px;
    border-radius: 0 25px 25px 0;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s;
}

.search-btn:hover {
    background: #4ac959;
}

/* ============ Navigation ============ */
nav {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.categories {
    display: flex;
    list-style: none;
    gap: 8px;
    flex-wrap: wrap;
}

.cat-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 18px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.cat-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.cat-btn.active {
    background: var(--accent-green);
    color: var(--bg-primary);
    border-color: var(--accent-green);
}

.cat-btn.podcasts-btn {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    color: white;
    border-color: var(--accent-purple);
    text-decoration: none;
    display: inline-block;
}

.cat-btn.podcasts-btn:hover {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    transform: scale(1.05);
}

.nav-actions {
    display: flex;
    gap: 10px;
}

.nav-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.nav-btn:hover {
    background: var(--bg-hover);
}

#health-indicator {
    font-size: 0.7rem;
}

#health-indicator.healthy { color: var(--accent-green); }
#health-indicator.warning { color: var(--accent-orange); }
#health-indicator.error { color: var(--accent-red); }

.refresh-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-blue);
    color: var(--accent-blue);
    padding: 8px 18px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.refresh-btn:hover {
    background: var(--accent-blue);
    color: var(--bg-primary);
}

.refresh-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* ============ Trending Section ============ */
.trending-section {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 0;
}

.trending-section h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.trending-topics {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.trending-tag {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--accent-cyan);
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s;
}

.trending-tag:hover {
    background: var(--accent-cyan);
    color: var(--bg-primary);
}

.trending-tag .count {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-left: 5px;
}

/* ============ Main Content ============ */
main {
    padding: 30px 0;
    min-height: calc(100vh - 400px);
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

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

.news-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.news-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: var(--accent-green);
}

.news-card .thumbnail {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.news-card .card-content {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.news-card .meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.news-card .category {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 12px;
    letter-spacing: 0.5px;
}

.category.general { background: var(--accent-blue); color: var(--bg-primary); }
.category.security { background: var(--accent-red); color: white; }
.category.kernel { background: var(--accent-purple); color: white; }
.category.distro { background: var(--accent-orange); color: var(--bg-primary); }

.news-card .date {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.news-card h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    line-height: 1.4;
}

.news-card h3 a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.3s ease;
}

.news-card h3 a:hover {
    color: var(--accent-green);
}

.news-card .summary {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 15px;
    flex-grow: 1;
    line-height: 1.5;
}

.news-card .card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.news-card .source {
    color: var(--accent-blue);
    font-size: 0.8rem;
    font-weight: 500;
}

.news-card .reading-time {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.news-card .actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 5px;
    border-radius: 5px;
    transition: all 0.3s;
}

.action-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.action-btn.bookmarked {
    color: var(--accent-orange);
}

/* Share buttons */
.share-buttons {
    display: flex;
    gap: 5px;
}

.share-btn {
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.share-btn:hover {
    color: var(--text-primary);
}

.share-btn.twitter:hover { color: #1da1f2; }
.share-btn.linkedin:hover { color: #0077b5; }
.share-btn.reddit:hover { color: #ff4500; }

/* ============ Loading & Empty States ============ */
.loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
}

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

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

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

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

/* ============ Modals ============ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
}

.modal.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    max-width: 800px;
    width: 100%;
    margin: 40px auto;
    position: relative;
    animation: modalIn 0.3s ease;
}

.modal-small {
    max-width: 450px;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-primary);
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    transition: background 0.3s;
    z-index: 1;
}

.modal-close:hover {
    background: var(--bg-hover);
}

#modal-body {
    padding: 30px;
}

#modal-body h2 {
    margin-bottom: 15px;
    padding-right: 40px;
}

#modal-body .article-meta {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

#modal-body .article-content {
    line-height: 1.8;
    margin-bottom: 25px;
}

#modal-body .read-more {
    display: inline-block;
    background: var(--accent-green);
    color: var(--bg-primary);
    padding: 12px 25px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.3s;
}

#modal-body .read-more:hover {
    transform: scale(1.05);
}

/* Comments */
.comments-section {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 1px solid var(--border-color);
}

.comments-section h3 {
    margin-bottom: 20px;
}

.comment-form {
    margin-bottom: 25px;
}

.comment-form input,
.comment-form textarea {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-family: inherit;
}

.comment-form textarea {
    min-height: 100px;
    resize: vertical;
}

.comment-form button {
    background: var(--accent-blue);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.3s;
}

.comment-form button:hover {
    background: #4fadff;
}

.comment {
    background: var(--bg-tertiary);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.comment-author {
    font-weight: 600;
    color: var(--accent-blue);
}

.comment-date {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.comment-content {
    color: var(--text-secondary);
}

/* Subscribe Modal */
#subscribe-modal h2 {
    padding: 30px 30px 0;
}

#subscribe-form {
    padding: 20px 30px 30px;
}

#subscribe-form input,
#subscribe-form select {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 1rem;
}

.category-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

.category-checkboxes label {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-secondary);
    cursor: pointer;
}

.subscribe-submit {
    width: 100%;
    background: var(--accent-green);
    border: none;
    color: var(--bg-primary);
    padding: 12px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background 0.3s;
}

.subscribe-submit:hover {
    background: #4ac959;
}

.subscribe-message {
    text-align: center;
    padding: 0 30px 20px;
    color: var(--accent-green);
}

/* Health Modal */
#health-modal h2 {
    padding: 30px 30px 20px;
}

.health-summary {
    padding: 0 30px 20px;
    display: flex;
    gap: 30px;
}

.health-stat {
    text-align: center;
}

.health-stat .number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-green);
}

.health-stat .label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.health-list {
    padding: 0 30px 30px;
    max-height: 400px;
    overflow-y: auto;
}

.health-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 8px;
}

.health-item .feed-name {
    font-weight: 500;
}

.health-item .feed-category {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.health-item .status {
    font-size: 1.2rem;
}

.health-item .status.healthy::after { content: '✓'; color: var(--accent-green); }
.health-item .status.unhealthy::after { content: '✗'; color: var(--accent-red); }

/* ============ Footer ============ */
footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 40px 0 20px;
    margin-top: 50px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.footer-section h4 {
    color: var(--text-primary);
    margin-bottom: 15px;
}

.footer-section p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer-btn {
    display: inline-block;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 15px;
    border-radius: 20px;
    margin-right: 10px;
    margin-bottom: 10px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.footer-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.install-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.footer-bottom p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

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

    .logo .tux {
        font-size: 2rem;
    }

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

    nav .container {
        flex-direction: column;
    }

    .categories {
        justify-content: center;
    }

    .status-bar {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .modal-content {
        margin: 20px;
    }

    .health-summary {
        flex-direction: column;
        gap: 15px;
    }

    .header-top {
        flex-direction: column;
        gap: 15px;
    }

    .theme-toggle-btn {
        position: static;
    }
}

/* ============ Scroll Sentinel ============ */
#scroll-sentinel {
    height: 1px;
    margin-top: 20px;
}

/* ============ PWA Install Prompt ============ */
.pwa-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--accent-green);
    border-radius: 12px;
    padding: 15px 25px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
}

.pwa-prompt button {
    background: var(--accent-green);
    border: none;
    color: var(--bg-primary);
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
}

.pwa-prompt .dismiss {
    background: transparent;
    color: var(--text-muted);
}
