/* =====================================================
   FEED COMPONENTS (Posts, Comments, Interactions)
   WCAG 2.1 AA Compliant
   ===================================================== */

/* =====================================================
   CREATE POST (AskBox)
   ===================================================== */

.create-post {
    background: var(--bg-white);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0px 4px 20px 0px rgba(209, 209, 209, 0.15);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.post-creator {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-color);
    color: var(--primary-color-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

/* User avatar photo styling (AskBox) */
.user-avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Title toggle container (AskBox) */
.title-toggle {
    margin-bottom: 0.75rem;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
    user-select: none;
}

/* Hide the actual checkbox */
.toggle-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Toggle switch track */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: #767676; /* WCAG 2.1: 4.5:1 contrast ratio against white */
    border-radius: 24px;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

/* Toggle switch thumb (circle) */
.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Checked state - track color */
.toggle-label input:checked + .toggle-switch {
    background-color: var(--community-primary, #6366f1);
}

/* Checked state - thumb position */
.toggle-label input:checked + .toggle-switch::after {
    transform: translateX(20px);
}

/* Focus state for accessibility */
.toggle-label input:focus + .toggle-switch {
    outline: 2px solid var(--community-primary, #6366f1);
    outline-offset: 2px;
}

/* Disabled state */
.toggle-label input:disabled + .toggle-switch {
    opacity: 0.5;
    cursor: not-allowed;
}

.toggle-label:has(input:disabled) {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .toggle-switch,
    .toggle-switch::after {
        transition: none;
    }
}

.post-input-wrapper {
    flex: 1;
}

.post-input {
    width: 100%;
    background: var(--bg-gray-light);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: inherit;
    resize: none;
    min-height: 60px;
}

.post-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(106, 74, 158, 0.05);
}

/* Post mode title input */
.post-title-input {
    width: 100%;
    background: var(--bg-gray-light);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.post-title-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(106, 74, 158, 0.05);
}

.post-title-input::placeholder {
    font-weight: 400;
    color: var(--text-secondary);
}

/* Post body textarea (in post mode) */
.post-body-input {
    min-height: 80px;
}

.create-post.disabled .post-title-input {
    cursor: not-allowed;
}

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

.post-options {
    display: flex;
    gap: 1rem;
}

.post-option {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    background: none;
    border: none;
    font-family: inherit;
    line-height: 1.5;
}

.post-option:hover {
    background: var(--glass-white);
    color: var(--text-primary);
}

.post-option.active {
    background: rgba(106, 74, 158, 0.1);
    color: var(--primary-color-safe);
}

.post-button {
    background: var(--primary-color);
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 2rem;
    color: var(--primary-color-text);
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s;
    min-height: 44px;
}

.post-button:hover {
    transform: translateY(-2px);
}

/* Disabled state for unauthenticated users */
.create-post.disabled {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(30%);
}

.create-post.disabled .post-input,
.create-post.disabled .post-button,
.create-post.disabled .post-option {
    cursor: not-allowed;
}

/* Sign-in prompt for unauthenticated users in AskBox */
.askbox-signin-prompt {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem;
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    opacity: 0.7;
    filter: grayscale(20%);
}

.askbox-signin-prompt i {
    color: var(--text-secondary);
    font-size: 1.25rem;
    opacity: 0.5;
}

.askbox-signin-prompt .prompt-text {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    opacity: 0.6;
}

.askbox-signin-prompt .signin-link {
    color: var(--community-primary);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0.5rem 0.75rem;
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    border-radius: 4px;
    font-size: 0.9375rem;
    opacity: 1.4;
    filter: none;
}

.askbox-signin-prompt .signin-link:hover {
    text-decoration: underline;
    background: rgba(0, 0, 0, 0.03);
}

.askbox-signin-prompt .signin-link:focus {
    outline: 3px solid var(--community-primary);
    outline-offset: 2px;
}

/* =====================================================
   POSTS (ImagePost, PlainPost)
   ===================================================== */

.post {
    background: var(--bg-white);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    overflow: hidden;
    transition: all 0.3s;
    box-shadow: 0px 4px 20px 0px rgba(209, 209, 209, 0.15);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.post:hover {
    box-shadow: 0 8px 32px rgba(106, 74, 158, 0.15);
}

.post-header {
    padding: 1.5rem 1.5rem 1.5rem 1.5rem;
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.post-author {
    display: flex;
    gap: 1rem;
}

.author-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-color);
    color: var(--primary-color-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    overflow: hidden;
}

.author-avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.author-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.author-name {
    font-weight: 600;
    margin-bottom: 0.125rem;
}

.author-details {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.author-badge {
    background: var(--accent-bg);
    color: var(--accent-text);
    padding: 0.125rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.625rem;
    font-weight: 600;
}

.post-content {
    padding: 0 1.5rem 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Remove bottom margin from last element in post content */
.post-content > :last-child {
    margin-bottom: 0 !important;
}

/* Also handle nested elements inside post-text (from markdown) */
.post-text > :last-child {
    margin-bottom: 0 !important;
}

.post-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.75rem 0;
    line-height: 1.4;
}

.post-text {
    line-height: 1.7;
    margin: 0;
    font-size: var(--font-size-base);
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.post-media {
    margin: 0 -1.5rem 0;
    background: var(--darker-bg);
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    position: relative;
    overflow: hidden;
    aspect-ratio: 16 / 9;
}

/* Clickable post media (articles, videos) */
.post-media-clickable {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.post-media-clickable:hover {
    opacity: 0.9;
}

.post-media-clickable:focus {
    outline: 2px solid var(--community-primary);
    outline-offset: 2px;
}

.post-media img,
.post-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    max-width: 100%;
}

.media-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    background: linear-gradient(to top, rgba(15, 23, 42, 0.9), transparent);
    color: white;
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tag {
    color: var(--accent-text);
    font-size: var(--font-size-sm);
    cursor: pointer;
    line-height: 1.5;
    text-decoration: none; /* Reset link default */
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
}

.tag:hover,
.tag:focus {
    text-decoration: underline;
}

.tag:focus {
    outline: 2px solid var(--focus-color, #005fcc);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Post Labels - Colored pills below author */
.post-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin: 0.25rem 0 0.75rem 0; /* Less space to author, more space to title */
    padding: 0 1.5rem; /* Match post-content horizontal padding */
}

.post-label {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
    border: 1px solid transparent;
    text-decoration: none !important;
    cursor: pointer;
    transition: opacity 0.2s ease;
    min-height: 28px;
    line-height: 1.4;
}

.post-label:hover,
.post-label:focus {
    opacity: 0.8;
    text-decoration: none !important;
}

.post-label:focus {
    outline: 2px solid var(--focus-color, #005fcc);
    outline-offset: 2px;
}

/* Ensure touch targets are accessible (44x44px clickable area) */
.post-label {
    position: relative;
}

.post-label::before {
    content: '';
    position: absolute;
    top: -8px;
    right: -4px;
    bottom: -8px;
    left: -4px;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .post-label {
        transition: none;
    }
}

/* New post fade-in animation */
@keyframes feedItemFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.feed-item-wrapper {
    /* Wrapper for feed items to support animation */
}

.feed-item-new {
    animation: feedItemFadeIn 0.3s ease-out forwards;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .feed-item-new {
        animation: none;
    }
}

/* Article post read button */
.article-action {
    padding: 1rem 0 2rem 0;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.article-read-btn {
    background: var(--primary-color);
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 2rem;
    color: var(--primary-color-text);
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s;
    min-height: 44px;
}

.article-read-btn:hover {
    transform: translateY(-2px);
}

.article-read-btn:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* =====================================================
   LIKE/COMMENT/SHARE
   ===================================================== */

/* Stats row removed - comment count now shown in button */
.post-stats {
    display: none;
}

.post-stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    justify-content: center;
}

.post-stat-item i {
    font-size: 1rem;
    color: var(--text-secondary);
}

.reactions-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.reaction-icons {
    display: flex;
}

.reaction-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    margin-left: -4px;
    border: 2px solid var(--bg-white);
    background: rgba(106, 74, 158, 0.15);
}

.reaction-icon:first-child {
    margin-left: 0;
}

.post-actions {
    display: flex;
    justify-content: space-around;
    padding: 0.5rem;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-secondary);
    background: none;
    border: none;
    font-size: var(--font-size-sm);
    line-height: 1.5;
}

.action-btn:hover {
    background: var(--glass-white);
    color: var(--text-primary);
}

.action-btn.liked {
    color: var(--accent-color);
}

/* =====================================================
   RIGHT SIDEBAR (Connections, Events)
   ===================================================== */

.right-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-card {
    background: var(--bg-white);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0px 4px 20px 0px rgba(209, 209, 209, 0.15);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--glass-border);
}

.card-title {
    font-weight: 600;
    font-size: 1.5rem;
    margin: 0;
}

.view-all {
    color: var(--accent-text);
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: none;
}

/* Connection items */
.member-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
}

.member-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: var(--primary-color-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    overflow: hidden;
    flex-shrink: 0;
}

.member-avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.member-info {
    flex: 1;
}

.member-name {
    font-weight: 500;
    font-size: var(--font-size-sm);
    margin-bottom: var(--spacing-xs);
    line-height: 1.4;
}

.member-role {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    line-height: 1.4;
}

.follow-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    background: var(--accent-color);
    color: var(--accent-color-text);
    border-radius: 1rem;
    font-size: var(--font-size-xs);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    line-height: 1.4;
    min-height: 44px;
}

.follow-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

/* Event items */
.event-item {
    padding: 1rem 0;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

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

.event-logo {
    width: 56px;
    height: 56px;
    border-radius: 0.5rem;
    object-fit: cover;
    flex-shrink: 0;
}

.event-content {
    flex: 1;
}

.event-date {
    background: var(--primary-color);
    color: var(--primary-color-text);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.625rem;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 0.5rem;
}

.event-title {
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    font-size: var(--font-size-sm);
    line-height: 1.4;
}

.event-details {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    line-height: 1.4;
}

.event-register-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    background: var(--accent-color);
    color: var(--accent-color-text);
    border-radius: 1rem;
    font-size: var(--font-size-xs);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
    line-height: 1.4;
    min-height: 44px;
}

.event-register-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

/* =====================================================
   EVENT DISPLAY - Enhanced event cards for right sidebar
   ===================================================== */

.events-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    width: 100%;
}

.event-display-card {
    background: var(--bg-white);
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.event-display-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.event-header-image {
    position: relative;
    width: 100%;
    height: 150px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
}

.event-header-image > img:first-child {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.event-header-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
}

.event-logo-centered {
    width: 64px;
    height: 64px;
    border-radius: 0.5rem;
    object-fit: cover;
    background: var(--bg-white);
}

.event-logo-overlay {
    position: absolute;
    top: var(--spacing-sm);
    left: var(--spacing-sm);
    width: 72px;
    height: 72px;
    border-radius: 0.5rem;
    border: 2px solid var(--bg-white);
    object-fit: cover;
    background: var(--bg-white);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.event-display-content {
    padding: var(--spacing-md);
}

.event-display-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
    line-height: 1.4;
}

.event-display-description {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    line-height: 1.5;
}

.event-display-date {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.event-display-date i {
    color: var(--primary-color);
}

.event-online-pill {
    display: inline-block;
    background: var(--primary-color);
    color: var(--primary-color-text);
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: var(--font-size-xs);
    font-weight: 500;
    margin-bottom: var(--spacing-sm);
}

.event-display-venue {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-xs);
    line-height: 1.4;
}

.event-display-venue i {
    margin-top: 3px;
    color: var(--accent-color);
    flex-shrink: 0;
}

.event-display-card .event-register-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
    font-size: calc(var(--font-size-xs) * 1.25);
}

.event-display-card .event-register-btn:hover,
.event-display-card .event-register-btn:focus,
.event-display-card .event-register-btn:visited,
.event-display-card .event-register-btn:active {
    text-decoration: none !important;
}

/* Run an Event button */
.run-event-btn {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--spacing-sm);
    width: 100%;
    padding: var(--spacing-md);
    background: var(--bg-gray-light);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    font-size: calc(var(--font-size-sm) * 1.2);
    font-weight: 600;
    text-decoration: none !important;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px;
}

.run-event-btn:hover {
    text-decoration: none !important;
    color: var(--text-primary);
    box-shadow: 0 8px 32px rgba(106, 74, 158, 0.15);
}

.run-event-btn:focus,
.run-event-btn:visited,
.run-event-btn:active {
    text-decoration: none !important;
    color: var(--text-primary);
}

/* Only add top margin when events list exists above */
.events-list + .run-event-btn {
    margin-top: var(--spacing-md);
}

.run-event-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.runevents-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

/* =====================================================
   FEED
   ===================================================== */

.feed {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* =====================================================
   HAMBURGER BUTTON
   ===================================================== */

.hamburger-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.hamburger-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--primary-color);
    margin: 3px 0;
    transition: all 0.3s ease;
}

