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

/* Add background to html element */
html {
    background-color: var(--bg-secondary, #f8f9fa); /* Default to light theme background if variables not loaded yet */
    min-height: 100%;
    width: 100%;
    overflow-x: hidden;
}

html.dark-theme {
    background-color: var(--bg-secondary, #222222); /* Match the new darker background */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    transition: color 0.3s ease, background-color 0.3s ease; /* Don't transition all properties */
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    width: 100%;
    overflow-x: hidden;
}

/* Theme Variables */
.light-theme {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-post: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --border-color: #e9ecef;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --accent: #ff4500;
    --accent-hover: #ff5722;
    --success: #28a745;
    --timer-bg: #f0f0f0;
    --timer-progress: #ffc107;
}

.dark-theme {
    --bg-primary: #1a1a1a;
    --bg-secondary: #222222; /* Darker background for main content area */
    --bg-post: #2a2a2a;     /* Lighter shade for posts to create contrast */
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-muted: #888888;
    --border-color: #404040;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --accent: #ff4500;
    --accent-hover: #ff5722;
    --success: #28a745;
    --timer-bg: #404040;
    --timer-progress: #ffc107;
}

#app {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: color 0.3s ease, background-color 0.3s ease; /* More specific transitions */
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

/* Shared container styles for consistent layout */
.header-container, .tabs-container {
    width: 100%;
    display: flex;
    justify-content: center;
    box-sizing: border-box;
    position: relative;
}

/* Full width visual elements that span entire viewport */
.header-container::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    right: 0;
    height: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1;
    pointer-events: none;
}

.tabs-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background-color: var(--border-color);
    width: 100%;
    z-index: 1;
}

/* Header Styles */
.header {
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    top: 0;
    z-index: 100;
    gap: 1rem;
    flex-wrap: nowrap;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    position: relative;
}

.logo-container {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    order: 1;
}

.logo {
    width: 40px;
    height: 40px;
    transition: transform 0.3s ease;
}

.logo:hover {
    transform: scale(1.05);
}

.app-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.02em;
}

.input-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 250px;
    max-width: 350px;
    order: 2;
    position: relative;
}

.subreddit-input {
    padding: 0.75rem 1rem;
    padding-right: 35px; /* Make space for the favorite button */
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    width: 350px;
    min-width: 0;
    max-width: 100%;
    transition: all 0.3s ease;
}

.subreddit-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 69, 0, 0.1);
}

.shockwave {
    animation: shockwave 0.1s ease-out;
}

@keyframes shockwave {
    0% {
        width: 4px;
        height: 4px;
        opacity: 1;
        border-width: 2px;
    }
    100% {
        width: 100px;
        height: 100px;
        opacity: 0;
        border-width: 1px;
    }
}

.refresh-timer {
    display: flex;
    align-items: center;
    justify-content: center;
    order: 3;
    margin-left: auto;
}

.timer-circle {
    transform: rotate(-90deg);
}

.timer-bg {
    fill: none;
    stroke: var(--timer-bg);
    stroke-width: 2;
}

.timer-progress {
    fill: none;
    stroke: var(--timer-progress);
    stroke-width: 2;
    stroke-dasharray: 62.83; /* 2π * 10 (radius) */
    stroke-dashoffset: 62.83;
    transition: stroke-dashoffset 1s linear;
}

.theme-toggle {
    background: none;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    order: 4;
}

.theme-toggle:hover {
    border-color: var(--accent);
    transform: scale(1.05);
    color: var(--text-primary);
}

.theme-icon {
    transition: all 0.3s ease;
}

