/* TeenBuzzTH - Modern Thai Teen Community CSS */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #ec4899;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1e293b;
    --gray-900: #0f172a;
    --gray-800: #1e293b;
    --gray-700: #334155;
    --gray-600: #475569;
    --gray-500: #64748b;
    --gray-400: #94a3b8;
    --gray-300: #cbd5e1;
    --gray-200: #e2e8f0;
    --gray-100: #f1f5f9;
    --gray-50: #f8fafc;
    --white: #ffffff;
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
    --gradient-dark: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --font-thai: 'Noto Sans Thai', 'Sarabun', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-thai), -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-dark);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-icon {
    font-size: 1.75rem;
}

.logo-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

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

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--gray-600);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.nav-link.active {
    background: var(--primary);
    color: var(--white);
}

/* Search Bar */
.search-bar {
    display: flex;
    align-items: center;
    background: var(--gray-100);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    flex: 1;
    max-width: 400px;
    margin: 0 2rem;
}

.search-bar input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 0.95rem;
    color: var(--gray-800);
}

.search-bar input::placeholder {
    color: var(--gray-400);
}

.search-bar button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: var(--gray-500);
}

/* User Menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.avatar:hover {
    transform: scale(1.05);
}

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

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: 0.5rem;
    padding-top: 0.75rem;
    display: none;
    z-index: 1000;
}

.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 15px;
    background: transparent;
}

.dropdown:hover .dropdown-menu,
.dropdown-menu:hover {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--gray-700);
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.dropdown-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 0.5rem 0;
}

/* Notifications */
.notification-btn {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    font-size: 1.25rem;
    color: var(--gray-600);
    transition: color 0.2s;
}

.notification-btn:hover {
    color: var(--primary);
}

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--danger);
    color: var(--white);
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-weight: 600;
}

/* Main Layout */
.main {
    display: grid;
    grid-template-columns: 260px 1fr 300px;
    gap: 2.5rem;
    padding: 1.5rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

@media (max-width: 1024px) {
    .main {
        grid-template-columns: 1fr;
    }
    .sidebar-left, .sidebar-right {
        display: none;
    }
}

/* Sidebar */
.sidebar-left, .sidebar-right {
    position: sticky;
    top: 80px;
    height: fit-content;
}

.sidebar-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.sidebar-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

/* Topic List */
.topic-list {
    list-style: none;
}

.topic-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
    color: var(--gray-700);
}

.topic-item:hover, .topic-item.active {
    background: var(--gray-100);
}

.topic-item.active {
    color: var(--primary);
    font-weight: 600;
}

.topic-icon {
    font-size: 1.25rem;
}

.topic-count {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--gray-400);
}

/* Stats Card */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.stat-item {
    text-align: center;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
}

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

.stat-label {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: var(--white);
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    color: var(--white);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-warning {
    background: var(--warning);
    color: var(--white);
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.btn-block {
    width: 100%;
}

/* Posts Feed */
.feed {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.feed-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-800);
}

.feed-tabs {
    display: flex;
    gap: 0.5rem;
}

.feed-tab {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--gray-600);
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
}

.feed-tab:hover, .feed-tab.active {
    background: var(--primary);
    color: var(--white);
}

/* Post Card */
.post-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

.post-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

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

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

.post-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
}

.post-meta {
    flex: 1;
}

.post-author {
    font-weight: 600;
    color: var(--gray-800);
}

.post-author:hover {
    color: var(--primary);
}

.post-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--gray-500);
}

.post-topic {
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--white);
}

.post-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.post-title a {
    color: inherit;
}

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

.post-excerpt {
    color: var(--gray-600);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-footer {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--gray-100);
}

.post-stat {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* Post Detail */
.post-detail {
    background: var(--white);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.post-detail .post-title {
    font-size: 1.75rem;
    margin-bottom: 1rem;
}

.post-content {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--gray-700);
    margin: 1.5rem 0;
}

.post-content p {
    margin-bottom: 1rem;
}

.post-actions {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 0;
    border-top: 1px solid var(--gray-200);
    border-bottom: 1px solid var(--gray-200);
    margin: 1.5rem 0;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--gray-600);
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.action-btn.liked {
    background: #fef2f2;
    color: var(--danger);
}

.action-btn.bookmarked {
    background: #fef3c7;
    color: var(--warning);
}

/* Replies */
.replies-section {
    margin-top: 2rem;
}

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

.replies-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.reply-card {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.reply-card.child {
    margin-left: 2rem;
    border-left: 3px solid var(--gray-300);
}

.reply-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.reply-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
    font-size: 0.85rem;
}

.reply-content {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--gray-700);
}

