/* Forum Styles */
/* Import Sarabun font for Thai and Latin support */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@100;200;300;400;500;600;700;800&display=swap');

:root {
    --primary-color: #22C55E;
    /* emerald-500 */
    --secondary-color: #6B7280;
    --success-color: #10B981;
    --danger-color: #EF4444;
    --warning-color: #F59E0B;
    --info-color: #06B6D4;
    --light-bg: #F9FAFB;
    --dark-bg: #1F2937;
    --card-bg: #FFFFFF;
    --border-color: #E5E7EB;
    --text-color: #111827;
    --text-muted: #6B7280;
}

/* Inputs */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 .2rem rgba(59, 130, 246, .15);
}

.search-bar .btn {
    white-space: nowrap;
}

body {
    background-color: var(--light-bg);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    font-family: 'Sarabun', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    line-height: 1.6;
}

/* Dark Mode */
body.dark-mode {
    --light-bg: #111827;
    --dark-bg: #1F2937;
    --card-bg: #1F2937;
    --border-color: #374151;
    --text-color: #F9FAFB;
    --text-muted: #D1D5DB;
    /* brighten muted text for better contrast */
}

body.dark-mode .navbar-dark {
    background-color: #0F172A !important;
}

body.dark-mode .category-card,
body.dark-mode .thread-card,
body.dark-mode .post-card,
body.dark-mode .stat-card {
    background-color: var(--card-bg);
    border-color: var(--border-color);
}

body.dark-mode .form-control,
body.dark-mode .form-select {
    background-color: #374151;
    border-color: #4B5563;
    color: #F9FAFB;
}

body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus {
    background-color: #4B5563;
    border-color: var(--primary-color);
    color: #F9FAFB;
}

/* Search Bar */
.search-bar {
    background: var(--card-bg);
    padding: 1.75rem;
    margin-bottom: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.search-bar input {
    border-radius: 8px;
}

/* Readable placeholder text */
input::placeholder,
textarea::placeholder {
    color: #6B7280;
    /* gray-600 */
    opacity: 1;
    /* make sure it's visible */
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
    color: #E5E7EB;
    /* gray-200 for contrast on dark bg */
    opacity: 1;
}

/* Keep search input and button on the same line */
.search-bar .input-group {
    display: flex;
    flex-wrap: nowrap;
    /* prevent button from dropping below */
}

.search-bar .input-group>.form-control {
    flex: 1 1 auto;
    /* allow input to take remaining width */
    min-width: 0;
    /* prevent overflow causing wrap */
}

/* Make input and button join seamlessly on desktop */
@media (min-width: 768px) {
    .search-bar #search-query.form-control {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
    }

    .search-bar button.btn {
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
    }
}

/* Forum Stats */
.forum-stats {
    margin-bottom: 2.25rem;
    /* extra breathing room below stats */
}

.forum-categories {
    margin-top: .75rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.75rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* Ensure vertical spacing between stat cards on wrap */
.forum-stats .row {
    row-gap: 1rem;
}

.stat-card h3 {
    margin: 0.5rem 0;
    font-weight: 700;
    font-size: 2rem;
}

.stat-card p {
    margin: 0;
    color: var(--text-muted);
}

/* Category Card */
.category-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s ease;
    margin-bottom: 1.75rem;
}

.category-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.category-header {
    padding: 2rem;
    background: var(--card-bg);
    color: var(--text-color);
    border-left: 4px solid var(--primary-color);
    border-bottom: 1px solid var(--border-color);
}

.category-header h2 {
    margin: 0 0 .25rem 0;
    font-size: 1.5rem;
    font-weight: 700;
    /* stronger heading for clarity */
}

.category-header h2 a {
    color: inherit;
    text-decoration: none;
}

.category-header h2 a:hover {
    text-decoration: underline;
}

.category-icon {
    font-size: 1.8rem;
    margin-right: 0.5rem;
}