.hamburger-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.hamburger-btn.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Hide hamburger on desktop */
@media (min-width: 1250px) {
    .hamburger-btn {
        display: none;
    }
}

/* =====================================================
   LOGIN BUTTON
   Styled as regular button (similar to Ask/Post type buttons)
   ===================================================== */

.login-button {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--primary-color);
    font-size: var(--font-size-sm);
    background: var(--bg-white);
    border: 1px solid var(--glass-border);
    font-family: inherit;
    line-height: 1.5;
    min-height: 44px;
}

.login-button:hover {
    background: rgba(106, 74, 158, 0.1);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.login-button:focus-visible {
    outline: 3px solid var(--focus-color, var(--primary-color));
    outline-offset: 2px;
}

.login-button i {
    color: var(--primary-color);
}

.login-button span {
    color: var(--primary-color);
    font-weight: 500;
}

/* =====================================================
   USER PROFILE DROPDOWN
   Dropdown menu for authenticated user actions
   ===================================================== */

.profile-dropdown-container {
    position: relative;
}

.profile-dropdown-trigger {
    cursor: pointer;
}

.profile-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--bg-white);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 160px;
    z-index: 200;
    overflow: hidden;
}

.profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    background: transparent;
    border: none;
    text-decoration: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    font-size: var(--font-size-sm);
    font-family: inherit;
    min-height: 44px;
}

