/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #1c1c1c;
    background-color: #dae0e6;
}

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

/* Header styles */
.header {
    background-color: #ffffff;
    border-bottom: 1px solid #edeff1;
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

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

.logo h1 {
    font-size: 28px;
    font-weight: 700;
    margin: 0;
    color: #ff4500;
}

.nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-input {
    padding: 8px 16px;
    border: 1px solid #edeff1;
    border-radius: 4px;
    width: 300px;
    font-size: 14px;
    background-color: #f6f7f8;
}

.search-input:focus {
    outline: none;
    border-color: #0079d3;
    background-color: white;
}

.nav-buttons {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-btn {
    background: none;
    border: none;
    color: #1c1c1c;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.nav-btn:hover {
    background-color: #f6f7f8;
}

.user-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.karma-display {
    font-size: 12px;
    color: #7c7c7c;
    font-weight: 500;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #edeff1;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Main content layout */
.main {
    padding: 20px 0;
}

.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 312px;
    gap: 24px;
    align-items: start;
}

.main-content {
    background-color: #ffffff;
    border-radius: 4px;
    border: 1px solid #ccc;
    overflow: hidden;
}

/* Subreddit header */
.subreddit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #edeff1;
    background-color: #f6f7f8;
}

.subreddit-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.subreddit-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid #0079d3;
}

.subreddit-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.subreddit-name {
    font-size: 16px;
    font-weight: 600;
    color: #1c1c1c;
    margin: 0;
}

.subreddit-members {
    font-size: 12px;
    color: #7c7c7c;
    margin: 0;
}

.join-btn {
    background-color: #0079d3;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    transition: background-color 0.2s;
}

.join-btn:hover {
    background-color: #0060a8;
}

/* Post container */
.post-container {
    display: flex;
    padding: 8px;
    border-bottom: 1px solid #edeff1;
}

.post-votes {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 8px;
    margin-right: 8px;
    min-width: 40px;
}

.vote-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    border-radius: 2px;
    transition: all 0.2s;
    color: #878a8c;
}

.vote-btn:hover {
    background-color: #f6f7f8;
}

.vote-btn.upvote.active {
    color: #ff4500;
}

.vote-btn.downvote.active {
    color: #7193ff;
}

.vote-icon {
    font-size: 16px;
    font-weight: bold;
}

.vote-count {
    font-weight: 700;
    color: #1c1c1c;
    font-size: 12px;
    margin: 2px 0;
}

.post-content {
    flex: 1;
    padding: 8px;
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #7c7c7c;
}

.subreddit-link {
    color: #1c1c1c;
    font-weight: 700;
}

.username {
    color: #1c1c1c;
    font-weight: 500;
}

.user-flair {
    background-color: #0079d3;
    color: white;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 500;
}

.user-flair.moderator {
    background-color: #46d160;
}

.user-flair.op {
    background-color: #0079d3;
}

.post-separator {
    color: #7c7c7c;
}

.menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 2px;
    color: #878a8c;
    font-size: 16px;
}

.menu-btn:hover {
    background-color: #f6f7f8;
}

.post-title {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 8px;
    line-height: 1.3;
    color: #1c1c1c;
}

.post-body {
    margin-bottom: 8px;
    line-height: 1.6;
}

.post-body p {
    margin-bottom: 12px;
}

.post-body strong {
    font-weight: 600;
}

.post-footer {
    margin-top: 8px;
}

.post-stats {
    display: flex;
    align-items: center;
    gap: 8px;
}

.comment-count {
    font-size: 12px;
    color: #7c7c7c;
    font-weight: 700;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 2px;
    font-size: 12px;
    font-weight: 700;
    color: #878a8c;
    transition: background-color 0.2s;
}

.action-btn:hover {
    background-color: #f6f7f8;
}

/* Comments section */
.comments-section {
    padding: 16px;
}

.sort-options {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #edeff1;
}

.sort-label {
    font-size: 12px;
    color: #7c7c7c;
    font-weight: 500;
}

.sort-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 2px;
    font-size: 12px;
    font-weight: 700;
    color: #0079d3;
    transition: background-color 0.2s;
}

.sort-btn:hover {
    background-color: #f6f7f8;
}

.sort-btn.active {
    color: #ff4500;
}

.comment-input-section {
    margin-bottom: 16px;
}

.comment-input-container {
    border: 1px solid #edeff1;
    border-radius: 4px;
    background-color: white;
}

.comment-input {
    width: 100%;
    min-height: 80px;
    padding: 8px;
    border: none;
    resize: vertical;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
}

.comment-input:focus {
    outline: none;
}

.comment-input-actions {
    padding: 8px;
    border-top: 1px solid #edeff1;
    display: flex;
    justify-content: flex-end;
}

.comment-submit {
    background-color: #0079d3;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    transition: background-color 0.2s;
}

.comment-submit:hover {
    background-color: #0060a8;
}

/* Comments list */
.comments-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comment {
    display: flex;
    position: relative;
}

.comment[data-level="1"] {
    margin-left: 20px;
}

.comment[data-level="2"] {
    margin-left: 40px;
}

.comment-line {
    position: absolute;
    left: -10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: #edeff1;
}

.comment[data-level="1"] .comment-line:first-child {
    left: -30px;
}

.comment[data-level="2"] .comment-line:first-child {
    left: -50px;
}

.comment[data-level="2"] .comment-line:nth-child(2) {
    left: -30px;
}

.comment-votes {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 8px;
    margin-right: 8px;
    min-width: 40px;
}

.comment-content {
    flex: 1;
    padding: 4px 0;
}