/* Initial message styles */
.initial-message {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.initial-message-content h2 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.initial-message-content p {
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.initial-message-content .example {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
}

/* Error message styles */
.error-message {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.error-message-content h2 {
    color: var(--accent);
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.error-message-content p {
    margin-bottom: 1rem;
    font-size: 1rem;
    line-height: 1.6;
}

.error-message-content .error-suggestion {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.error-message-content .error-suggestion:last-of-type {
    margin-bottom: 2rem;
}

.error-message-content a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

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

.retry-button {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.retry-button:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 69, 0, 0.3);
}

/* Tabs Styles */
.tabs {
    padding: 0 2rem;
    display: flex;
    gap: 0.5rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    position: relative;
}

.tab-button {
    background: none;
    border: none;
    padding: 0.9rem 1.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.tab-button:hover {
    color: var(--text-primary);
    background-color: var(--bg-secondary);
}

.tab-button.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Tab icon and text styles */
.tab-icon {
    display: none;
    margin: auto;
    color: inherit;
    fill: currentColor;
    transition: transform 0.3s ease;
    width: 28px;
    height: 28px;
}

.tab-button[data-sort="hot"] .tab-icon {
    color: #ff4500; /* Reddit orange/red for flame */
    fill: #ff4500;
}

.tab-button[data-sort="new"] .tab-icon {
    color: #00cec9; /* Teal for new star */
    fill: #00cec9;
}

.tab-button[data-sort="top"] .tab-icon {
    color: #4285f4; /* Blue for top lines */
    fill: #4285f4;
}

.tab-button[data-sort="rising"] .tab-icon {
    color: #9b59b6; /* Purple for rising arrow */
    fill: #9b59b6;
}

.tab-button[data-sort="controversial"] .tab-icon {
    color: #96c93d; /* Green for controversial symbol */
    fill: #96c93d;
}

.tab-button:hover .tab-icon {
    transform: scale(1.2);
}

/* Override specific colors only when button is not active */
.tab-button:not(.active) .tab-icon {
    opacity: 0.7;
}

.tab-button.active .tab-icon {
    opacity: 1;
}

.tab-text {
    display: inline;
}

/* Medium screen tabs - show both icon and text */
@media (min-width: 401px) and (max-width: 700px) {
    .tab-button {
        padding: 0.75rem 0.5rem;
    }
    
    .tab-text {
        display: block;
        font-size: 0.7rem;
        margin-top: 0.25rem;
    }
}

/* Mobile tabs styling */
@media (max-width: 700px) {
    .tabs {
        padding: 0;
        display: flex;
        flex-wrap: nowrap;
        justify-content: space-between;
    }
    
    .tab-button {
        flex: 1;
        padding: 0.6rem 0.25rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        border-bottom-width: 2px;
    }
    
    .tab-icon {
        display: block;
        height: 28px;
        width: 28px;
    }
    
    .tab-text {
        display: none; /* Hide text on small screens */
    }
    
    /* Active tab indicator */
    .tab-button.active {
        background-color: var(--bg-secondary);
    }
}

/* Very small screens - ensure icons are spaced well */
@media (max-width: 400px) {
    .tab-button {
        padding: 0.75rem 0.15rem;
    }
    
    .tab-icon {
        width: 24px;
        height: 24px;
    }
}

/* Full width background colors for containers */
.header-container {
    background-color: var(--bg-primary);
}

.tabs-container {
    background-color: var(--bg-primary);
}

/* Posts Container */
.posts-container {
    width: 100%;
    max-width: 100%; /* Default full width for small screens */
    min-width: 300px; /* Ensure readable width on narrow screens */
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
    min-height: 0;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Media queries for responsive container sizing */
/* Between 0px and 700px, all containers are full width (default) */

/* From 700px to 1500px, posts container should match header/tabs (full width) */
@media (min-width: 700px) and (max-width: 1499px) {
    /* No max-width limits - posts will take full width like header/tabs */
}

/* At 1500px+, both header/tabs and posts use the same width limitations */
@media (min-width: 1500px) {
    .header, .tabs, .posts-container {
        max-width: 1500px; /* Fixed at 1500px for large screens */
    }
}

/* When viewport is wide enough that 67% is wider than 1500px */
@media (min-width: 2240px) {
    .header, .tabs, .posts-container {
        max-width: 67%; /* All containers use 67% width on very large screens */
    }
}

/* Special styling for dark mode */
.dark-theme .post {
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
}

/* Post Styles */
.post {
    background-color: var(--bg-post);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    transition: opacity 0.1s ease, box-shadow 0.2s ease, transform 0.2s ease;
    opacity: 0; /* Start hidden to prevent flash */
    transform: translateY(0);
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.post.visible {
    opacity: 1; /* Make visible when ready */
}

.post:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.post.hiding {
    animation: hidePost 0.2s ease-out forwards;
}

@keyframes hidePost {
    0% {
        opacity: 1;
        transform: translateY(0);
        max-height: 300px;
        margin-bottom: 1rem;
        padding: 1rem;
    }
    50% {
        opacity: 0;
        transform: translateY(-10px);
    }
    100% {
        opacity: 0;
        transform: translateY(-20px);
        max-height: 0;
        margin-bottom: 0;
        padding: 0;
        overflow: hidden;
        border-width: 0;
    }
}

.post.entering {
    animation: slideIn 0.5s ease-out;
}

.post.exiting {
    animation: slideOut 0.5s ease-out forwards;
}

.post.moving-up {
    animation: moveUp 0.5s ease-out;
}

.post.moving-down {
    animation: moveDown 0.5s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
        max-height: 0;
        padding: 0 1rem;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 300px;
        padding: 1rem;
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateY(0);
        max-height: 300px;
        padding: 1rem;
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
        max-height: 0;
        padding: 0 1rem;
    }
}

@keyframes moveUp {
    from {
        transform: translateY(20px);
    }
    to {
        transform: translateY(0);
    }
}

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

.post-voting-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    width: 50px;
}

.hide-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.2rem 0.4rem;
    cursor: pointer;
    font-size: 0.7rem;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

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

.post-votes {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.upvote-icon {
    color: var(--accent); /* Static color for upvote icon - no hover color change */
    margin-right: 1px;
    display: inline-block;
}

.post-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.post-subreddit {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    margin-bottom: 0.25rem;
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.post-subreddit:hover {
    text-decoration: underline;
}

/* In the header row, subreddit should grow to fill available space */
.post-header-row .post-subreddit {
    flex: 1;
    margin-bottom: 0;
}

.post-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    display: block;
    margin-bottom: 0.25rem;
    line-height: 1.3;
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}

.post-title:hover {
    color: var(--accent);
}

.post-metadata {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    overflow: hidden;
    white-space: nowrap;
    width: 100%;
    min-width: 0; /* Ensure flexbox can shrink children properly */
}

.post-meta-separator {
    color: var(--text-muted);
    margin: 0 0.25rem;
    font-size: 0.8rem;
}

.post-description-link {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    display: inline-block;
}

.post-description-link:hover {
    color: var(--accent);
}

/* Ensure selftext links have the same style as external links */
.selftext-link {
    display: inline-block;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%; /* Ensure selftext uses full available width */
}

/* Hover effect for selftext posts - both title and description highlight together */
.selftext-post:hover .post-title,
.selftext-post:hover .selftext-link {
    color: var(--accent);
}

/* External posts - title and description highlight independently */
.external-post .post-title:hover {
    color: var(--accent);
}

.external-post .external-link:hover {
    color: var(--accent);
}

/* Add a subtle indicator for links */
.post-description-link {
    position: relative;
    padding-right: 1rem;
}

.external-link::after {
    content: "↗";
    font-size: 0.7rem;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.7;
}

.post-time {
    color: var(--text-muted);
    font-size: 0.8rem;
    flex-shrink: 0;
    white-space: nowrap;
    margin-right: 0.5rem;
}

/* Loading and Error States */
.loading, .error {
    text-align: center;
    padding: 3rem;
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

/* Footer */
.footer {
    margin-top: 4rem;
    padding: 2rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    width: 100%;
}

.footer p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.footer-separator {
    margin: 0 8px;
    color: var(--text-muted);
}

/* Notification */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 4px;
    color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    animation: slide-in 0.3s ease-out forwards;
}

.success-notification {
    background-color: var(--success);
}

.info-notification {
    background-color: #3498db;
}

.notification.fading-out {
    animation: slide-out 0.5s ease-in forwards;
}

@keyframes slide-in {
    0% { transform: translateX(100%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

@keyframes slide-out {
    0% { transform: translateX(0); opacity: 1; }
    100% { transform: translateX(100%); opacity: 0; }
}

/* Input container and favorites */
.input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.favorite-button {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    pointer-events: auto;
}

.favorite-button:hover {
    color: var(--accent);
    transform: translateY(-50%) scale(1.1);
}

.favorite-button.active {
    color: var(--accent);
}

.favorite-button.favorite-animation {
    animation: favorite-pulse 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes favorite-pulse {
    0% { transform: translateY(-50%) scale(1); }
    50% { transform: translateY(-50%) scale(1.5); }
    100% { transform: translateY(-50%) scale(1); }
}

.favorites-dropdown-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    order: 3; /* Position between timer and theme toggle on large screens */
}

.favorites-dropdown-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    width: 30px;
    height: 30px;
}

.favorites-dropdown-toggle:hover {
    color: var(--accent);
    transform: scale(1.1);
}

.favorites-dropdown-toggle:active {
    transform: scale(0.95);
}

.favorites-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    right: auto;
    left: 50%; /* Center relative to button */
    transform: translateX(-90%); /* Shift left to appear on left side of button */
    background-color: var(--bg-post);
    border-radius: 4px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    width: 240px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    padding: 10px;
}

.favorites-dropdown h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: var(--text-primary);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.favorites-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 5px;
}

.favorite-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.favorite-item:hover {
    background-color: var(--bg-secondary);
}

.favorite-item-text {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
    font-size: 14px;
}

.favorite-item-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    margin-left: 5px;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.favorite-item-remove:hover {
    opacity: 1;
    color: var(--accent);
}

.favorites-empty {
    color: var(--text-secondary);
    text-align: center;
    padding: 10px;
    font-size: 14px;
}

.hidden {
    display: none !important;
    opacity: 0 !important; /* Ensure hidden posts are invisible */
}

/* Media queries for responsive design */
@media (max-width: 700px) {
    /* Header layout for small screens */
    .header {
        justify-content: space-between;
        padding: 0.75rem;
        gap: 0.5rem;
        max-width: 100%;
        /* With logo removed, give more space to input */
    }
    
    /* Hide logo on small screens to save space */
    .logo-container {
        display: none;
    }
    
    .refresh-timer {
        order: 1;
    }
    
    .input-container {
        flex: 1;
        max-width: none;
        min-width: 0;
        order: 2;
        margin-right: 0.25rem;
    }
    
    .subreddit-input {
        width: 100%;
        min-width: 0;
        padding-right: 35px; /* Make space for the favorite button */
    }
    
    /* Favorites dropdown after input row */
    .favorites-dropdown-container {
        order: 3;
        margin-left: auto;
    }
    
    /* Theme toggle last */
    .theme-toggle {
        order: 4;
    }
    
    /* Dropdown width for small screens */
    .favorites-dropdown {
        width: 200px;
    }
    
    /* Post styling for small screens */
    .post {
        padding: 0.75rem;
        gap: 0.25rem;
    }
    
    .post-title {
        font-size: 0.95rem;
    }
    
    .post-description-link {
        font-size: 0.8rem;
    }
    
    .posts-container {
        padding: 1rem;
        width: 100%;
        max-width: 100%; /* Override the 67% on small screens */
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    /* Show the header row on small screens */
    .post-header-row {
        display: flex;
        align-items: center;
        width: 100%;
        gap: 0.75rem;
        margin-bottom: 0.5rem;
        flex-wrap: nowrap;
    }
    
    /* Show header row and hide voting section on small screens */
    .post-header-row {
        display: flex;
    }
    
    .post-voting-section {
        display: none;
    }
    
    /* Style the elements in the header row */
    .post-header-row .hide-btn {
        font-size: 0.7rem;
        padding: 0.15rem 0.3rem;
        margin: 0;
    }
    
    .post-header-row .post-votes {
        font-size: 0.75rem;
        min-width: auto;
        display: flex;
        align-items: center;
    }
    
    .post-header-row .post-subreddit {
        margin-bottom: 0;
        flex-grow: 1;
        text-overflow: ellipsis;
        overflow: hidden;
    }
    
    .post-content {
        flex: 1 1 100%;
        width: 100%;
    }
    
    /* Hide the subreddit in the content div since it's in the header row */
    .post-content .post-subreddit {
        display: none;
    }
}

/* Post Header Row - visible only on small screens */
.post-header-row {
    display: none; /* Hidden by default on large screens */
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
}

/* Post voting section - visible by default on large screens */
.post-voting-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    width: 50px;
}

.post-header-row .hide-btn,
.post-header-row .post-votes,
.post-header-row .post-subreddit {
    display: inline-flex; /* Ensure these elements are visible */
    align-items: center;
}

.post-header-row {
    background-color: var(--bg-secondary);
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
}

/* Small screen layout */
@media (max-width: 700px) {
    /* Show mobile content wrapper, hide desktop content */
    .mobile-content-wrapper {
        display: flex !important;
        flex-direction: column;
    }
    
    /* Show header row at the top of mobile content */
    .post-header-row {
        display: flex !important;
        align-items: center;
        justify-content: flex-start;
        width: 100%;
        margin-bottom: 0.75rem;
        gap: 0.5rem;
    }
    
    /* Hide duplicate desktop content */
    .post-voting-section, 
    .post-content {
        display: none !important;
    }
}

.mobile-content-wrapper {
    display: none; /* Hidden by default on large screens */
    flex-direction: column;
    width: 100%;
}

/* Handle duplicate content in the DOM */
.post-header-row .post-title,
.post-header-row .post-metadata {
    display: none; /* These are duplicates and should be hidden */
}

.mobile-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    display: block;
    margin-bottom: 0.25rem;
    line-height: 1.3;
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}

.mobile-title:hover {
    color: var(--accent);
}

.mobile-metadata {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    overflow: hidden;
    white-space: nowrap;
    width: 100%;
}

/* Adjust padding for different screen sizes */
@media (max-width: 700px) {
    .header-container, .tabs-container {
        padding: 0;
    }
    
    .header, .tabs {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* No padding constraints for medium screens - allow full width */
@media (min-width: 700px) and (max-width: 1500px) {
    .header-container, .tabs-container {
        padding: 0;
    }
}

@media (min-width: 1500px) {
    .header-container, .tabs-container {
        padding: 0;
    }
}

/* Enhanced dark mode post styling */
.dark-theme .post {
    border: 1px solid var(--border-color);
    transition: all 0.2s ease, border-color 0.3s ease;
}

.dark-theme .post:hover {
    border-color: #505050;
}

/* Subtle header background in dark theme for better layering */
.dark-theme .post-header-row {
    background-color: rgba(0, 0, 0, 0.1);
}

/* Slightly more visible selection for tab buttons in dark mode */
.dark-theme .tab-button.active {
    background-color: rgba(255, 69, 0, 0.05);
}

/* Dark mode shadow adjustment */
.dark-theme .header-container::after {
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}