.profile-dropdown-item:hover,
.profile-dropdown-item:focus {
    background: rgba(106, 74, 158, 0.1);
    text-decoration: none;
    color: var(--primary-color);
}

.profile-dropdown-item:hover i,
.profile-dropdown-item:focus i {
    color: var(--primary-color);
}

.profile-dropdown-item:focus-visible {
    outline: 2px solid var(--focus-color, var(--primary-color));
    outline-offset: -2px;
}

.profile-dropdown-item i {
    font-size: 1rem;
    color: var(--text-secondary);
    transition: color 0.2s;
}

/* =====================================================
   CONFIRMATION MODAL
   Reusable modal for confirmation dialogs
   WCAG: Focus trap, high contrast, keyboard accessible
   ===================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.confirmation-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: var(--bg-white);
    border-radius: 1.5rem;
    box-shadow: 0 16px 56px rgba(0, 0, 0, 0.25);
    z-index: 9999;
    max-width: 460px;
    width: calc(100% - 2rem);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
}

.confirmation-modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.modal-content {
    padding: 3rem 2.5rem;
    text-align: center;
}

.modal-logo {
    margin-bottom: 2rem;
}

.modal-logo img {
    max-width: 140px;
    max-height: 70px;
    object-fit: contain;
}

.modal-icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 1rem 0;
}

.modal-message {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 0 0 2rem 0;
    line-height: 1.7;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 0.5rem;
}

.modal-btn {
    padding: 0.875rem 2rem;
    border-radius: 2rem;
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 48px;
    min-width: 120px;
    border: none;
    font-family: inherit;
}

.modal-btn-cancel {
    background: var(--bg-gray-light);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.modal-btn-cancel:hover {
    background: var(--glass-white);
}

.modal-btn-confirm {
    background: var(--primary-color);
    color: var(--primary-color-text);
}

.modal-btn-confirm:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.modal-btn:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .confirmation-modal,
    .modal-overlay {
        transition: none;
    }
}


/* =====================================================
   SIDEBAR ERROR (ErrorBoundary fallback)
   Graceful error display when sidebar components fail
   ===================================================== */