.comment-header {
    margin-bottom: 4px;
}

.comment-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #7c7c7c;
}

.karma-score {
    color: #7c7c7c;
}

.comment-time {
    color: #7c7c7c;
}

.awards {
    font-size: 12px;
}

.comment-body {
    margin-bottom: 8px;
    line-height: 1.5;
    font-size: 14px;
}

.comment-body p {
    margin-bottom: 8px;
}

.comment-body ul, .comment-body ol {
    margin-left: 20px;
    margin-bottom: 8px;
}

.comment-body li {
    margin-bottom: 4px;
}

.comment-body strong {
    font-weight: 600;
}

.comment-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.reply-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 2px;
    font-size: 12px;
    font-weight: 700;
    color: #878a8c;
    transition: background-color 0.2s;
}

.reply-btn:hover {
    background-color: #f6f7f8;
}

.reply-input {
    margin-top: 8px;
    border: 1px solid #edeff1;
    border-radius: 4px;
    background-color: white;
}

.reply-textarea {
    width: 100%;
    min-height: 60px;
    padding: 8px;
    border: none;
    resize: vertical;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
}

.reply-textarea:focus {
    outline: none;
}

.reply-actions {
    padding: 8px;
    border-top: 1px solid #edeff1;
    display: flex;
    gap: 8px;
}

.reply-submit {
    background-color: #0079d3;
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    transition: background-color 0.2s;
}

.reply-submit:hover {
    background-color: #0060a8;
}

.reply-cancel {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    color: #878a8c;
    transition: background-color 0.2s;
}

.reply-cancel:hover {
    background-color: #f6f7f8;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar-section {
    background-color: #ffffff;
    border: 1px solid #ccc;
    border-radius: 4px;
    overflow: hidden;
}

.sidebar-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #7c7c7c;
    padding: 12px 12px 8px 12px;
    background-color: #f6f7f8;
    border-bottom: 1px solid #edeff1;
    margin: 0;
}

.community-info {
    padding: 12px;
}

.community-description {
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 12px;
    color: #1c1c1c;
}

.community-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.stat {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: #1c1c1c;
}

.stat-label {
    font-size: 12px;
    color: #7c7c7c;
}

.community-created {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #7c7c7c;
}

.created-label {
    font-weight: 500;
}

.rules-list {
    padding: 0 12px 12px 12px;
}

.rule-item {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #f6f7f8;
    font-size: 14px;
}

.rule-item:last-child {
    border-bottom: none;
}

.rule-number {
    font-weight: 700;
    color: #0079d3;
    min-width: 16px;
}

.rule-text {
    color: #1c1c1c;
}

.related-communities {
    padding: 0 12px 12px 12px;
}

.community-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.community-item:hover {
    background-color: #f6f7f8;
}

.community-icon {
    width: 32px;
    height: 32px;
    background-color: #0079d3;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.community-details h4 {
    font-size: 14px;
    font-weight: 500;
    color: #1c1c1c;
    margin: 0;
}

.community-members {
    font-size: 12px;
    color: #7c7c7c;
    margin: 0;
}

/* Footer */
.footer {
    background-color: #ffffff;
    border-top: 1px solid #edeff1;
    padding: 24px 0;
    margin-top: 48px;
}

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

.footer-links {
    display: flex;
    gap: 24px;
}

.footer-link {
    color: #7c7c7c;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.footer-link:hover {
    color: #1c1c1c;
}

.footer-copyright {
    font-size: 14px;
    color: #7c7c7c;
}

/* Responsive design */
@media (max-width: 1024px) {
    .content-wrapper {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .sidebar {
        order: -1;
    }
    
    .search-input {
        width: 200px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 12px;
    }
    
    .nav {
        width: 100%;
        justify-content: space-between;
    }
    
    .search-input {
        width: 150px;
    }
    
    .nav-buttons {
        gap: 8px;
    }
    
    .nav-btn {
        padding: 6px 8px;
        font-size: 12px;
    }
    
    .post-title {
        font-size: 16px;
    }
    
    .post-container {
        flex-direction: column;
    }
    
    .post-votes {
        flex-direction: row;
        justify-content: flex-start;
        margin-bottom: 8px;
        margin-right: 0;
    }
    
    .comment[data-level="1"] {
        margin-left: 16px;
    }
    
    .comment[data-level="2"] {
        margin-left: 32px;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .footer-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .search-input {
        width: 120px;
    }
    
    .post-container {
        padding: 8px;
    }
    
    .comments-section {
        padding: 12px;
    }
    
    .sidebar-section {
        margin: 0 -16px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .comment[data-level="1"] {
        margin-left: 12px;
    }
    
    .comment[data-level="2"] {
        margin-left: 24px;
    }
}

/* Animation improvements */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.reply-input {
    animation: fadeIn 0.3s ease-out;
}

.comment {
    animation: fadeIn 0.5s ease-out;
}

/* Accessibility improvements */
.vote-btn:focus,
.action-btn:focus,
.reply-btn:focus,
.nav-btn:focus,
.sort-btn:focus {
    outline: 2px solid #0079d3;
    outline-offset: 2px;
}

.search-input:focus,
.comment-input:focus,
.reply-textarea:focus {
    outline: 2px solid #0079d3;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .header,
    .sidebar,
    .footer,
    .post-votes,
    .comment-votes,
    .comment-actions,
    .post-stats,
    .sort-options,
    .comment-input-section {
        display: none;
    }
    
    .main-content {
        border: 1px solid #ccc;
    }
    
    .content-wrapper {
        grid-template-columns: 1fr;
    }
    
    .post-container {
        flex-direction: column;
    }
}