/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1a1a2e;
    --secondary: #16213e;
    --accent: #0f3460;
    --text-primary: #333;
    --text-secondary: #666;
    --text-light: #999;
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f1f3f5;
    --border: #e9ecef;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.04);
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 6px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    font-size: 15px;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary);
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
}

/* Container */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header */
header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
}

header .logo {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

header .logo a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

header .logo a:hover {
    opacity: 0.8;
}

header nav ul {
    display: flex;
    list-style: none;
    gap: 8px;
}

header nav ul li a {
    color: var(--text-secondary);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-weight: 500;
}

header nav ul li a:hover,
header nav ul li a.active {
    color: var(--primary);
    background: var(--bg-secondary);
}

/* User menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-menu .profile-pic {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border);
    transition: var(--transition);
}

.user-menu .profile-pic:hover {
    border-color: var(--accent);
}

/* Main content */
main {
    padding: 48px 0;
    min-height: calc(100vh - 200px);
}

/* Cards */
.card {
    background: var(--bg-primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 32px;
    overflow: hidden;
    transition: var(--transition);
    border: 1px solid var(--border);
}

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

.card-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.card-header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.card-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
}

.card-body {
    padding: 32px;
}

.card-footer {
    padding: 20px 32px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

/* Forms */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    display: block;
    width: 100%;
    padding: 14px 16px;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-family: inherit;
}

.form-control:focus {
    color: var(--text-primary);
    background: var(--bg-primary);
    border-color: var(--accent);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(15, 52, 96, 0.1);
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    user-select: none;
    border: none;
    padding: 12px 24px;
    font-size: 14px;
    line-height: 1.5;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    color: white;
    background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
    box-shadow: 0 4px 12px rgba(15, 52, 96, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(15, 52, 96, 0.4);
    color: white;
}

.btn-secondary {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: var(--border);
    transform: translateY(-1px);
    color: var(--text-primary);
}

.btn-danger {
    color: white;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
    color: white;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 12px;
}

/* Tables */
.table {
    width: 100%;
    margin-bottom: 24px;
    color: var(--text-primary);
    border-collapse: separate;
    border-spacing: 0;
}

.table th,
.table td {
    padding: 16px;
    vertical-align: middle;
    border-top: 1px solid var(--border);
}

.table th {
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-top: none;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background: var(--bg-secondary);
}

/* Alerts */
.alert {
    position: relative;
    padding: 16px 24px;
    margin-bottom: 24px;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 500;
}

.alert-success {
    color: #0f5132;
    background: linear-gradient(135deg, #d1f2eb 0%, #a7e9c8 100%);
}

.alert-danger {
    color: #842029;
    background: linear-gradient(135deg, #f8d7da 0%, #f5c2c7 100%);
}

.alert-info {
    color: #055160;
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
}

/* Categories */
.categories {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.category-card {
    background: var(--bg-primary);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
    border: 1px solid var(--border);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.category-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.category-header {
    padding: 24px;
    color: white;
    position: relative;
    overflow: hidden;
}

.category-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 100%);
}

.category-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    position: relative;
    z-index: 1;
}

.category-body {
    padding: 24px;
    flex: 1;
}

.category-body p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.category-footer {
    padding: 20px 24px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

/* Posts */
.post-item {
    padding: 24px 0;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.post-item:last-child {
    border-bottom: none;
}

.post-item:hover {
    background: var(--bg-secondary);
    margin: 0 -32px;
    padding-left: 32px;
    padding-right: 32px;
}

.post-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
}

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

.post-meta {
    color: var(--text-light);
    font-size: 13px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.post-excerpt {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Replies */
.reply-item {
    padding: 24px;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.reply-item:last-child {
    border-bottom: none;
}

.reply-item:hover {
    background: var(--bg-secondary);
}

.reply-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.reply-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    margin-right: 16px;
    border: 2px solid var(--border);
}

.reply-meta {
    color: var(--text-light);
    font-size: 13px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    margin-top: 32px;
    gap: 8px;
}

.pagination .page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    line-height: 1;
    color: var(--text-secondary);
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-weight: 500;
}

.pagination .page-link:hover {
    color: var(--primary);
    background: var(--bg-secondary);
    border-color: var(--accent);
    text-decoration: none;
    transform: translateY(-1px);
}

.pagination .page-item.active .page-link {
    color: white;
    background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(15, 52, 96, 0.3);
}

/* Profile */
.profile-header {
    display: flex;
    align-items: center;
    margin-bottom: 32px;
    padding: 32px;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border-radius: var(--radius);
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin-right: 32px;
    border: 4px solid var(--bg-primary);
    box-shadow: var(--shadow);
}

.profile-info h2 {
    margin-bottom: 8px;
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--primary);
}

.profile-info p {
    color: var(--text-secondary);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-primary {
    color: white;
    background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
}

.badge-danger {
    color: white;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.badge-success {
    color: white;
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
}

/* Footer */
footer {
    background: var(--primary);
    color: white;
    padding: 48px 0 24px;
    margin-top: 64px;
}

footer .container {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 32px;
}

footer .footer-section h3 {
    margin-bottom: 16px;
    font-size: 1.125rem;
    font-weight: 600;
}

footer .footer-section ul {
    list-style: none;
}

footer .footer-section ul li {
    margin-bottom: 8px;
}

footer .footer-section ul li a {
    color: rgba(255, 255, 255, 0.8);
    transition: var(--transition);
}

footer .footer-section ul li a:hover {
    color: white;
    text-decoration: none;
}

footer .footer-bottom {
    text-align: center;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    width: 100%;
    font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
    :root {
        --radius: 8px;
    }
    
    .container {
        padding: 0 16px;
    }
    
    header .container {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px;
    }
    
    header nav {
        width: 100%;
        margin-top: 16px;
    }
    
    header nav ul {
        flex-wrap: wrap;
    }
    
    .categories {
        grid-template-columns: 1fr;
    }
    
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
    
    .profile-avatar {
        margin-right: 0;
        margin-bottom: 16px;
    }
    
    footer .container {
        flex-direction: column;
    }
    
    .card-header,
    .card-body,
    .card-footer {
        padding: 20px;
    }
    
    main {
        padding: 24px 0;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.6s ease-out;
}

/* Form validation styles */
.form-control.is-invalid {
    border-color: #e74c3c;
    background-color: #fdf2f2;
}

.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 8px;
    font-size: 13px;
    color: #e74c3c;
    font-weight: 500;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--bg-primary);
    margin: 5% auto;
    padding: 0;
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h5 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
}

.modal-body {
    padding: 32px;
}

.modal-footer {
    padding: 24px 32px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.close {
    color: var(--text-light);
    font-size: 28px;
    font-weight: 300;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}

.close:hover {
    color: var(--text-primary);
}

/* Admin panel styles */
.admin-nav {
    display: flex;
    margin-bottom: 32px;
    border-bottom: 1px solid var(--border);
    gap: 4px;
}

.admin-nav a {
    padding: 12px 20px;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    transition: var(--transition);
    font-weight: 500;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.admin-nav a:hover {
    color: var(--primary);
    background: var(--bg-secondary);
    text-decoration: none;
}

.admin-nav a.active {
    color: var(--primary);
    border-bottom-color: var(--accent);
    background: var(--bg-secondary);
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* Rich text editor styles */
.editor-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    border: 2px solid var(--border);
    border-bottom: none;
}

.editor-button {
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    font-size: 14px;
}

.editor-button:hover {
    background: var(--bg-tertiary);
    transform: translateY(-1px);
}

.editor-textarea {
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    border-top: none;
}

/* Mobile menu */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.mobile-menu-toggle:hover {
    background: var(--bg-secondary);
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    header nav {
        display: none;
        width: 100%;
    }
    
    header nav.active {
        display: block;
    }
    
    header nav ul {
        flex-direction: column;
        margin-top: 0;
        width: 100%;
    }
    
    header nav ul li {
        margin: 0;
        width: 100%;
    }
    
    header nav ul li a {
        display: block;
        padding: 12px 16px;
        border-radius: 0;
    }
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* Focus styles for accessibility */
.btn:focus,
.form-control:focus,
a:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    header, footer, .btn, .admin-nav {
        display: none;
    }
    
    body {
        background: white;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}