/* ===== RESET & BASE ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #4a90d9;
  --primary-dark: #357abd;
  --primary-light: #e8f1fb;
  --accent: #f0a030;
  --bg: #f4f6f9;
  --bg-white: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --text-muted: #b0b8c1;
  --border: #e1e5eb;
  --border-light: #f0f2f5;
  --success: #27ae60;
  --danger: #e74c3c;
  --warning: #f39c12;
  --admin-badge: #e74c3c;
  --moderator-badge: #8e44ad;
  --member-badge: #4a90d9;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 0.2s ease;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

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

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

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

img {
  max-width: 100%;
  display: block;
}

/* ===== HEADER ===== */
.header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

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

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
}

.logo-icon-img {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  object-fit: cover;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  transition: background var(--transition), color var(--transition);
}

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

.nav-link.btn-login {
  color: var(--primary);
}

.nav-link.btn-register {
  background: var(--primary);
  color: #fff;
}

.nav-link.btn-register:hover {
  background: var(--primary-dark);
  color: #fff;
}

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

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

.user-name {
  font-weight: 500;
  font-size: 0.9rem;
}

/* ===== MAIN CONTAINER ===== */
.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 24px 20px;
  flex: 1;
}

/* ===== BREADCRUMBS ===== */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 20px;
}

.breadcrumbs a {
  color: var(--text-light);
}

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

.breadcrumbs .sep {
  color: var(--text-muted);
}

/* ===== HERO / WELCOME ===== */
.hero {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  color: #fff;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 400px;
  height: 400px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: 10%;
  width: 250px;
  height: 250px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}

.hero h1 {
  font-size: 1.7rem;
  font-weight: 700;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.hero p {
  font-size: 1rem;
  opacity: 0.9;
  position: relative;
  z-index: 1;
  max-width: 600px;
}

/* ===== STATS BAR ===== */
.stats-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1;
  min-width: 150px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

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

.stat-label {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== SECTION HEADER ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title .icon {
  color: var(--primary);
}

/* ===== FORUM TOPICS LIST ===== */
.topics-list {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 28px;
  position: relative;
}

.topics-list.blurred .topic-item {
  filter: blur(6px);
  pointer-events: none;
  user-select: none;
}

.topics-list.blurred .blur-overlay {
  display: flex;
}

.blur-overlay {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.95);
  padding: 16px 28px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  box-shadow: var(--shadow-md);
  z-index: 10;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  pointer-events: auto;
  white-space: nowrap;
}

.blur-overlay a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.topic-item {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
  cursor: pointer;
}

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

.topic-item:hover {
  background: #fafbfd;
}

.topic-item.pinned {
  background: #fffdf5;
  border-left: 3px solid var(--accent);
}

.topic-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  margin-right: 14px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  color: #fff;
}

.topic-avatar-img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  margin-right: 14px;
  flex-shrink: 0;
  object-fit: cover;
}

.topic-content {
  flex: 1;
  min-width: 0;
  margin-right: 16px;
}

.topic-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topic-title a {
  color: var(--text);
}

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

.topic-meta {
  font-size: 0.8rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 12px;
}

.topic-meta .author {
  font-weight: 500;
}

.topic-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.topic-stat {
  text-align: center;
  min-width: 50px;
}

.topic-stat-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.topic-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-admin {
  background: #fde8e8;
  color: var(--admin-badge);
}

.badge-moderator {
  background: #f0e6f6;
  color: var(--moderator-badge);
}

.badge-member {
  background: var(--primary-light);
  color: var(--member-badge);
}

.badge-pinned {
  background: #fff3cd;
  color: #856404;
}

.badge-locked {
  background: #f0f0f0;
  color: #666;
}

/* ===== RULES / ADMIN POST ===== */
.admin-post {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 28px;
}

.admin-post-header {
  background: linear-gradient(135deg, #fff5f5, #fff0f0);
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
}

.admin-post-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.admin-post-info h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.admin-post-info .meta {
  font-size: 0.8rem;
  color: var(--text-light);
}

.admin-post-body {
  padding: 24px;
}

.admin-post-body h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 10px;
  margin-top: 18px;
  color: var(--text);
}

.admin-post-body h3:first-child {
  margin-top: 0;
}

.admin-post-body p {
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 12px;
}

.admin-post-body ul, .admin-post-body ol {
  margin: 10px 0 14px 20px;
  font-size: 0.92rem;
  line-height: 1.8;
  color: var(--text);
}

.admin-post-body li {
  margin-bottom: 4px;
}

.admin-post-body .highlight-box {
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  padding: 14px 18px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 16px 0;
  font-size: 0.9rem;
  color: var(--text);
}

.admin-post-body .warning-box {
  background: #fff8e1;
  border-left: 4px solid var(--warning);
  padding: 14px 18px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 16px 0;
  font-size: 0.9rem;
  color: var(--text);
}

/* ===== AUTH FORMS ===== */
.auth-container {
  max-width: 440px;
  margin: 40px auto;
}

.auth-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-md);
}

.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
}

.auth-card .subtitle {
  text-align: center;
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.92rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-group .hint {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 5px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform 0.1s ease;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.88rem;
  color: var(--text-light);
}

/* ===== ALERTS ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 18px;
  display: none;
  align-items: center;
  gap: 10px;
}

.alert.show {
  display: flex;
}

.alert-error {
  background: #fde8e8;
  color: #c0392b;
  border: 1px solid #f5c6cb;
}

.alert-success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.alert-warning {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffeaa7;
}

.alert-info {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid #bee5eb;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 1.3rem;
  color: var(--text-light);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.modal-close:hover {
  background: var(--border-light);
}

.modal-body {
  padding: 24px;
}

.modal-body p {
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.7;
}

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

.modal-footer .btn {
  width: auto;
  padding: 8px 20px;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border-light);
}

/* ===== FOOTER ===== */
.footer {
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  padding: 20px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-light);
  margin-top: auto;
}

.footer a {
  color: var(--text-light);
}

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

.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 8px;
}

/* ===== ONLINE USERS ===== */
.online-bar {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-light);
  box-shadow: var(--shadow-sm);
}

.online-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== LOADING SPINNER ===== */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: none;
}

.spinner.active {
  display: inline-block;
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .header-inner {
    height: 54px;
  }

  .logo {
    font-size: 1.15rem;
  }

  .hero {
    padding: 28px 22px;
  }

  .hero h1 {
    font-size: 1.3rem;
  }

  .stats-bar {
    gap: 10px;
  }

  .stat-card {
    min-width: 120px;
    padding: 14px 12px;
  }

  .topic-item {
    padding: 12px 14px;
    flex-wrap: wrap;
  }

  .topic-stats {
    display: none;
  }

  .topic-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.85rem;
    margin-right: 10px;
  }

  .topic-avatar-img {
    width: 36px;
    height: 36px;
    margin-right: 10px;
  }

  .auth-card {
    padding: 28px 22px;
  }

  .admin-post-header {
    padding: 16px 18px;
  }

  .admin-post-body {
    padding: 18px;
  }
}

@media (max-width: 480px) {
  .header-nav .nav-link span {
    display: none;
  }

  .nav-link {
    padding: 8px 10px;
  }

  .footer-links {
    flex-direction: column;
    gap: 6px;
  }
}

/* ===== TOAST NOTIFICATION ===== */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  min-width: 280px;
  max-width: 400px;
  animation: toastIn 0.3s ease;
}

.toast.toast-out {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(30px);
  }
}

.toast-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.toast-error .toast-icon { color: var(--danger); }
.toast-success .toast-icon { color: var(--success); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--primary); }
