/* Modern Clean Dark Theme & Grid Layout */
:root {
    --bg-app: #121212;
    --bg-panel: #1e1e1e;
    --bg-card: #252525;
    --bg-element: #2c2c2c;
    --bg-hover: #333333;

    --text-primary: #f5f5f5;
    --text-secondary: #c0c0c0;
    --text-muted: #808080;

    --accent: #bb86fc;
    --accent-hover: #9965f4;
    --accent-dim: rgba(187, 134, 252, 0.1);

    --border: #333333;
    --border-light: #404040;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Light Mode Theme */
[data-theme="light"] {
    --bg-app: #f5f5f5;
    --bg-panel: #ffffff;
    --bg-card: #ffffff;
    --bg-element: #f8f8f8;
    --bg-hover: #e8e8e8;

    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-muted: #9a9a9a;

    --accent: #6200ea;
    --accent-hover: #7c4dff;
    --accent-dim: rgba(98, 0, 234, 0.1);

    --border: #e0e0e0;
    --border-light: #f0f0f0;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.15);

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}


/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    outline: none;
}

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 400;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-app);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-hover);
}

/* App Layout */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.header {
    height: 60px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}



/* Search */
.search-container {
    flex: 1;
    max-width: 480px;
    margin: 0 20px;
    position: relative;
}

.search-input {
    width: 100%;
    height: 38px;
    background: var(--bg-element);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0 15px 0 40px;
    color: var(--text-primary);
    font-family: inherit;
    transition: all 0.2s;
}

.search-input:focus {
    background: var(--bg-card);
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 12px;
}

.search-btn:hover {
    color: var(--text-primary);
    border-left-color: var(--accent);
}

.header-right {
    display: flex;
    gap: 12px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

/* Main Content Area */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    /* Prevent body scroll */
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    z-index: 100;
}

.sidebar-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.sidebar-header h2 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.add-btn {
    background: var(--accent);
    color: #121212;
    border: none;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.add-btn:hover {
    transform: scale(1.05);
    background: var(--accent-hover);
}

.accounts-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

/* Category & Feed Items */
.sidebar-section {
    margin-bottom: 4px;
}

.category-header {
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
    user-select: none;
}

.category-header:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.category-header.active {
    color: var(--accent);
    background: var(--accent-dim);
}

.category-name {
    display: flex;
    align-items: center;
    gap: 10px;
}

.category-chevron {
    transition: transform 0.3s ease;
    opacity: 0.5;
}

.category-header.collapsed .category-chevron {
    transform: rotate(-90deg);
}

.sidebar-links {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.2s;
    padding-left: 12px;
}

.category-header.collapsed+.sidebar-links {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}

.sidebar-subheader {
    padding: 8px 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-top: 8px;
}

.sidebar-link {
    display: block;
    padding: 8px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 4px;
    margin: 2px 8px;
    transition: all 0.2s;
}

.sidebar-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-link.active {
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 500;
}

.category-toggle {
    font-size: 10px;
    opacity: 0.7;
    width: 14px;
    text-align: center;
}

/* RT and QT Enhancements */
.rt-indicator-small {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.rt-header {
    padding: 0 !important;
    margin-bottom: 12px !important;
    background: none !important;
    border: none !important;
}

.quoted-tweet {
    background: none !important;
    border: none !important;
    padding-left: 12px !important;
    border-left: 2px solid var(--border) !important;
    margin-top: 10px !important;
}

.quoted-tweet .quoted-image {
    border-radius: 8px;
    margin-top: 8px;
}

/* Force small size for avatars in RT/QT to prevent "large box" issue */
.rt-header img,
.rt-avatar,
.quoted-tweet img.qt-avatar,
.quoted-tweet .qt-avatar {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    display: block !important;
    box-shadow: none !important;
    margin: 0 !important;
    max-width: none !important;
}

.quoted-tweet img.qt-avatar,
.quoted-tweet .qt-avatar {
    width: 32px !important;
    height: 32px !important;
}

.category-count {
    background: var(--bg-element);
    color: var(--text-muted);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
}

.category-feeds {
    display: none;
    background: rgba(0, 0, 0, 0.1);
}

/* Refresh Indicator */
.refresh-indicator {
    background: var(--accent-dim);
    color: var(--accent);
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    border-bottom: 1px solid var(--border);
    animation: fadeIn 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.refresh-indicator .spinner-small {
    width: 12px;
    height: 12px;
    border: 2px solid var(--accent);
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

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

.feed-item {
    padding: 8px 20px 8px 48px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all 0.2s;
}

.feed-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.feed-item.active {
    color: var(--accent);
    background: var(--accent-dim);
    border-color: var(--accent);
}

/* Feed Area (Grid) */

/* Dashboard Layout */
.dashboard {
    flex: 1;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    /* Columns scroll independently */
    background: var(--bg-app);
}

.column {
    flex: 0 0 520px;
    /* Reduced from 600px to fit better */
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--bg-app);
    min-width: 400px;
    max-width: 700px;
    height: 100%;
    /* Force full height */
}

.column-header-dash {
    flex: 0 0 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-panel);
    z-index: 10;
}

.column-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
}

.column-icon {
    font-size: 16px;
}

.column-config-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

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

.column-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Scrollbar within columns */
.column-content::-webkit-scrollbar {
    width: 6px;
}

.column-content::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

/* Hide grid-specific loading/empty in new layout or re-style them */
.feed-loading,
.feed-empty {
    padding: 40px 20px;
}

/* Responsive Dashboard */
@media (max-width: 1100px) {
    .column {
        flex: 1;
        min-width: 300px;
    }
}

@media (max-width: 768px) {
    .dashboard {
        flex-direction: column;
        overflow-y: auto;
    }

    .column {
        display: none;
        /* Hide all columns by default on mobile */
        flex: none;
        width: 100%;
        max-width: none;
        height: calc(100vh - 60px);
        /* Full height minus header */
        border-right: none;
        border-bottom: none;
    }

    .column.mobile-active {
        display: flex;
        /* Show only the active column */
    }

    .column-content {
        overflow-y: auto;
        height: 100%;
    }

    /* Hide column headers on mobile */
    .column-header-dash {
        display: none;
    }

    /* Hide gear/settings icons on mobile */
    .column-config-btn {
        display: none;
    }

    /* Center bird icon, hide RSS Reader text */
    /* Center bird icon, hide Reader text */
    /* Left align bird icon on mobile */
    .logo {
        display: flex;
        align-items: center;
        height: 60px;
        /* Match header height */
    }

    /* Hide text "Reader" on mobile, keep SVG */
    .logo {
        font-size: 0;
    }

    .logo svg {
        width: 32px;
        height: 32px;
    }
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-element);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 20px;
}

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

