/* Modern Color Palette */
:root {
    --primary: #4f46e5;
    /* Indigo 600 */
    --primary-hover: #4338ca;
    /* Indigo 700 */
    --background: #fdfdfd;
    /* Very slight off-white */
    --surface: #ffffff;
    --text-main: #1e293b;
    /* Slate 800 */
    --text-secondary: #64748b;
    /* Slate 500 */
    --border: #f1f5f9;
    /* Slate 100 - very subtle */
    --border-hover: #e2e8f0;
    /* Slate 200 */

    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.02), 0 1px 2px -1px rgb(0 0 0 / 0.02);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.03), 0 4px 6px -4px rgb(0 0 0 / 0.03);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.05), 0 8px 10px -6px rgb(0 0 0 / 0.01);

    --radius: 1rem;
    /* More rounded */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-serif: 'Noto Serif Myanmar', serif;
}

/* Dark Mode Variables */
body.dark-mode {
    --primary: #6366f1;
    /* Indigo 500 - brighter for dark mode */
    --primary-hover: #818cf8;
    /* Indigo 400 */
    --background: #0f172a;
    /* Slate 900 */
    --surface: #1e293b;
    /* Slate 800 */
    --text-main: #f1f5f9;
    /* Slate 100 */
    --text-secondary: #94a3b8;
    /* Slate 400 */
    --border: #334155;
    /* Slate 700 */
    --border-hover: #475569;
    /* Slate 600 */

    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.5);
}

/* Dark Mode Specific Overrides */
body.dark-mode .navbar {
    background: rgba(15, 23, 42, 0.85);
    /* Darker blur */
    border-bottom: 1px solid var(--border);
}

body.dark-mode .content-block.original {
    background-color: #1e293b;
    /* Match surface */
    border-bottom: 1px solid var(--border);
}

body.dark-mode .content-block.translated {
    background-color: #0f172a;
    /* Darker background for distinction */
}

body.dark-mode .card-image {
    background: #334155;
}

body.dark-mode .page-link:hover,
body.dark-mode .page-link.active {
    background: var(--primary);
    border-color: var(--primary);
}

/* Theme Toggle Button */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 1rem;
}

.theme-toggle:hover {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.1);
    border-color: var(--primary);
}

body {
    font-family: var(--font-sans);
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.6;
    margin: 0;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 1.25rem 0;
}

.container {
    max-width: 1600px;
    /* Wide layout for dashboard feel */
    margin: 0 auto;
    padding: 0 1.5rem;
}

.navbar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    text-decoration: none;
    letter-spacing: -0.03em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-brand::before {
    content: '';
    display: block;
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 4px;
    transform: rotate(45deg);
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.04);
}

/* Feed Layout */
.feed-header {
    text-align: center;
    margin: 5rem 0 4rem;
}

.feed-title {
    font-size: 3rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 1.5rem;
    letter-spacing: -0.04em;
    line-height: 1.1;
}

.feed-grid {
    column-count: 3;
    column-gap: 2rem;
    padding-bottom: 6rem;
}

@media (min-width: 1600px) {
    .feed-grid {
        column-count: 4;
    }
}

@media (max-width: 1024px) {
    .feed-grid {
        column-count: 2;
    }
}

@media (max-width: 640px) {
    .feed-grid {
        column-count: 1;
    }
}

/* Card Styling */
.news-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    display: flex;
    flex-direction: column;
    /* Important for masonry */
    break-inside: avoid;
    margin-bottom: 2rem;
    height: auto;
    /* Allow height to adapt to content */
}

.news-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-hover);
}

.card-image {
    width: 100%;
    height: auto;
    /* Pinterest style: allow variable height */
    display: block;
    background: #f1f5f9;
}

