/* =========================================================================
   COMMUNITY FORUM STYLES
   Main stylesheet for QH Community (community.html, community-post.html, community-profile.html)
   ========================================================================= */

/* --- ROOT VARIABLES (Specific to Community) --- */
:root {
    --comm-primary: #0891b2; /* Teal 600 */
    --comm-primary-light: #06b6d4; /* Teal 500 */
    --comm-primary-dark: #0e7490; /* Teal 700 */
    --comm-bg-dark: #0f172a; /* Slate 900 */
    --comm-bg-card: rgba(255, 255, 255, 0.95);
    --comm-text: #1e293b; /* Slate 800 */
    --comm-text-muted: #64748b; /* Slate 500 */
    --comm-border: #e2e8f0; /* Slate 200 */
    --comm-hover: #f1f5f9; /* Slate 100 */
    --comm-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --comm-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

body.dark-mode {
    --comm-bg-dark: #020617; /* Slate 950 */
    --comm-bg-card: rgba(30, 41, 59, 0.95); /* Slate 800 */
    --comm-text: #f8fafc; /* Slate 50 */
    --comm-text-muted: #94a3b8; /* Slate 400 */
    --comm-border: #334155; /* Slate 700 */
    --comm-hover: #1e293b; /* Slate 800 */
    --comm-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --comm-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

/* ==========================================
   HERO SECTION
   ========================================== */
.comm-hero {
    background: linear-gradient(135deg, var(--comm-bg-dark) 0%, var(--comm-primary-dark) 100%);
    padding: 8rem 2rem 4rem;
    text-align: center;
    color: white;
    position: relative;
    overflow: hidden;
}

.comm-hero::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="40" stroke="rgba(255,255,255,0.03)" stroke-width="2" fill="none"/></svg>') repeat;
    background-size: 100px 100px;
    opacity: 0.5;
    z-index: 1;
}

.comm-hero-content {
    position: relative;
    z-index: 2;
    max-width: 800px;
    margin: 0 auto;
    animation: fadeUp 0.6s ease forwards;
}

.comm-hero-badge {
    display: inline-block;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 1px;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(5px);
}

.comm-hero h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.comm-hero p {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 2rem;
}

.comm-search-bar {
    display: flex;
    max-width: 600px;
    margin: 0 auto;
    background: var(--comm-bg-card);
    border-radius: 30px;
    padding: 0.5rem;
    box-shadow: var(--comm-shadow-hover);
    transition: transform 0.3s ease;
}

.comm-search-bar:focus-within {
    transform: scale(1.02);
}

.comm-search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.5rem 1.5rem;
    font-size: 1rem;
    color: var(--comm-text);
    outline: none;
}

.comm-search-bar button {
    background: var(--comm-primary);
    color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s ease;
}

.comm-search-bar button:hover {
    background: var(--comm-primary-light);
}

/* ==========================================
   LAYOUT & GRID
   ========================================== */
.comm-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 2rem;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2.5rem;
}

/* ==========================================
   SIDEBAR WIDGETS
   ========================================== */
.comm-sidebar {
    position: sticky;
    top: 100px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: fit-content;
}

.comm-widget {
    background: var(--comm-bg-card);
    border: 1px solid var(--comm-border);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--comm-shadow);
    backdrop-filter: blur(10px);
}

.comm-widget-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--comm-text);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-create-post {
    width: 100%;
    background: var(--comm-primary);
    color: white;
    border: none;
    padding: 0.8rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 1rem;
}

.btn-create-post:hover {
    background: var(--comm-primary-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(8, 145, 178, 0.3);
}

/* Categories List */
.comm-category-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.comm-category-item {
    display: flex;
    align-items: center;
    padding: 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
    color: var(--comm-text-muted);
    font-weight: 500;
}

.comm-category-item:hover, .comm-category-item.active {
    background: var(--comm-hover);
    color: var(--comm-text);
}

.comm-category-item.active {
    border-left: 3px solid var(--comm-primary);
}

.comm-category-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    color: white;
    font-size: 0.9rem;
}

.comm-category-count {
    margin-left: auto;
    background: var(--comm-hover);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    color: var(--comm-text-muted);
}

/* User Mini Card */
.comm-user-minicard {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.comm-user-minicard img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--comm-border);
}

.comm-user-info h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--comm-text);
}

.comm-user-info p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--comm-text-muted);
}

/* ==========================================
   FEED & POST CARDS
   ========================================== */
