/*
    ========================================
    FORUM REDESIGN STYLESHEET
    ========================================
*/

/* Override body background for cosmic background pages */
body {
    background-color: transparent !important;
    background-image: none !important;
}

:root {
    --rh-bg-primary: #101419;
    --rh-bg-secondary: #1A2028;
    --rh-bg-tertiary: #252C37;
    --rh-border-primary: #3A4454;
    --rh-border-secondary: #2A323F;
    --rh-text-primary: #EAEBEE;
    --rh-text-secondary: #A0AEC0;
    --rh-text-tertiary: #718096;
    --rh-accent-primary: #38B2AC;
    --rh-accent-secondary: #4FD1C5;
    --rh-accent-primary-glow: rgba(56, 178, 172, 0.3);
    --rh-accent-red: #E53E3E;
    --rh-font-heading: 'Bebas Neue', sans-serif;
    --rh-font-body: 'Inter', sans-serif;
}

/* --- GENERAL FORUM LAYOUT --- */
#page-wrapper {
    background-color: transparent;
}

.forum-container,
.category-container,
.thread-container {
    max-width: 75rem;
    margin: 3rem auto;
    padding: 0 1rem;
}

.forum-header h1,
.category-header h1,
.thread-header h1 {
    font-family: var(--rh-font-heading);
    color: var(--rh-text-primary);
    text-shadow: 0 0 0.9375rem var(--rh-accent-primary-glow);
}

/* --- FORUMS LIST PAGE --- */
.forum-header {
    text-align: center;
    margin-bottom: 4rem; /* Increased bottom margin */
    padding: 2rem 1rem;
}

.forum-header h1 {
    font-size: 5rem; /* Made the font larger */
    letter-spacing: 0.125rem;
    text-shadow: 0 0 0.625rem var(--rh-accent-primary-glow), 0 0 1.5625rem var(--rh-accent-primary-glow);
}

.forum-header p {
    font-size: 1.2rem;
    color: var(--rh-text-secondary);
    max-width: 37.5rem;
    margin: 0.5rem auto 0;
}

.forum-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1.5rem;
}

.forum-wrapper {
    background: linear-gradient(145deg, var(--rh-bg-secondary), var(--rh-bg-tertiary));
    border: 1px solid var(--rh-border-primary);
    border-radius: 0.75rem;
    margin-bottom: 3rem;
    overflow: hidden; /* Ensures the rows stay within the rounded corners */
}

.forum-category-title {
    font-family: var(--rh-font-heading);
    font-size: 1.8rem;
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid var(--rh-border-primary);
    margin: 0;
    color: var(--rh-accent-secondary); /* Brighter color */
    letter-spacing: 1px;
    text-shadow: 0 0 0.3125rem var(--rh-accent-primary-glow);
}

.forum-row {
    display: flex;
    align-items: center;
    padding: 1.25rem 1.75rem; /* Adjusted padding */
    border-bottom: 1px solid var(--rh-border-secondary);
    text-decoration: none;
    color: var(--rh-text-secondary);
    gap: 1.5rem; /* Adjusted gap */
    transition: all 0.2s ease-in-out; /* Transition all properties */
    position: relative;
    background: transparent;
}

.forum-row:last-child { border-bottom: none; }

.forum-row:hover {
    background-color: var(--rh-bg-tertiary);
    transform: translateY(-0.125rem); /* Lift effect */
    box-shadow: 0 0.5rem 1.25rem rgba(0,0,0,0.3);
    z-index: 1;
}

.forum-icon {
    font-size: 1.5rem; /* Slightly smaller icon */
    color: var(--rh-accent-secondary);
    flex-shrink: 0;
    width: 3rem; /* Fixed width */
    height: 3rem; /* Fixed height */
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--rh-bg-primary);
    border-radius: 0.5rem;
    border: 1px solid var(--rh-border-secondary);
}

.forum-info {
    flex-grow: 1;
}

.forum-info h2 {
    margin: 0 0 0.25rem 0;
    font-size: 1.2rem;
    color: var(--rh-text-primary);
    font-weight: 600;
    letter-spacing: 0.0313rem; /* Added letter spacing */
}

.forum-info p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--rh-text-secondary);
}

.forum-stats {
    flex-basis: 9.375rem; /* Increased basis */
    flex-shrink: 0;
    font-size: 0.9rem;
    color: var(--rh-text-secondary);
    display: flex;
    justify-content: space-around; /* Use space-around */
    text-align: center;
}