.category-header p {
    margin: 0.5rem 0 0;
    opacity: 0.9;
}

/* Dark mode: make descriptions clearer */
body.dark-mode .category-header p {
    opacity: 1;
    color: var(--text-muted);
}

.category-body {
    padding: 2rem;
}

/* Layout similar to screenshot */
.category-row {
    display: grid;
    grid-template-columns: 56px 1fr 320px;
    gap: 1.5rem;
    align-items: start;
}

.category-icon-badge {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(34, 197, 94, .12);
    color: var(--primary-color);
}

.subs-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem 1.5rem;
}

.subs-columns a {
    color: #16A34A;
    /* green-600 */
    text-decoration: none;
    font-weight: 600;
}

.subs-columns a:hover {
    text-decoration: underline;
}

.latest-thread-card {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-top: .25rem;
}

.avatar-bubble {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    display: grid;
    place-items: center;
    background: #0f172a;
    color: #A7F3D0;
    font-weight: 700;
}

.latest-thread-card a {
    color: #16A34A;
    text-decoration: none;
}

.latest-thread-card a:hover {
    text-decoration: underline;
}

/* old .subcategories/.subcategory-item/.category-stats/.latest-thread styles removed as unused */

/* old .latest-thread rule removed */

/* Thread Card */
.thread-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.75rem;
    margin-bottom: 1.25rem;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.thread-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transform: translateX(5px);
}

.thread-card.pinned {
    border-left: 4px solid var(--warning-color);
}

.thread-card.locked {
    opacity: 0.8;
}

.thread-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.thread-title a {
    color: var(--text-color);
    text-decoration: none;
}

.thread-title a:hover {
    color: var(--primary-color);
}

.thread-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.95rem;
    /* slightly larger for readability */
    color: var(--text-muted);
    flex-wrap: wrap;
}

/* Ensure muted text is readable in dark mode */
body.dark-mode .text-muted {
    color: var(--text-muted) !important;
    opacity: 1 !important;
}

/* Ensure small text remains readable in dark mode */
body.dark-mode small,
body.dark-mode .small {
    color: var(--text-muted) !important;
    opacity: 1 !important;
}

.thread-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.thread-stats {
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
}

.thread-stats span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

/* Post Card */
.post-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--light-bg);
    border-bottom: 1px solid var(--border-color);
}

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

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

.post-author-info h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.post-author-info small {
    color: var(--text-muted);
}

.post-body {
    padding: 1.5rem;
    line-height: 1.8;
}

.post-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
}

.post-footer {
    padding: 1rem 1.5rem;
    background: var(--light-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.post-actions button,
.post-actions a {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.2s ease;
}

.post-actions button:hover,
.post-actions a:hover {
    color: var(--primary-color);
}

/* Badges */
.rank-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.rank-newbie {
    background: #94A3B8;
    color: white;
}

.rank-member {
    background: #10B981;
    color: white;
}

.rank-veteran {
    background: #3B82F6;
    color: white;
}

.rank-expert {
    background: #8B5CF6;
    color: white;
}

.rank-legend {
    background: #F59E0B;
    color: white;
}

/* Tags */
.thread-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--primary-color);
    color: white;
    border-radius: 20px;
    font-size: 0.8rem;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.tag:hover {
    opacity: 0.8;
    color: white;
}

/* Pagination */
.pagination {
    justify-content: center;
    margin-top: 2rem;
}

.pagination .page-link {
    color: var(--primary-color);
    border-color: var(--border-color);
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

body.dark-mode .pagination .page-link {
    background-color: var(--card-bg);
    color: var(--text-color);
}

/* Footer */
.footer {
    margin-top: auto;
}

/* Navbar enhancements */
.navbar.navbar-dark.bg-dark {
    background: rgba(15, 23, 42, 0.95) !important;
    /* slate-900 */
    box-shadow: 0 2px 12px rgba(0, 0, 0, .25);
    backdrop-filter: saturate(160%) blur(6px);
    padding-top: .4rem;
    /* add vertical space */
    padding-bottom: .4rem;
    /* add vertical space */
    top: 10px;
    /* offset from very top to avoid hugging the edge */
    margin-top: 10px;
    /* visual breathing room above the bar */
}

/* Remove navbar toggle button (hamburger) */
body>nav.navbar>div.container>button.navbar-toggler {
    display: none !important;
}

/* Keep navbar menu visible since toggler is removed */
.navbar .navbar-collapse {
    display: flex !important;
    flex-basis: auto !important;
}

/* Fix bullets and spacing in navbar list */
.navbar .navbar-nav {
    list-style: none !important;
    padding-left: 0 !important;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: .6rem;
    /* more space between items */
}

.navbar .navbar-nav .nav-item {
    display: inline-flex;
}

.navbar .navbar-nav .nav-link,
.navbar .navbar-nav .btn.nav-link {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    /* space between icon and label */
    padding: .25rem .6rem;
    /* horizontal breathing room */
}

/* Tweak icon spacing inside nav links */
.navbar .navbar-nav .nav-link i {
    margin-right: .15rem;
}

/* Add a little space around the dark mode toggle */
.navbar #darkModeToggle {
    padding-left: .6rem;
    padding-right: .6rem;
}

/* Keep brand nicely aligned with icon */
.navbar .navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding-top: .15rem;
    padding-bottom: .15rem;
}

