/* ================================================================
   DISCUSSIONS PAGE – Premium Design System
   Palette: Slate / Emerald / White
   Typography: Inter + Plus Jakarta Sans
   Grid: 8pt
   ================================================================ */

:root {
    --ds-bg: #f8fafb;
    --ds-surface: #ffffff;
    --ds-surface-hover: #f1f5f9;
    --ds-border: #e2e8f0;
    --ds-border-soft: #f1f5f9;
    --ds-text-primary: #0f172a;
    --ds-text-secondary: #475569;
    --ds-text-muted: #94a3b8;
    --ds-primary: #10b981;
    --ds-primary-dark: #059669;
    --ds-primary-soft: rgba(16, 185, 129, 0.08);
    --ds-primary-ring: rgba(16, 185, 129, 0.2);
    --ds-accent: #6366f1;
    --ds-accent-soft: rgba(99, 102, 241, 0.08);
    --ds-danger: #ef4444;
    --ds-warning: #f59e0b;
    --ds-radius-sm: 10px;
    --ds-radius-md: 16px;
    --ds-radius-lg: 24px;
    --ds-radius-xl: 32px;
    --ds-shadow-sm: 0 1px 3px rgba(15,23,42,0.04);
    --ds-shadow-md: 0 4px 16px rgba(15,23,42,0.06);
    --ds-shadow-lg: 0 12px 40px rgba(15,23,42,0.08);
    --ds-shadow-xl: 0 20px 60px rgba(15,23,42,0.1);
    --ds-transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Hero Section ─────────────────────────────── */
.forum-hero {
    background: linear-gradient(160deg, #0f172a 0%, #1e293b 50%, #064e3b 100%);
    padding: 88px 24px 72px;
    text-align: center;
    color: white;
    border-radius: 0 0 var(--ds-radius-xl) var(--ds-radius-xl);
    margin-bottom: -48px;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.forum-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 600px 400px at 20% 80%, rgba(16,185,129,0.15) 0%, transparent 70%),
        radial-gradient(ellipse 500px 500px at 80% 20%, rgba(99,102,241,0.1) 0%, transparent 70%);
    pointer-events: none;
}

.forum-hero::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(16,185,129,0.3), transparent);
}

.forum-hero .container {
    position: relative;
    z-index: 1;
}

.forum-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(16,185,129,0.15);
    border: 1px solid rgba(16,185,129,0.25);
    color: #6ee7b7;
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 16px;
}

.forum-title {
    font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 12px;
    letter-spacing: -0.5px;
    line-height: 1.2;
    background: linear-gradient(135deg, #ffffff 0%, #d1fae5 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.forum-subtitle {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    max-width: 480px;
    margin: 0 auto 28px;
    line-height: 1.7;
    font-weight: 400;
}

.forum-hero-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.forum-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.forum-stat {
    text-align: center;
}

.forum-stat-value {
    display: block;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    color: #ffffff;
}

.forum-stat-label {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* ── Create Topic Button ─────────────────────── */
.btn-create-topic {
    background: var(--ds-primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 14px;
    font-weight: 700;
    font-size: 0.88rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(16,185,129,0.3);
    transition: all var(--ds-transition);
    font-family: 'Inter', sans-serif;
}

.btn-create-topic:hover {
    background: var(--ds-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(16,185,129,0.4);
}

.btn-create-topic:active {
    transform: translateY(0) scale(0.98);
}

/* ── Forum Container ─────────────────────────── */
.forum-container {
    position: relative;
    z-index: 2;
    padding-bottom: 100px;
    max-width: 720px;
    margin: 0 auto;
}

/* ── Search Bar ──────────────────────────────── */
.forum-search-bar {
    position: relative;
    margin-top: 64px;
    margin-bottom: 24px;
}

.forum-search-bar i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ds-text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.forum-search-input {
    width: 100%;
    padding: 14px 16px 14px 44px;
    border: 1.5px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface);
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    color: var(--ds-text-primary);
    transition: all var(--ds-transition);
    box-shadow: var(--ds-shadow-sm);
}

.forum-search-input::placeholder {
    color: var(--ds-text-muted);
}

.forum-search-input:focus {
    outline: none;
    border-color: var(--ds-primary);
    box-shadow: 0 0 0 4px var(--ds-primary-ring), var(--ds-shadow-md);
}

/* ── Discussion Feed ─────────────────────────── */
.discussions-feed {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Thread Card ─────────────────────────────── */
.thread-card {
    background: var(--ds-surface);
    border-radius: var(--ds-radius-lg);
    padding: 20px 24px;
    border: 1.5px solid var(--ds-border-soft);
    box-shadow: var(--ds-shadow-sm);
    cursor: pointer;
    transition: all var(--ds-transition);
    animation: cardSlideIn 0.4s ease backwards;
}

.thread-card:nth-child(1) { animation-delay: 0.05s; }
.thread-card:nth-child(2) { animation-delay: 0.1s; }
.thread-card:nth-child(3) { animation-delay: 0.15s; }
.thread-card:nth-child(4) { animation-delay: 0.2s; }
.thread-card:nth-child(5) { animation-delay: 0.25s; }

@keyframes cardSlideIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.thread-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--ds-shadow-lg);
    border-color: var(--ds-primary-ring);
}

.thread-card:active {
    transform: scale(0.99);
}

/* ── Thread Meta ─────────────────────────────── */
.thread-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

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

.thread-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--ds-primary-soft), var(--ds-accent-soft));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--ds-primary-dark);
    flex-shrink: 0;
}