.stat-block {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--rh-text-primary);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--rh-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.0313rem;
}

.forum-last-post {
    flex-basis: 17.5rem;
    flex-shrink: 0;
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--rh-text-secondary);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.last-post-avatar-small {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 0.125rem solid var(--rh-border-secondary);
}

.last-post-info .thread-title {
    color: var(--rh-text-primary);
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s;
}

.last-post-info .thread-title:hover {
    color: var(--rh-accent-secondary);
}

.last-post-info .username {
    color: var(--rh-accent-secondary);
    font-weight: 600;
}

.last-post-info .post-time {
    color: var(--rh-text-tertiary);
    font-size: 0.9em;
}

.no-posts {
    color: var(--rh-text-tertiary);
}


/* --- CATEGORY PAGE --- */
.category-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--rh-border-primary);
}

.breadcrumb {
    font-size: 1rem;
    color: var(--rh-text-secondary);
    margin-bottom: 0.75rem;
}
.breadcrumb a {
    color: var(--rh-text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}
.breadcrumb a:hover { color: var(--rh-accent-secondary); }
.breadcrumb .breadcrumb-separator { margin: 0 0.5rem; }

.category-header h1 { font-size: 3.5rem; }
.category-header p { color: var(--rh-text-secondary); margin-top: 0.25rem; }

.thread-list-header {
    display: flex;
    justify-content: space-between;
    padding: 0 1.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--rh-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.0313rem;
    gap: 1.5rem; /* Consistent gap with rows */
}

.thread-list-header .header-main {
    flex-grow: 1;
}

.thread-list-header .header-stats {
    flex-basis: 7.5rem;
    text-align: right;
    flex-shrink: 0;
}

.thread-list-header .header-last-post {
    flex-basis: 13.75rem;
    text-align: right;
    flex-shrink: 0;
}

.thread-list-main {
    /* The container is now just for layout, not decoration */
    border: none;
    background: none;
    box-shadow: none;
}

.thread-row {
    display: flex;
    align-items: center;
    padding: 1.25rem 1.75rem;
    gap: 1.5rem;

    /* Card-like appearance */
    background: linear-gradient(145deg, var(--rh-bg-secondary), var(--rh-bg-primary));
    border: 1px solid var(--rh-border-secondary);
    border-radius: 0.625rem; /* ~10px */
    margin-bottom: 1rem;
    box-shadow: 0 0.25rem 0.75rem rgba(0,0,0,0.2);

    /* Smooth transition for hover effects */
    transition: all 0.2s ease-in-out;
}

.thread-row:last-child {
    margin-bottom: 0;
}

.thread-row:hover {
    transform: translateY(-0.25rem); /* Lift effect */
    box-shadow: 0 0.75rem 1.5rem rgba(0,0,0,0.4); /* Deeper shadow */
    border-color: var(--rh-accent-secondary);
    background-color: var(--rh-bg-tertiary); /* Maintain background change */
}
.thread-row.sticky {
    background-color: rgba(56, 178, 172, 0.08);
    border-left: 3px solid var(--rh-accent-secondary);
}
.thread-icon { font-size: 1.5rem; color: var(--rh-text-secondary); }
.thread-icon.sticky { color: var(--rh-accent-primary); }
.thread-icon.locked {
    color: var(--rh-accent-red);
    font-size: 1.75rem;
    text-shadow: 0 0 0.5rem var(--rh-accent-red);
}
.thread-info a {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--rh-text-primary);
    text-decoration: none;
    transition: color 0.2s;
}
.thread-info a:hover { color: var(--rh-accent-secondary); }