.comm-feed {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.comm-feed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.comm-feed-header h2 {
    font-size: 1.5rem;
    color: var(--comm-text);
    margin: 0;
}

.comm-sort-select {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--comm-border);
    background: var(--comm-bg-card);
    color: var(--comm-text);
    outline: none;
    cursor: pointer;
}

.comm-post-card {
    background: var(--comm-bg-card);
    border: 1px solid var(--comm-border);
    border-radius: 16px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    box-shadow: var(--comm-shadow);
    display: block;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
}

.comm-post-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--comm-shadow-hover);
    border-color: var(--comm-primary-light);
}

.comm-post-header {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

.comm-post-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 1rem;
    border: 1px solid var(--comm-border);
}

.comm-post-meta {
    flex: 1;
}

.comm-post-author {
    font-weight: 600;
    color: var(--comm-text);
    margin: 0 0 0.2rem 0;
    font-size: 0.95rem;
}

.comm-post-date {
    font-size: 0.8rem;
    color: var(--comm-text-muted);
    margin: 0;
}

.comm-post-badge {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    padding: 0.3rem 0.8rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

.comm-post-pinned {
    position: absolute;
    top: 0;
    right: 0;
    background: #f59e0b;
    color: white;
    padding: 0.2rem 1rem;
    font-size: 0.7rem;
    font-weight: bold;
    border-bottom-left-radius: 12px;
}

.comm-post-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--comm-text);
    margin-bottom: 0.8rem;
    line-height: 1.4;
}

.comm-post-excerpt {
    color: var(--comm-text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.comm-post-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.comm-post-footer {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    border-top: 1px solid var(--comm-border);
    padding-top: 1rem;
    color: var(--comm-text-muted);
    font-size: 0.9rem;
}

.comm-post-stat {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.comm-post-stat.liked i {
    color: #ef4444;
}

/* ==========================================
   POST DETAIL VIEW
   ========================================== */
.comm-detail-container {
    max-width: 1000px;
    margin: 2rem auto;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2.5rem;
}

.comm-article {
    background: var(--comm-bg-card);
    border: 1px solid var(--comm-border);
    border-radius: 16px;
    padding: 3rem;
    box-shadow: var(--comm-shadow);
}

.comm-article-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--comm-text);
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.comm-article-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--comm-border);
    margin-bottom: 2rem;
}

.comm-article-author {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: inherit;
}

.comm-article-author img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.comm-article-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--comm-text);
}

.comm-article-content p {
    margin-bottom: 1.5rem;
}

.comm-article-content img {
    max-width: 100%;
    border-radius: 8px;
    margin: 1.5rem 0;
}

/* Paywall overlay */
.comm-paywall {
    position: relative;
}

.comm-paywall::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 150px;
    background: linear-gradient(to bottom, transparent, var(--comm-bg-card));
    pointer-events: none;
}

.comm-paywall-box {
    margin-top: 2rem;
    padding: 2rem;
    background: var(--comm-hover);
    border: 1px dashed var(--comm-border);
    border-radius: 12px;
    text-align: center;
}

.comm-paywall-box a {
    display: inline-block;
    background: var(--comm-primary);
    color: white;
    padding: 0.8rem 2rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    margin-top: 1rem;
}

/* Action Bar */
.comm-action-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--comm-border);
}

.comm-btn-action {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--comm-hover);
    border: 1px solid var(--comm-border);
    color: var(--comm-text);
    padding: 0.6rem 1.2rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.comm-btn-action:hover {
    background: var(--comm-border);
}

.comm-btn-like.liked {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #ef4444;
}
.comm-btn-like.liked i {
    animation: likePopScale 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ==========================================
   COMMENTS SECTION
   ========================================== */
.comm-comments-section {
    margin-top: 3rem;
}

.comm-comments-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--comm-text);
}