.sidebar-error {
    background: var(--bg-white);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    box-shadow: 0px 4px 20px 0px rgba(209, 209, 209, 0.15);
}

.sidebar-error i {
    font-size: 2rem;
    color: var(--bs-warning, #ffc107);
    display: block;
    margin-bottom: 0.75rem;
}

.sidebar-error p {
    margin: 0 0 1rem 0;
    font-size: var(--font-size-sm);
    line-height: 1.5;
}

.sidebar-error .btn {
    min-height: 36px;
}

/* =====================================================
   COMMENTS SECTION
   Comment display and input components
   WCAG 2.1 AA Compliant
   ===================================================== */

/* Comment section container */
.comment-section {
    background: var(--bg-gray-light);
    border-top: 1px solid var(--glass-border);
    padding: 1rem 1.5rem;
}

/* Post actions (comment button) in article page - add vertical spacing */
.article-page .post-actions {
    margin-top: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

/* Comment section in article page - extend to edges */
.article-page .comment-section {
    margin-left: -2rem;
    margin-right: -2rem;
    margin-bottom: -2rem;
    padding: 1rem 2rem;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
}

/* Loading state */
.comment-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.comment-loading i {
    margin-right: 0.5rem;
}

/* Empty state */
.comment-empty {
    text-align: center;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    padding: 0.5rem 0;
    margin: 0;
}

/* Comment list */
.comment-list {
    margin-bottom: 1rem;
}

/* Single comment item */
.comment-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--glass-border);
}

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