/* Ensure navbar content is vertically centered */
.navbar .container {
    display: flex;
    align-items: center;
}

.navbar .navbar-nav .nav-link,
.navbar .navbar-nav .btn.nav-link {
    line-height: 1.25;
}

/* Breadcrumb */
.breadcrumb {
    background: transparent;
    margin-bottom: 0;
}

.breadcrumb .breadcrumb-item+.breadcrumb-item::before {
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

body.dark-mode .breadcrumb .breadcrumb-item,
body.dark-mode .breadcrumb a,
body.dark-mode .breadcrumb .breadcrumb-item+.breadcrumb-item::before {
    color: var(--text-muted);
}

/* Stat card icon spacing */
.stat-card i {
    margin-bottom: .25rem;
}

/* Responsive */
@media (max-width: 768px) {
    .category-row {
        grid-template-columns: 48px 1fr;
    }

    .latest-thread-card {
        margin-top: .5rem;
    }

    .subs-columns {
        grid-template-columns: 1fr;
    }

    .category-card {
        margin-bottom: 1.5rem;
    }

    .category-stats {
        text-align: left !important;
        margin-top: 1rem;
    }

    .thread-meta {
        flex-direction: column;
        gap: 0.5rem;
    }

    .post-footer {
        flex-direction: column;
        gap: 1rem;
    }
}

/* Extra-small phones: force forum tiles to single column */
@media (max-width: 576px) {

    /* Forum stats: col-6 -> full width on mobile */
    .forum-stats .row>[class*="col-"] {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Any forum category grids that might use Bootstrap cols */
    .forum-categories .row>[class*="col-"] {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
}

/* Utilities */
.user-online::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--success-color);
    border-radius: 50%;
    margin-right: 0.5rem;
}

.sticky-top-custom {
    position: sticky;
    top: 1rem;
    z-index: 100;
}

/* Quote Block */
.forum-quote {
    border-left: 4px solid var(--primary-color);
    padding: 1rem;
    margin: 1rem 0;
    background: var(--light-bg);
    border-radius: 4px;
}

/* Code Block */
pre code {
    display: block;
    padding: 1rem;
    background: #282C34;
    color: #ABB2BF;
    border-radius: 8px;
    overflow-x: auto;
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(59, 130, 246, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
}

.toast {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* Form action buttons area */
.form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: .5rem;
    margin-top: 1.25rem;
    /* ~mt-4 */
    padding-top: 1rem;
    /* ~pt-3 */
    border-top: 1px solid var(--border-color);
}