.comm-comment-input {
    background: var(--comm-bg-card);
    border: 1px solid var(--comm-border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 2rem;
}

.comm-comment-input textarea {
    width: 100%;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-family: inherit;
    font-size: 1rem;
    color: var(--comm-text);
    min-height: 80px;
}

.comm-comment-input .actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.comm-btn-primary {
    background: var(--comm-primary);
    color: white;
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.comm-comment-thread {
    margin-bottom: 1.5rem;
}

.comm-comment {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.comm-comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.comm-comment-body {
    background: var(--comm-hover);
    padding: 1rem;
    border-radius: 12px;
    flex: 1;
}

.comm-comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

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

.comm-comment-date {
    font-size: 0.8rem;
    color: var(--comm-text-muted);
}

.comm-comment-text {
    color: var(--comm-text);
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.comm-comment-actions {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
}

.comm-comment-actions button {
    background: none;
    border: none;
    color: var(--comm-text-muted);
    cursor: pointer;
    font-weight: 500;
    padding: 0;
}

.comm-comment-actions button:hover {
    color: var(--comm-primary);
}

.comm-replies {
    margin-left: 3rem;
    border-left: 2px solid var(--comm-border);
    padding-left: 1rem;
}

/* ==========================================
   PROFILE SECTION
   ========================================== */
.comm-profile-header {
    background: var(--comm-bg-card);
    border: 1px solid var(--comm-border);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 2rem;
    box-shadow: var(--comm-shadow);
}

.comm-profile-cover {
    height: 250px;
    background: linear-gradient(135deg, #cbd5e1, #94a3b8);
    position: relative;
    background-size: cover;
    background-position: center;
}

.comm-profile-edit-cover {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.comm-profile-info {
    padding: 0 2rem 2rem;
    position: relative;
    display: flex;
    flex-direction: column;
}

.comm-profile-avatar-wrap {
    margin-top: -50px;
    margin-bottom: 1rem;
    position: relative;
    width: fit-content;
}

.comm-profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid var(--comm-bg-card);
    object-fit: cover;
    background: white;
}

.comm-profile-name {
    font-size: 2rem;
    font-weight: 800;
    color: var(--comm-text);
    margin: 0;
}

.comm-profile-specialty {
    color: var(--comm-primary);
    font-weight: 600;
    margin: 0.2rem 0 1rem;
}

.comm-profile-bio {
    color: var(--comm-text);
    max-width: 800px;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.comm-profile-stats {
    display: flex;
    gap: 2rem;
    border-top: 1px solid var(--comm-border);
    padding-top: 1.5rem;
}

.comm-stat-box {
    text-align: center;
}

.comm-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--comm-text);
    display: block;
}

.comm-stat-label {
    font-size: 0.85rem;
    color: var(--comm-text-muted);
}

/* ==========================================
   MODALS (Create Post / Edit Profile)
   ========================================== */
.comm-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.comm-modal-overlay.active {
    display: flex;
}

.comm-modal {
    background: var(--comm-bg-card);
    width: 100%;
    max-width: 700px;
    border-radius: 16px;
    padding: 2rem;
    max-height: 90vh;
    overflow-y: auto;
    animation: fadeUp 0.3s ease;
}

.comm-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.comm-modal-header h3 {
    margin: 0;
    color: var(--comm-text);
}

.comm-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--comm-text-muted);
    cursor: pointer;
}

.comm-form-group {
    margin-bottom: 1.5rem;
}

.comm-form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--comm-text);
}

.comm-input, .comm-select {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--comm-border);
    border-radius: 8px;
    background: var(--comm-bg-card);
    color: var(--comm-text);
    font-family: inherit;
    font-size: 1rem;
}

/* Simple WYSIWYG Editor */
.comm-editor-toolbar {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--comm-hover);
    border: 1px solid var(--comm-border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
}

.comm-editor-toolbar button {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--comm-text);
    border-radius: 4px;
}

.comm-editor-toolbar button:hover {
    background: var(--comm-border);
}

.comm-editor-content {
    border: 1px solid var(--comm-border);
    border-radius: 0 0 8px 8px;
    min-height: 200px;
    padding: 1rem;
    outline: none;
    background: var(--comm-bg-card);
    color: var(--comm-text);
}

/* ==========================================
   ANIMATIONS & RESPONSIVE
   ========================================== */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes likePopScale {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); }
    100% { transform: scale(1); }
}

@media (max-width: 992px) {
    .comm-container {
        grid-template-columns: 1fr;
    }
    .comm-sidebar {
        display: none; /* Can be toggled with a button in mobile */
    }
    .comm-detail-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .comm-hero {
        padding: 6rem 1rem 3rem;
    }
    .comm-hero h1 {
        font-size: 2rem;
    }
    .comm-article {
        padding: 1.5rem;
    }
    .comm-profile-header {
        text-align: center;
    }
    .comm-profile-avatar-wrap {
        margin: -60px auto 1rem;
    }
    .comm-profile-stats {
        justify-content: center;
    }
}