/* New comment animation */
.comment-new {
    animation: commentFadeIn 0.3s ease-out forwards;
}

@keyframes commentFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .comment-new {
        animation: none;
    }
}

/* Comment avatar */
.comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    color: var(--primary-color-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    flex-shrink: 0;
    overflow: hidden;
}

.comment-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Comment body */
.comment-body {
    flex: 1;
    min-width: 0;
}

.comment-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
    flex-wrap: wrap;
}

.comment-author {
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
}

.comment-time {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.comment-content {
    font-size: var(--font-size-sm);
    line-height: 1.6;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.comment-content p {
    margin: 0;
}

/* Comment input container */
.comment-input-container {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding-top: 0.5rem;
}

/* Disabled state for unauthenticated users */
.comment-input-container.disabled {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(30%);
}

.comment-input-container.disabled .comment-textarea,
.comment-input-container.disabled .comment-submit-btn {
    cursor: not-allowed;
}

/* Sign-in prompt for unauthenticated users (replaces disabled input) */
.comment-signin-prompt {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-white);
    border-radius: 8px;
    border: 1px solid var(--border-light);
    margin-top: 0.5rem;
    opacity: 0.7;
    filter: grayscale(20%);
}

.comment-signin-prompt i {
    color: var(--text-secondary);
    font-size: 1rem;
    opacity: 0.5;
}

.comment-signin-prompt .prompt-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
    opacity: 0.6;
}

.comment-signin-prompt .signin-link {
    color: var(--community-primary);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0.5rem 0.75rem;
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    border-radius: 4px;
    font-size: 0.875rem;
    /* Make sign-in button stand out from the grayed-out prompt */
    opacity: 1.4; /* Counteract parent opacity */
    filter: none;
}

.comment-signin-prompt .signin-link:hover {
    text-decoration: underline;
    background: rgba(0, 0, 0, 0.03);
}

.comment-signin-prompt .signin-link:focus {
    outline: 3px solid var(--community-primary);
    outline-offset: 2px;
}

.comment-input-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    color: var(--primary-color-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    flex-shrink: 0;
    overflow: hidden;
}

.comment-input-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.comment-input-wrapper {
    flex: 1;
    min-width: 0;
}

.comment-textarea {
    width: 100%;
    background: var(--bg-white);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 0.625rem 1rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--font-size-sm);
    resize: none;
    min-height: 40px;
    line-height: 1.5;
}

.comment-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-white);
}

.comment-textarea:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.comment-textarea.error {
    border-color: var(--error, #dc3545);
}

.comment-error {
    display: block;
    color: var(--error, #dc3545);
    font-size: var(--font-size-xs);
    margin-top: 0.25rem;
}

.comment-submit-btn {
    background: var(--primary-color);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    color: var(--primary-color-text);
    font-weight: 600;
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: transform 0.3s, opacity 0.3s;
    min-height: 40px;
    min-width: 64px;
}

.comment-submit-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.comment-submit-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.comment-submit-btn:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Visually hidden class for accessibility */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Active state for comment button */
.action-btn.active {
    background: rgba(106, 74, 158, 0.1);
    color: var(--primary-color);
}

/* =====================================================
   SHOW ALL COMMENTS DIVIDER
   Centered divider with text for loading more comments
   WCAG 2.1 AA Compliant - 44px touch target, focus visible
   ===================================================== */

.show-all-comments-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: 100%;
    padding: 0.75rem 0;
    margin: 0.5rem 0;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    transition: color 0.2s ease;
    min-height: 44px; /* WCAG 2.1 AA touch target */
}

.show-all-comments-divider:hover {
    color: var(--community-primary, var(--primary-color));
}

.show-all-comments-divider:focus-visible {
    outline: 2px solid var(--community-primary, var(--primary-color));
    outline-offset: 2px;
    border-radius: 4px;
}

.divider-line {
    flex: 1;
    height: 1px;
    background: var(--glass-border, #e5e7eb);
    max-width: 80px;
}

.divider-text {
    white-space: nowrap;
    font-weight: 500;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .show-all-comments-divider {
        transition: none;
    }
}