.card-content {
    padding: 2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.source-badge {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.source-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    flex: 1;
}

.source-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.source-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.source-type-tag {
    font-size: 0.65rem;
    padding: 0.35rem;
    /* Uniform padding for icon */
    border-radius: 50%;
    /* Circle shape for icons */
    font-weight: 700;
    letter-spacing: 0.02em;
    border: 1px solid transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: default;
    flex-shrink: 0;
    margin-left: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
}

.source-type-tag:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.source-type-tag.rss {
    background-color: #fff1f2;
    color: #be123c;
    border-color: #fecdd3;
}

.source-type-tag.facebook {
    background-color: #eff6ff;
    color: #1d4ed8;
    border-color: #dbeafe;
}

.source-type-tag.telegram {
    background-color: #ecfeff;
    color: #0e7490;
    border-color: #cffafe;
}

.source-type-tag.twitter {
    background-color: #f8fafc;
    color: #334155;
    border-color: #e2e8f0;
}

/* Dark mode adjustments for tags */
body.dark-mode .source-type-tag.rss {
    background: #4c0519;
    color: #fda4af;
    border-color: #881337;
}

body.dark-mode .source-type-tag.facebook {
    background: #1e3a8a;
    color: #93c5fd;
    border-color: #1d4ed8;
}

body.dark-mode .source-type-tag.telegram {
    background: #164e63;
    color: #67e8f9;
    border-color: #155e75;
}

body.dark-mode .source-type-tag.twitter {
    background: #1e293b;
    color: #cbd5e1;
    border-color: #334155;
}

.card-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 1.5rem;
    line-height: 1.4;
    letter-spacing: -0.02em;
}

.card-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

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

/* Reusing Stack Styles from Template but refining here if needed */
.content-stack {
    border: 1px solid var(--border) !important;
}

.content-block.translated .content-text {
    font-family: var(--font-serif) !important;
    font-size: 1rem !important;
    line-height: 1.8 !important;
}

.card-excerpt {
    margin-bottom: 2rem;
    flex: 1;
    overflow: visible;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
    margin-top: auto;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.read-more {
    color: var(--text-main);
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s;
}

.read-more:hover {
    color: var(--primary);
    gap: 0.6rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 4rem;
}

.page-link {
    min-width: 44px;
    padding: 0 1rem;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-main);
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 600;
    font-size: 0.9rem;
}

.page-link:hover,
.page-link.active {
    background: var(--text-main);
    color: white;
    border-color: var(--text-main);
}

.page-link.disabled {
    opacity: 0.5;
    cursor: default;
    border: none;
    background: transparent;
}

/* Footer */
footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 4rem 0;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Back to Top Button */
#backToTop {
    position: fixed;
    bottom: 40px;
    right: 40px;
    z-index: 99;
    border: none;
    outline: none;
    background-color: var(--text-main);
    color: var(--background);
    cursor: pointer;
    padding: 16px;
    border-radius: 50%;
    box-shadow: var(--shadow-lg);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

#backToTop:hover {
    background-color: var(--primary);
    transform: translateY(-4px) scale(1);
    box-shadow: 0 15px 30px rgba(79, 70, 229, 0.3);
}

/* Filter Dropdown Styles */
.filter-btn {
    background-color: var(--surface);
    color: var(--text-main);
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    cursor: pointer;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.filter-btn:hover,
.filter-btn:focus {
    background-color: var(--surface);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--shadow-md);
}

.filter-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    margin-top: 0.5rem;
    background-color: var(--surface);
    min-width: 200px;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    z-index: 101;
    overflow: hidden;
    animation: fadeIn 0.15s ease-out;
}

.filter-dropdown-content a {
    color: var(--text-main);
    padding: 0.75rem 1.25rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.1s;
}

.filter-dropdown-content a:hover {
    background-color: #f8fafc;
    /* light grey hover */
    color: var(--primary);
}

.filter-dropdown-content a.active {
    background-color: rgba(79, 70, 229, 0.05);
    color: var(--primary);
    font-weight: 600;
}

.show {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dark mode adjustments for filter */
body.dark-mode .filter-dropdown-content a:hover {
    background-color: #334155;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-links {
        display: none;
    }

    .feed-title {
        font-size: 2.25rem;
    }

    .feed-grid {
        column-count: 1;
        column-gap: 2rem;
    }

    .card-content {
        padding: 1.5rem;
    }
}