.reply-actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
}

.reply-action {
    font-size: 0.8rem;
    color: var(--gray-500);
    cursor: pointer;
    transition: color 0.2s;
}

.reply-action:hover {
    color: var(--primary);
}

/* Reply Form */
.reply-form {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1.5rem;
    box-shadow: var(--shadow);
}

.reply-form textarea {
    width: 100%;
    min-height: 100px;
    padding: 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    resize: vertical;
    font-family: inherit;
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}

.reply-form textarea:focus {
    outline: none;
    border-color: var(--primary);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

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

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s;
    background: var(--white);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-textarea {
    min-height: 200px;
    resize: vertical;
}

.form-hint {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-top: 0.5rem;
}

.form-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* Auth Pages */
.auth-container {
    min-height: calc(100vh - 70px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    color: var(--gray-500);
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--gray-500);
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-weight: 500;
}

.alert-error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: var(--success);
    border: 1px solid #bbf7d0;
}

.alert-warning {
    background: #fffbeb;
    color: var(--warning);
    border: 1px solid #fde68a;
}

/* Profile Page */
.profile-header {
    background: var(--gradient-primary);
    padding: 3rem 2rem;
    border-radius: var(--radius-lg);
    color: var(--white);
    margin-bottom: 1.5rem;
    text-align: center;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0 auto 1rem;
    border: 4px solid rgba(255,255,255,0.3);
}

.profile-name {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.profile-username {
    opacity: 0.8;
    margin-bottom: 1rem;
}

.profile-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1.5rem;
}

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

.profile-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.profile-stat-label {
    font-size: 0.85rem;
    opacity: 0.8;
}

.follow-btn {
    padding: 0.5rem 1.5rem;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid var(--white);
    background: transparent;
    color: var(--white);
}

.follow-btn:hover {
    background: var(--white);
    color: var(--primary);
}

.follow-btn.following {
    background: var(--white);
    color: var(--primary);
}

/* Admin Dashboard */
.admin-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: calc(100vh - 70px);
}

.admin-sidebar {
    background: var(--gray-900);
    padding: 1.5rem;
}

.admin-nav {
    list-style: none;
}

.admin-nav-item {
    margin-bottom: 0.5rem;
}

.admin-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    color: var(--gray-400);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.admin-nav-link:hover, .admin-nav-link.active {
    background: var(--gray-800);
    color: var(--white);
}

.admin-content {
    padding: 2rem;
    background: var(--gray-100);
}

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

.admin-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-800);
}

/* Dashboard Stats */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.stat-card-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.stat-card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-800);
}

.stat-card-label {
    color: var(--gray-500);
    font-size: 0.9rem;
}

/* Tables */
.table-container {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th, .table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tr:hover {
    background: var(--gray-50);
}

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

.bg-purple {
    background: var(--primary);
    color: var(--white);
}

.bg-gray {
    background: var(--gray-300);
    color: var(--gray-700);
}

.bg-green {
    background: var(--success);
    color: var(--white);
}

.bg-red {
    background: var(--danger);
    color: var(--white);
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* Loading States */
.htmx-request {
    opacity: 0.7;
    pointer-events: none;
}

.htmx-request::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .search-bar {
        order: 3;
        max-width: 100%;
        margin: 0;
        width: 100%;
    }
    
    .main {
        padding: 1rem;
    }
    
    .post-detail {
        padding: 1.25rem;
    }
    
    .admin-layout {
        grid-template-columns: 1fr;
    }
    
    .admin-sidebar {
        display: none;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--gray-500);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

/* Pinned indicator */
.pinned-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    background: var(--warning);
    color: var(--white);
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* Locked indicator */
.locked-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    background: var(--gray-500);
    color: var(--white);
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}