.thread-author {
    font-weight: 700;
    color: var(--ds-text-primary);
    font-size: 0.85rem;
}

.author-badge {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.author-badge.admin {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.author-badge.member {
    background: var(--ds-primary-soft);
    color: var(--ds-primary-dark);
    border: 1px solid var(--ds-primary-ring);
}

.thread-time {
    font-size: 0.75rem;
    color: var(--ds-text-muted);
    font-weight: 500;
    white-space: nowrap;
}

/* ── Thread Content ──────────────────────────── */
.thread-category-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--ds-accent-soft);
    color: var(--ds-accent);
    margin-bottom: 8px;
    letter-spacing: 0.3px;
}

.thread-title {
    font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--ds-text-primary);
    margin-bottom: 6px;
    line-height: 1.35;
    letter-spacing: -0.2px;
}

.thread-snippet {
    font-size: 0.88rem;
    color: var(--ds-text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 16px;
}

.thread-footer {
    display: flex;
    gap: 20px;
    font-size: 0.78rem;
    color: var(--ds-text-muted);
    font-weight: 600;
    border-top: 1px solid var(--ds-border-soft);
    padding-top: 12px;
}

.thread-footer span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.thread-footer i {
    font-size: 0.85rem;
}

/* ── Detail View ─────────────────────────────── */
.btn-back-thread {
    background: var(--ds-surface);
    border: 1.5px solid var(--ds-border);
    color: var(--ds-text-secondary);
    padding: 10px 18px;
    border-radius: var(--ds-radius-sm);
    font-weight: 700;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin: 56px 0 20px;
    transition: all var(--ds-transition);
    font-family: 'Inter', sans-serif;
}

.btn-back-thread:hover {
    background: var(--ds-surface-hover);
    transform: translateX(-4px);
    box-shadow: var(--ds-shadow-sm);
}

.thread-head {
    background: var(--ds-surface);
    border-radius: var(--ds-radius-lg);
    padding: 28px;
    border: 1.5px solid var(--ds-border-soft);
    box-shadow: var(--ds-shadow-md);
    margin-bottom: 32px;
}

.thread-title-full {
    font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--ds-text-primary);
    margin: 12px 0 16px;
    line-height: 1.3;
    letter-spacing: -0.3px;
}

.thread-full-content {
    font-size: 0.95rem;
    color: var(--ds-text-secondary);
    line-height: 1.8;
    white-space: pre-wrap;
    margin-bottom: 20px;
}

.thread-stats {
    font-size: 0.8rem;
    color: var(--ds-text-muted);
    display: flex;
    gap: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--ds-border-soft);
}