/* Article Card */
.article-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    /* Force full width in column */
    min-height: 80px;
    /* Prevent collapse */
    flex-shrink: 0;
    /* Important: Prevent squishing */
}

.article-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    background: var(--bg-element);
    border-color: var(--border-light);
}

.article-header {
    padding: 16px 16px 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.article-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    /* Softer square */
    background: var(--bg-panel);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.article-meta {
    flex: 1;
    overflow: hidden;
}

.article-source {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.article-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.article-title {
    padding: 0 16px 8px 16px;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-primary);
}

.article-content {
    padding: 12px 16px 16px 16px;
    /* Added top padding */
    font-size: 15px;
    font-weight: 450;
    line-height: 1.6;
    color: var(--text-secondary);
    min-height: 180px;
    /* Standardize card height */
}

.article-content.truncated {
    /* Clamp to 10 lines when truncated */
    display: -webkit-box;
    -webkit-line-clamp: 10;
    line-clamp: 10;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-content.expanded {
    display: block;
    -webkit-line-clamp: unset;
    line-clamp: unset;
}

.article-media {
    width: 100%;
    position: relative;
    padding-top: 56.25%;
    /* 16:9 Aspect Ratio Container */
    background: var(--bg-panel);
    overflow: hidden;
    border-bottom: 1px solid var(--border);
}

.article-media img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.article-card:hover .article-media img {
    transform: scale(1.03);
}

/* Quoted Tweet Styling (for Quote Tweets / QTs) */
.article-content .quoted-tweet {
    margin: 12px 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-element);
    cursor: pointer;
}

.article-content .quoted-tweet:hover {
    background: var(--bg-hover);
}

.article-content .quoted-tweet p {
    margin: 4px 0;
    font-size: 14px;
    color: var(--text-secondary);
}

/* Images within tweet content */
.article-content .content-image,
.article-content .quoted-image {
    max-width: 100%;
    border-radius: var(--radius-md);
    margin: 8px 0;
    display: block;
}

.article-content .quoted-image {
    max-height: 300px;
    object-fit: cover;
}

/* Retweet Indicator */
.article-content .rt-indicator {
    margin-bottom: 8px;
    padding: 6px 10px;
    background: var(--accent-dim);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--accent);
    font-weight: 500;
}

.article-content .rt-indicator span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Actions */
.article-actions {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.show-more-btn {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.article-link {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-element);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.article-link:hover {
    background: var(--accent);
    color: #fff;
    transform: rotate(-45deg);
    /* Dynamic icon interaction */
}

/* New Articles Button */
.new-articles-btn {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: #121212;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 13px;
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    z-index: 100;
    animation: slideDownFade 0.3s ease-out;
}

@keyframes slideDownFade {
    from {
        opacity: 0;
        transform: translate(-50%, -20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    color: var(--text-primary);
    font-size: 16px;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 20px;
}

.modal-body {
    padding: 20px;
}

.modal-body label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.modal-input {
    width: 100%;
    background: var(--bg-app);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.modal-input:focus {
    border-color: var(--accent);
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    border: none;
    font-size: 14px;
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

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

.btn-primary {
    background: var(--accent);
    color: #121212;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

/* Toasts */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

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

/* Mobile Repsonsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 60px;
        bottom: 0;
        left: 0;
        transform: translateX(-100%);
        z-index: 40;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .articles-container {
        grid-template-columns: 1fr;
        /* Single column on mobile */
    }

    .search-container {
        display: none;
        /* Hide search in header on mobile */
    }

    .search-container.mobile-visible {
        display: block;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--bg-panel);
        padding: 10px;
        margin: 0;
    }
}

.mobile-menu-btn {
    display: none;
    margin-right: 10px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    /* Match other icon brightness */
    cursor: pointer;
    opacity: 0.8;
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
    }

    .mobile-search-btn {
        display: flex !important;
    }
}

.mobile-search-btn {
    display: none;
}

/* Infinite Scroll Loading Indicators */
.loading-more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: var(--text-muted);
    font-size: 14px;
    width: 100%;
}

.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-light);
    border-top: 2px solid var(--accent);
    border-radius: 50%;
    animation: spin-small 0.8s linear infinite;
}

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

.scroll-sentinel {
    margin-top: -100px;
    height: 100px;
    width: 100%;
    pointer-events: none;
}

/* Article Engagement Stats */
.article-stats {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
    align-items: center;
}

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