* {
    box-sizing: border-box;
}

:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --border-color: #e5e7eb;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s, color 0.3s;
    background-color: var(--bg-light);
    font-size: 15px;
    line-height: 1.6;
}

#app {
    flex: 1;
}

.container {
    max-width: 1400px;
}

body.dark-mode {
    background-color: #0f172a;
    color: #e2e8f0;
}

body.dark-mode nav {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

body.dark-mode .bg-white {
    background-color: #1e293b !important;
}

body.dark-mode .bg-gray-50 {
    background-color: #0f172a !important;
}

body.dark-mode .bg-gray-100 {
    background-color: #334155 !important;
}

body.dark-mode .text-gray-800 {
    color: #f1f5f9 !important;
}

body.dark-mode .text-gray-700 {
    color: #cbd5e1 !important;
}

body.dark-mode .text-gray-600 {
    color: #94a3b8 !important;
}

body.dark-mode .text-gray-500 {
    color: #64748b !important;
}

body.dark-mode .border,
body.dark-mode .border-gray-200 {
    border-color: #334155 !important;
}

body.dark-mode .shadow-md,
body.dark-mode .shadow-sm,
body.dark-mode .shadow-lg,
body.dark-mode .shadow-xl {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3) !important;
}

body.dark-mode .category-card,
body.dark-mode .thread-row,
body.dark-mode .post-card {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

body.dark-mode .category-card:hover,
body.dark-mode .thread-row:hover {
    background-color: #334155 !important;
}

body.dark-mode .post-author-card {
    background: linear-gradient(to bottom, #1e293b 0%, #0f172a 100%) !important;
}

body.dark-mode input,
body.dark-mode textarea,
body.dark-mode select {
    background-color: #0f172a !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
    color: #64748b !important;
}

body.dark-mode input:focus,
body.dark-mode textarea:focus,
body.dark-mode select:focus {
    border-color: #6366f1 !important;
    background-color: #1e293b !important;
}

body.dark-mode table thead {
    background-color: #334155 !important;
}

body.dark-mode table tbody {
    background-color: #1e293b !important;
}

body.dark-mode .divide-gray-200 > * {
    border-color: #334155 !important;
}

body.dark-mode #modal {
    background-color: rgba(0, 0, 0, 0.85) !important;
}

body.dark-mode #modal .bg-white {
    background-color: #1e293b !important;
}

body.dark-mode .stats-badge {
    background-color: #334155 !important;
    color: #cbd5e1 !important;
}

body.dark-mode footer {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

body.dark-mode .pinned-thread {
    background: linear-gradient(to right, #422006 0%, #1e293b 100%) !important;
}

body.dark-mode .announcement-thread {
    background: linear-gradient(to right, #1e3a8a 0%, #1e293b 100%) !important;
}

body.dark-mode .category-icon,
body.dark-mode .user-avatar {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

.category-card {
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
}

.category-card:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-lg);
    border-left-color: var(--primary-hover);
}

.category-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
    font-size: 24px;
    flex-shrink: 0;
}

.thread-row {
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
    border-left: 3px solid transparent;
}

.thread-row:hover {
    background-color: #f9fafb;
    border-left-color: var(--primary-color);
    transform: translateX(2px);
}

.post-card {
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
}

.post-card:hover {
    box-shadow: var(--shadow-md);
}

.post-author-card {
    background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
    border-right: 1px solid var(--border-color);
}

.user-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 32px;
    margin: 0 auto;
    border: 3px solid white;
    box-shadow: var(--shadow-md);
}

.stats-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #f3f4f6;
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.badge-admin {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.3);
}

.badge-moderator {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.badge-user {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.badge-guest {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(107, 114, 128, 0.3);
}

.pinned-thread {
    background: linear-gradient(to right, #fef3c7 0%, #ffffff 100%);
    border-left-color: #f59e0b !important;
}

.locked-thread {
    opacity: 0.7;
    background-color: #f9fafb;
}

.announcement-thread {
    background: linear-gradient(to right, #dbeafe 0%, #ffffff 100%);
    border-left-color: #3b82f6 !important;
}

nav {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: var(--shadow-md);
}

nav a {
    color: white !important;
}

nav button {
    border: 2px solid rgba(255, 255, 255, 0.3);
}

nav button:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.5);
}

footer {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.4);
}

.thread-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.thread-meta > * {
    display: flex;
    align-items: center;
    gap: 4px;
}

.category-stats {
    text-align: right;
    min-width: 120px;
}

.stat-number {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#modal {
    display: none;
}

#modal.active {
    display: flex;
}

.admin-tab {
    cursor: pointer;
    transition: all 0.2s;
}

.admin-tab.active {
    border-bottom-color: #2563eb;
    color: #2563eb;
}

@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    nav .flex {
        flex-wrap: wrap;
    }
    
    #userNav {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .text-3xl {
        font-size: 1.5rem;
    }
    
    .grid-cols-1 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    nav .text-2xl {
        font-size: 1.25rem;
    }
    
    nav button {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .space-x-4 > * + * {
        margin-left: 0.5rem;
    }
}

.editor-toolbar {
    border: 1px solid #e5e7eb;
    border-bottom: none;
    background: #f9fafb;
    padding: 0.5rem;
    border-radius: 0.5rem 0.5rem 0 0;
}

.editor-toolbar button {
    padding: 0.25rem 0.5rem;
    margin-right: 0.25rem;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 0.25rem;
    cursor: pointer;
}

.editor-toolbar button:hover {
    background: #f3f4f6;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pagination button {
    padding: 0.5rem 1rem;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
    background: #f3f4f6;
}

.pagination button.active {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: #2563eb;
    animation: spin 1s linear infinite;
}

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

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    background: #10b981;
    color: white;
}

.toast.error {
    background: #ef4444;
    color: white;
}

.toast.info {
    background: #3b82f6;
    color: white;
}