.thread-stats span {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── Replies Section ─────────────────────────── */
.replies-section {
    padding-left: 0;
    border-left: none;
}

.replies-title {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--ds-text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.replies-title::before {
    content: '';
    width: 4px;
    height: 20px;
    background: var(--ds-primary);
    border-radius: 4px;
}

.replies-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reply-card {
    background: var(--ds-surface);
    border-radius: var(--ds-radius-md);
    padding: 18px 20px;
    border: 1.5px solid var(--ds-border-soft);
    box-shadow: var(--ds-shadow-sm);
    transition: border-color var(--ds-transition);
}

.reply-card:hover {
    border-color: var(--ds-border);
}

.reply-content {
    margin-top: 10px;
    font-size: 0.92rem;
    color: var(--ds-text-secondary);
    line-height: 1.7;
    white-space: pre-wrap;
}

.no-replies {
    padding: 40px 24px;
    text-align: center;
    color: var(--ds-text-muted);
    background: var(--ds-surface-hover);
    border-radius: var(--ds-radius-md);
    font-size: 0.9rem;
    border: 1.5px dashed var(--ds-border);
}

/* ── Reply Form ──────────────────────────────── */
.reply-form {
    margin-top: 28px;
    background: var(--ds-surface);
    border-radius: var(--ds-radius-lg);
    padding: 20px;
    border: 1.5px solid var(--ds-primary-ring);
    box-shadow: 0 8px 24px rgba(16,185,129,0.06);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reply-form-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--ds-text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.reply-textarea {
    width: 100%;
    border: 1.5px solid var(--ds-border);
    background: var(--ds-bg);
    border-radius: var(--ds-radius-sm);
    padding: 14px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 100px;
    color: var(--ds-text-primary);
    transition: all var(--ds-transition);
    box-sizing: border-box;
}

.reply-textarea::placeholder {
    color: var(--ds-text-muted);
}

.reply-textarea:focus {
    outline: none;
    border-color: var(--ds-primary);
    background: var(--ds-surface);
    box-shadow: 0 0 0 4px var(--ds-primary-ring);
}

.reply-login-prompt {
    margin-top: 24px;
    padding: 20px;
    text-align: center;
    background: var(--ds-surface-hover);
    border-radius: var(--ds-radius-md);
    border: 1.5px dashed var(--ds-border);
    color: var(--ds-text-secondary);
    font-size: 0.9rem;
}

.reply-login-prompt a {
    color: var(--ds-primary-dark);
    font-weight: 700;
    text-decoration: none;
}

/* ── Submit Button ───────────────────────────── */
.btn-submit {
    background: var(--ds-primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--ds-radius-sm);
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    align-self: flex-end;
    transition: all var(--ds-transition);
    font-family: 'Inter', sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-submit:hover {
    background: var(--ds-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(16,185,129,0.25);
}

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

/* ── Empty / Error States ────────────────────── */
.empty-placeholder, .error-placeholder {
    padding: 64px 32px;
    text-align: center;
    color: var(--ds-text-muted);
    background: var(--ds-surface);
    border-radius: var(--ds-radius-lg);
    border: 1.5px dashed var(--ds-border);
}

.empty-placeholder i, .error-placeholder i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.15;
    display: block;
}

.empty-placeholder p, .error-placeholder p {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ds-text-secondary);
    margin-bottom: 6px;
}

.empty-placeholder span {
    font-size: 0.85rem;
    color: var(--ds-text-muted);
}

/* ── Modal ───────────────────────────────────── */
.topic-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.topic-modal-overlay[hidden] {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.topic-modal {
    background: var(--ds-surface);
    border-radius: var(--ds-radius-xl) var(--ds-radius-xl) 0 0;
    padding: 28px 24px calc(28px + env(safe-area-inset-bottom, 0px));
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--ds-shadow-xl);
    animation: slideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@media (min-width: 640px) {
    .topic-modal-overlay {
        align-items: center;
    }
    .topic-modal {
        border-radius: var(--ds-radius-xl);
        max-height: 70vh;
    }
}

.topic-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.topic-modal-header h3 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--ds-text-primary);
}

.btn-close-modal {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1.5px solid var(--ds-border);
    background: var(--ds-surface-hover);
    color: var(--ds-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all var(--ds-transition);
}

.btn-close-modal:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}

.topic-modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.topic-input, .topic-textarea {
    width: 100%;
    border: 1.5px solid var(--ds-border);
    background: var(--ds-bg);
    border-radius: var(--ds-radius-sm);
    padding: 14px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    color: var(--ds-text-primary);
    transition: all var(--ds-transition);
    box-sizing: border-box;
}

.topic-input::placeholder, .topic-textarea::placeholder {
    color: var(--ds-text-muted);
}

.topic-input:focus, .topic-textarea:focus {
    outline: none;
    border-color: var(--ds-primary);
    background: var(--ds-surface);
    box-shadow: 0 0 0 4px var(--ds-primary-ring);
}

.topic-textarea {
    resize: vertical;
    min-height: 140px;
}

.topic-char-count {
    font-size: 0.72rem;
    color: var(--ds-text-muted);
    text-align: right;
    margin-top: -8px;
}

/* ── Skeleton Loaders ────────────────────────── */
.skeleton-card {
    height: 140px;
    background: linear-gradient(90deg, #f1f5f9 25%, #f8fafc 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.6s ease-in-out infinite;
    border-radius: var(--ds-radius-lg);
    margin-bottom: 12px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 480px) {
    .forum-hero {
        padding: 76px 16px 56px;
    }

    .forum-title {
        font-size: 1.6rem;
    }

    .forum-subtitle {
        font-size: 0.82rem;
    }

    .forum-stats {
        gap: 20px;
    }

    .forum-stat-value {
        font-size: 1.25rem;
    }

    .thread-card {
        padding: 16px 18px;
        border-radius: var(--ds-radius-md);
    }

    .thread-title {
        font-size: 1rem;
    }

    .thread-head {
        padding: 20px;
        border-radius: var(--ds-radius-md);
    }

    .thread-title-full {
        font-size: 1.25rem;
    }

    .reply-form {
        padding: 16px;
    }
}