.thread-meta { font-size: 0.9rem; color: var(--rh-text-secondary); margin-top: 0.25rem; }
.thread-meta .author-link { font-weight: 600; color: var(--rh-text-primary); text-decoration: none; }
.thread-meta .author-link:hover { text-decoration: underline; }
.thread-stats { flex-basis: 7.5rem; text-align: right; color: var(--rh-text-secondary); }
.thread-stats div:first-child { color: var(--rh-text-primary); font-weight: 600; }
.thread-last-post {
    flex-basis: 13.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.last-post-info a { color: var(--rh-text-primary); }
.last-post-info span { color: var(--rh-text-secondary); font-size: 0.9em; }
.last-post-avatar {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    object-fit: cover;
    border: 0.125rem solid var(--rh-border-primary);
    flex-shrink: 0;
}


/* --- THREAD PAGE --- */
.thread-container { max-width: 75rem; } /* Wider for new layout */
.thread-header h1 { font-size: 3rem; }

.post-container {
    display: flex;
    flex-direction: row; /* New: changed to row */
    background: var(--rh-bg-secondary);
    border: 1px solid var(--rh-border-primary);
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 0.3125rem 0.9375rem rgba(0,0,0,0.2);
    overflow: hidden; /* To keep child elements within border radius */
}

.post-container.original-post {
    border-color: var(--rh-accent-primary);
    box-shadow: 0 0.5rem 1.5625rem rgba(0,0,0,0.3), 0 0 0.9375rem var(--rh-accent-primary-glow);
}

/* New: Author Sidebar */
.post-author-sidebar {
    flex: 0 0 12.5rem; /* Do not grow, do not shrink, base width 200px */
    padding: 1.5rem;
    background: var(--rh-bg-primary);
    border-right: 1px solid var(--rh-border-primary);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: inset -5px 0 5px -5px rgba(0,0,0,0.5);
}

.author-link {
    text-decoration: none;
    color: var(--rh-text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.author-link:hover .author-name {
    color: var(--rh-accent-secondary);
}

.author-avatar {
    width: 6.25rem; /* Larger avatar */
    height: 6.25rem;
    border-radius: 50%;
    object-fit: cover;
    border: 0.1875rem solid var(--rh-border-secondary);
    transition: all 0.2s; /* Changed to all */
}
.author-link:hover .author-avatar {
    border-color: var(--rh-accent-primary);
    transform: scale(1.05);
}

.author-name {
    font-weight: 800; /* Bolder */
    font-size: 1.3rem; /* Larger */
    transition: color 0.2s;
}

.author-meta {
    font-size: 0.85rem;
    color: var(--rh-text-secondary);
    margin-bottom: 1rem;
    width: 100%;
}
.author-stat {
    margin-bottom: 0.5rem;
    background-color: var(--rh-bg-secondary);
    padding: 0.5rem;
    border-radius: 0.25rem;
    border: 1px solid var(--rh-border-secondary);
}
.author-stat strong {
    color: var(--rh-text-primary);
}

.author-bio {
    font-size: 0.9rem;
    color: var(--rh-text-tertiary);
    line-height: 1.5;
    word-break: break-word; /* Prevents long words from overflowing */
    margin-top: auto; /* Pushes social links to the bottom */
}

.author-socials {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

.social-link {
    font-size: 1.25rem;
    color: var(--rh-text-tertiary);
    transition: color 0.2s ease-in-out;
}

.social-link:hover {
    color: var(--rh-accent-secondary);
}

/* New: Main Post Area */
.post-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.post-meta-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--rh-border-secondary);
    background: var(--rh-bg-tertiary);
    font-size: 0.9rem;
    color: var(--rh-text-tertiary);
}

.post-actions .quote-btn {
    background-color: var(--rh-bg-secondary);
    color: var(--rh-text-secondary);
    border: 1px solid var(--rh-border-primary);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}
.post-actions .quote-btn:hover {
    background-color: var(--rh-accent-primary);
    color: var(--rh-bg-primary);
    border-color: var(--rh-accent-secondary);
}

.post-content {
    padding: 1.5rem;
    color: var(--rh-text-secondary);
    line-height: 1.7;
    flex-grow: 1; /* Allows content to fill available space */
}
.post-content h2, .post-content h3 { color: var(--rh-text-primary); }
.post-content p { color: var(--rh-text-secondary); }
.post-content blockquote { border-left: 0.1875rem solid var(--rh-accent-primary); color: var(--rh-text-secondary); background: var(--rh-bg-primary); padding: 1rem; }
.post-content pre { background-color: var(--rh-bg-primary); border: 1px solid var(--rh-border-primary); color: var(--rh-text-secondary); }

/* Reply Box */
.reply-box {
    background: var(--rh-bg-secondary);
    border: 1px solid var(--rh-border-primary);
    padding: 1.5rem;
    border-radius: 0.5rem;
}
.reply-box h3 { color: var(--rh-accent-primary); }
#reply-editor-container { background-color: var(--rh-bg-primary); color: var(--rh-text-primary); border-radius: 0.375rem; }
.ql-toolbar {
    background: var(--rh-bg-tertiary);
    border-top-left-radius: 0.375rem;
    border-top-right-radius: 0.375rem;
    border: 1px solid var(--rh-border-primary) !important;
}
.ql-toolbar .ql-stroke { stroke: var(--rh-text-secondary); }
.ql-toolbar .ql-fill { fill: var(--rh-text-secondary); }
.ql-container {
    border-bottom-left-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
    min-height: 9.375rem;
    border: 1px solid var(--rh-border-primary) !important;
    font-family: var(--rh-font-body);
}
.ql-editor { color: var(--rh-text-primary); }
.ql-editor.ql-blank::before { color: var(--rh-text-tertiary); }

.login-prompt {
    text-align: center;
    padding: 2rem;
    background-color: var(--rh-bg-secondary);
    border-radius: 0.5rem;
    border: 1px solid var(--rh-border-primary);
    color: var(--rh-text-secondary);
}

/* --- LOADER --- */
#forum-loader {
    border: 0.25rem solid var(--rh-border-primary);
    border-top: 0.25rem solid var(--rh-accent-primary);
}

/* --- RESPONSIVE --- */
@media (max-width: 48rem) {
    .forum-stats, .forum-last-post, .thread-stats, .thread-last-post { display: none; }
    .post-container { flex-direction: column; }
    .post-author { flex-basis: auto; border-bottom: 1px solid var(--rh-border-primary); padding-bottom: 1rem; margin-bottom: 1rem; }
}

/* --- Skeleton Loader for Thread/Category View --- */
.thread-row.skeleton .skeleton-text,
.thread-row.skeleton .skeleton-icon,
.skeleton-post .skeleton-avatar,
.skeleton-post .skeleton-name,
.skeleton-post .skeleton-text {
    background: var(--rh-bg-tertiary);
    animation: skeleton-pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    border-radius: 0.375rem;
    color: transparent;
    user-select: none;
}
.thread-row.skeleton .skeleton-icon {
    width: 2rem;
    height: 2rem;
}
.thread-row.skeleton .skeleton-text {
    height: 1em;
    width: 80%;
}
.thread-row.skeleton .skeleton-text.skeleton-text-short {
    width: 40%;
}
.thread-row.skeleton .thread-info > .skeleton-text {
    height: 1.15rem; /* Match thread title size */
    margin-bottom: 0.5rem;
}
.thread-row.skeleton .thread-info > .skeleton-text.skeleton-text-short {
    height: 0.9rem; /* Match meta text size */
}
.thread-row.skeleton .thread-stats .skeleton-text {
    width: 60%;
    margin-left: auto;
}
.thread-row.skeleton .thread-last-post .skeleton-text {
    width: 90%;
}

@keyframes skeleton-pulse {
  50% {
    opacity: 0.5;
  }
}

/* --- NEW THREAD PAGE --- */
.new-thread-container {
    max-width: 50rem;
    margin: 3rem auto;
    padding: 2rem;
    background: linear-gradient(145deg, var(--rh-bg-secondary), var(--rh-bg-tertiary));
    border: 1px solid var(--rh-border-primary);
    border-radius: 0.75rem;
    box-shadow: 0 0.625rem 1.875rem rgba(0,0,0,0.2), 0 0 1.25rem var(--rh-accent-primary-glow);
}

.page-header {
    text-align: center;
    margin-bottom: 2rem;
}
.page-header h1 {
    font-family: var(--rh-font-heading);
    font-size: 3.5rem;
    color: var(--rh-text-primary);
    text-shadow: 0 0 0.9375rem var(--rh-accent-primary-glow);
}
.page-header p {
    color: var(--rh-text-secondary);
    font-size: 1.1rem;
}

.form-group {
    margin-bottom: 1.5rem;
}
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--rh-text-primary);
    font-size: 1.1rem;
}
.form-group input, .form-group select {
    width: 100%;
    background-color: var(--rh-bg-primary);
    border: 1px solid var(--rh-border-primary);
    border-radius: 0.375rem;
    padding: 0.75rem 1rem;
    color: var(--rh-text-primary);
    font-family: var(--rh-font-body);
    font-size: 1rem;
    transition: all 0.2s ease-in-out;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--rh-accent-primary);
    box-shadow: 0 0 0 0.1875rem var(--rh-accent-primary-glow);
}

.validation-message {
    font-size: 0.9rem;
    color: var(--rh-accent-red);
    margin-top: 0.5rem;
    display: none; /* Shown by JS */
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 2rem;
}

.auth-check-message {
    text-align: center;
    padding: 3rem;
    background-color: var(--rh-bg-secondary);
    border-radius: 0.5rem;
    border: 1px solid var(--rh-border-primary);
    color: var(--rh-text-secondary);
}
