/* ===== EATR Public Layout — Sidebar + Main ===== */

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: #f0f2f5; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }

/* ===== TOP NAV ===== */
.pub-topnav {
  position: fixed; top: 0; left: 0; right: 0;
  height: 56px; z-index: 1100;
  background: linear-gradient(90deg, #0f1d38 0%, #132248 40%, #142654 100%);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  box-shadow: 0 2px 20px rgba(0,0,0,0.4), 0 1px 0 rgba(27,219,224,0.1);
  border-bottom: 1px solid rgba(27,219,224,0.08);
}
.topnav-left { display: flex; align-items: center; gap: 14px; }
.topnav-toggle {
  display: none; background: none; border: none; color: rgba(255,255,255,0.8);
  font-size: 1.4rem; cursor: pointer; padding: 4px 8px;
}
.topnav-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.topnav-brand-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #1bdbe0, #0fa3b1);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #fff;
}
.topnav-brand-text { font-size: 1.1rem; font-weight: 800; color: #fff; letter-spacing: 1px; }
.topnav-right { display: flex; align-items: center; gap: 8px; }
.topnav-right a {
  color: rgba(255,255,255,0.65); text-decoration: none; font-size: 0.84rem;
  padding: 6px 14px; border-radius: 6px; transition: all 0.2s;
  display: flex; align-items: center; gap: 5px;
}
.topnav-right a:hover { background: rgba(255,255,255,0.1); color: #fff; }
.topnav-right .btn-admin {
  background: rgba(27,219,224,0.15); color: #1bdbe0 !important;
  border: 1px solid rgba(27,219,224,0.3);
}
.topnav-right .btn-admin:hover { background: rgba(27,219,224,0.25) !important; }

/* ===== LAYOUT WRAPPER ===== */
.pub-layout {
  display: flex;
  margin-top: 56px;
  min-height: calc(100vh - 56px);
}

/* ===== PUBLIC SIDEBAR — Glassmorphism + Gradient ===== */
.pub-sidebar {
  width: 280px; min-width: 280px;
  position: fixed; top: 0; left: 0;
  height: 100vh; padding-top: 56px;
  overflow-y: auto; overflow-x: hidden;
  z-index: 900;
  transition: left 0.3s ease;

  /* Rich deep gradient background */
  background: linear-gradient(175deg,
    #0f1d38 0%,
    #132248 25%,
    #102035 50%,
    #152850 75%,
    #0c1830 100%
  );
  box-shadow: 4px 0 32px rgba(0,0,0,0.5), 2px 0 8px rgba(27,219,224,0.06);
}

/* Decorative glow orbs */
.pub-sidebar::before {
  content: '';
  position: absolute; top: 60px; left: -40px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(27,219,224,0.18) 0%, transparent 65%);
  pointer-events: none; z-index: 0;
}
.pub-sidebar::after {
  content: '';
  position: absolute; bottom: 120px; right: -30px;
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(120,80,255,0.14) 0%, transparent 65%);
  pointer-events: none; z-index: 0;
}
.pub-sidebar > * { position: relative; z-index: 1; }

.pub-sidebar::-webkit-scrollbar { width: 3px; }
.pub-sidebar::-webkit-scrollbar-track { background: transparent; }
.pub-sidebar::-webkit-scrollbar-thumb {
  background: linear-gradient(to bottom, #1bdbe0, #7850ff);
  border-radius: 2px;
}

/* Heading */
.pub-sidebar-heading {
  padding: 18px 16px 10px;
  font-size: 0.65rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 2.5px;
  background: linear-gradient(90deg, #1bdbe0, #7ca5ff);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex; align-items: center; gap: 6px;
}
.pub-sidebar-heading i {
  -webkit-text-fill-color: #1bdbe0;
  filter: drop-shadow(0 0 4px rgba(27,219,224,0.6));
}

/* ─── Class items ─── */
.pub-class-item {
  margin: 3px 10px;
  border-radius: 12px;
  transition: all 0.2s;
  border: 1px solid transparent;
}
.pub-class-item + .pub-class-item { margin-top: 3px; }

.pub-class-item.no-topics {
  opacity: 0.55;
}
.pub-class-item.has-topics {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.06);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.pub-class-item.has-topics:hover {
  background: rgba(27,219,224,0.06);
  border-color: rgba(27,219,224,0.2);
  box-shadow: 0 4px 20px rgba(27,219,224,0.08), inset 0 1px 0 rgba(255,255,255,0.05);
}
.pub-class-item.open {
  background: rgba(27,219,224,0.08) !important;
  border-color: rgba(27,219,224,0.3) !important;
  box-shadow: 0 6px 24px rgba(27,219,224,0.12), inset 0 1px 0 rgba(255,255,255,0.07) !important;
}

.pub-class-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  transition: all 0.2s;
}
.pub-class-item.has-topics .pub-class-header { cursor: pointer; }

.pub-class-icon {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.3);
  transition: all 0.2s;
}
.pub-class-item.has-topics .pub-class-icon {
  background: linear-gradient(135deg, rgba(27,219,224,0.2), rgba(27,219,224,0.08));
  border-color: rgba(27,219,224,0.3);
  color: #1bdbe0;
  box-shadow: 0 0 12px rgba(27,219,224,0.2);
}
.pub-class-item.open .pub-class-icon {
  background: linear-gradient(135deg, #1bdbe0, #0fa3b1);
  border-color: #1bdbe0;
  color: #fff;
  box-shadow: 0 4px 16px rgba(27,219,224,0.4);
}

.pub-class-info { flex: 1; min-width: 0; }
.pub-class-name {
  font-size: 0.87rem; font-weight: 700; display: block;
  color: rgba(255,255,255,0.65);
  transition: color 0.2s;
}
.pub-class-item.has-topics .pub-class-name { color: #fff; }
.pub-class-item.open .pub-class-name { color: #1bdbe0; }
.pub-class-count { font-size: 0.67rem; color: rgba(255,255,255,0.55); font-weight: 500; }
.pub-class-item.open .pub-class-count { color: rgba(27,219,224,0.8); }
.pub-class-count.empty { color: rgba(255,255,255,0.3); }

.pub-class-arrow {
  font-size: 0.7rem; color: rgba(255,255,255,0.2);
  transition: transform 0.25s, color 0.2s; flex-shrink: 0;
}
.pub-class-item.open > .pub-class-header .pub-class-arrow {
  transform: rotate(90deg);
  color: #1bdbe0;
  filter: drop-shadow(0 0 4px rgba(27,219,224,0.6));
}

/* Topics list */
.pub-topics-list {
  display: none;
  padding: 4px 6px 8px;
  background: rgba(0,0,0,0.12);
  border-radius: 0 0 12px 12px;
  border-top: 1px solid rgba(27,219,224,0.1);
}
.pub-class-item.open .pub-topics-list { display: block; }

/* Individual topic */
.pub-topic-item {
  border-radius: 9px;
  margin: 2px 0;
  transition: all 0.15s;
}
.pub-topic-header {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 7px 10px 7px 10px; cursor: pointer; border-radius: 9px;
  transition: all 0.15s;
}
.pub-topic-header:hover {
  background: rgba(255,255,255,0.04);
}
.pub-topic-item.active > .pub-topic-header {
  background: linear-gradient(135deg, rgba(27,219,224,0.18), rgba(27,219,224,0.06));
  box-shadow: 0 2px 12px rgba(27,219,224,0.12), inset 0 1px 0 rgba(27,219,224,0.15);
  border-left: 2px solid #1bdbe0;
  padding-left: 8px;
}

.pub-topic-num {
  min-width: 22px; height: 22px; border-radius: 7px; flex-shrink: 0; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.64rem; font-weight: 800;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.35);
  transition: all 0.2s;
}
.pub-topic-item.active .pub-topic-num {
  background: linear-gradient(135deg, #1bdbe0, #0fa3b1);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 10px rgba(27,219,224,0.45);
}
.pub-topic-header:hover .pub-topic-num {
  background: rgba(27,219,224,0.12);
  border-color: rgba(27,219,224,0.2);
  color: #1bdbe0;
}

.pub-topic-title {
  flex: 1; font-size: 0.77rem; line-height: 1.35;
  color: rgba(255,255,255,0.82); font-weight: 500;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  transition: color 0.15s;
}
.pub-topic-item.active .pub-topic-title {
  color: #1bdbe0;
  font-weight: 700;
  text-shadow: 0 0 20px rgba(27,219,224,0.3);
}
.pub-topic-header:hover .pub-topic-title { color: #fff; }

.pub-topic-arrow {
  font-size: 0.62rem; flex-shrink: 0; margin-top: 5px;
  color: rgba(255,255,255,0.18);
  transition: transform 0.2s, color 0.15s;
}
.pub-topic-item.expanded .pub-topic-arrow { transform: rotate(90deg); }
.pub-topic-item.active .pub-topic-arrow { color: #1bdbe0; }

/* Submenu */
.pub-submenu {
  display: none;
  padding: 3px 0 6px 40px;
  border-left: 1px solid rgba(27,219,224,0.15);
  margin: 0 0 4px 20px;
}
.pub-topic-item.expanded .pub-submenu { display: block; }

.pub-sub-link {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 10px 5px 0; font-size: 0.74rem;
  color: rgba(255,255,255,0.7); text-decoration: none;
  border-radius: 6px; transition: all 0.15s;
}
.pub-sub-link:hover { color: #fff; text-decoration: none; padding-left: 4px; }
.pub-sub-link.active {
  color: #1bdbe0; font-weight: 700;
  text-shadow: 0 0 12px rgba(27,219,224,0.4);
}
.pub-sub-link i { font-size: 0.82rem; flex-shrink: 0; }

.sub-badge {
  background: linear-gradient(135deg, rgba(27,219,224,0.25), rgba(27,219,224,0.1));
  color: #1bdbe0; padding: 1px 7px; border-radius: 8px;
  font-size: 0.64rem; font-weight: 800; margin-left: auto;
  border: 1px solid rgba(27,219,224,0.25);
}
.test-link i { color: #ff8c5a !important; filter: drop-shadow(0 0 4px rgba(255,107,53,0.4)); }
.test-link:hover { color: #ff8c5a !important; }

/* Sidebar footer */
.pub-sidebar-footer {
  padding: 14px 16px 20px;
  margin: 8px 10px 0;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  display: flex; flex-direction: column; gap: 3px;
}
.pub-footer-link {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 8px;
  font-size: 0.79rem; color: rgba(255,255,255,0.65); text-decoration: none; transition: all 0.18s;
}
.pub-footer-link:hover {
  background: rgba(27,219,224,0.08);
  color: #1bdbe0; text-decoration: none;
  padding-left: 14px;
}

/* ===== MAIN CONTENT ===== */
.pub-main {
  margin-left: 280px;
  flex: 1;
  min-width: 0;
  min-height: calc(100vh - 56px);
}
.pub-main-inner { padding: 28px 32px; }

/* ===== HOME PAGE ===== */
.home-hero {
  background: linear-gradient(135deg, #132248 0%, #1e3060 60%, #1e4070 100%);
  border-radius: 16px; padding: 40px 44px; color: #fff; margin-bottom: 28px;
  position: relative; overflow: hidden;
}
.home-hero::before {
  content: ''; position: absolute; top: -80px; right: -80px;
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(27,219,224,0.1) 0%, transparent 70%);
  pointer-events: none;
}
.home-hero::after {
  content: ''; position: absolute; bottom: -40px; left: 200px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(255,107,53,0.07) 0%, transparent 70%);
  pointer-events: none;
}
.home-hero-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(27,219,224,0.15); border: 1px solid rgba(27,219,224,0.3);
  color: #1bdbe0; padding: 5px 14px; border-radius: 20px;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.5px; margin-bottom: 16px;
}
.home-hero h1 { font-size: 1.9rem; font-weight: 800; margin: 0 0 10px; line-height: 1.25; }
.home-hero p { color: rgba(255,255,255,0.65); font-size: 1rem; margin-bottom: 28px; line-height: 1.6; max-width: 560px; }
.home-stats { display: flex; gap: 28px; flex-wrap: wrap; }
.home-stat { text-align: center; }
.home-stat .num { font-size: 2rem; font-weight: 800; color: #1bdbe0; line-height: 1; }
.home-stat .lbl { font-size: 0.72rem; color: rgba(255,255,255,0.45); text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }

/* ===== STAT CARDS ===== */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  border-radius: 16px;
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 30px rgba(0,0,0,0.15); }
.stat-card::after {
  content: '';
  position: absolute; right: -20px; top: -20px;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  pointer-events: none;
}

.stat-card-teal  { background: linear-gradient(135deg, #0fa3b1 0%, #1bdbe0 100%); }
.stat-card-blue  { background: linear-gradient(135deg, #1a56db 0%, #3b82f6 100%); }
.stat-card-orange{ background: linear-gradient(135deg, #d05a0a 0%, #f97316 100%); }
.stat-card-purple{ background: linear-gradient(135deg, #6d28d9 0%, #8b5cf6 100%); }

.stat-card-icon {
  width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.stat-card-body { flex: 1; min-width: 0; }
.stat-card-num {
  font-size: 2rem; font-weight: 800; color: #fff;
  line-height: 1; margin-bottom: 4px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.stat-card-label {
  font-size: 0.82rem; font-weight: 700; color: rgba(255,255,255,0.9);
  margin-bottom: 5px; letter-spacing: 0.3px;
}
.stat-card-sub {
  font-size: 0.72rem; color: rgba(255,255,255,0.7);
  display: flex; align-items: center; gap: 4px;
}

/* ===== STATS ROW (top topics + results) ===== */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}
.stats-block {
  background: #fff;
  border-radius: 14px;
  padding: 22px 22px 10px;
  box-shadow: 0 2px 14px rgba(0,0,0,0.06);
}

/* Top topics */
.top-topic-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px; border-radius: 10px;
  text-decoration: none; color: inherit;
  transition: background 0.15s;
  margin-bottom: 4px;
}
.top-topic-item:hover { background: #f8f9ff; text-decoration: none; color: inherit; }
.top-topic-rank {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 800; color: #fff;
}
.rank-1 { background: linear-gradient(135deg, #f59e0b, #fcd34d); }
.rank-2 { background: linear-gradient(135deg, #6b7280, #9ca3af); }
.rank-3 { background: linear-gradient(135deg, #92400e, #d97706); }
.rank-4, .rank-5 { background: linear-gradient(135deg, #1bdbe0, #0fa3b1); }
.top-topic-info { flex: 1; min-width: 0; }
.top-topic-title { font-size: 0.83rem; font-weight: 600; color: #1a2744; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-topic-meta  { font-size: 0.72rem; color: #8a9bb0; margin-top: 2px; }
.top-topic-views { font-size: 0.75rem; color: #8a9bb0; white-space: nowrap; display: flex; align-items: center; gap: 3px; }

/* Recent results */
.result-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px; border-radius: 10px;
  margin-bottom: 4px; transition: background 0.15s;
}
.result-item:hover { background: #f8f9ff; }
.result-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.result-success { background: #d1fae5; color: #059669; }
.result-warning  { background: #fef3c7; color: #d97706; }
.result-danger   { background: #fee2e2; color: #dc2626; }
.result-info     { flex: 1; min-width: 0; }
.result-name     { font-size: 0.84rem; font-weight: 600; color: #1a2744; }
.result-topic    { font-size: 0.72rem; color: #8a9bb0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-score    { font-size: 0.9rem; font-weight: 800; flex-shrink: 0; }
.result-score-success { color: #059669; }
.result-score-warning  { color: #d97706; }
.result-score-danger   { color: #dc2626; }

@media (max-width: 1200px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .stats-row  { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .stat-cards { grid-template-columns: 1fr 1fr; }
}

/* Class cards */
.section-title {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.5px; color: #8a9bb0; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: #e9ecef; }

.class-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 28px; }
.class-card {
  background: #fff; border-radius: 12px; padding: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06); transition: all 0.2s;
  text-decoration: none; color: inherit; display: block;
  border: 2px solid transparent;
}
.class-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.1); text-decoration: none; color: inherit; border-color: #1bdbe0; }
.class-card.has-content { border-color: rgba(27,219,224,0.2); }
.class-card-icon {
  width: 44px; height: 44px; border-radius: 10px; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  background: linear-gradient(135deg, rgba(27,219,224,0.12), rgba(27,219,224,0.06));
  color: #1bdbe0;
}
.class-card.no-content .class-card-icon { background: #f8f9fa; color: #adb5bd; }
.class-card-name { font-size: 0.95rem; font-weight: 700; color: #1a2744; margin-bottom: 4px; }
.class-card.no-content .class-card-name { color: #adb5bd; }
.class-card-count { font-size: 0.78rem; color: #8a9bb0; }
.class-card.no-content .class-card-count { color: #ced4da; }

/* Recent topics */
.topic-list-item {
  display: flex; align-items: center; gap: 14px;
  background: #fff; border-radius: 10px; padding: 14px 18px;
  margin-bottom: 10px; text-decoration: none; color: inherit;
  box-shadow: 0 1px 6px rgba(0,0,0,0.05); transition: all 0.2s;
  border-left: 4px solid transparent;
}
.topic-list-item:hover { transform: translateX(3px); border-left-color: #1bdbe0; text-decoration: none; color: inherit; box-shadow: 0 3px 12px rgba(0,0,0,0.1); }
.topic-list-num {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, #1bdbe0, #0fa3b1);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700; color: #fff;
}
.topic-list-info { flex: 1; min-width: 0; }
.topic-list-title { font-size: 0.88rem; font-weight: 600; color: #1a2744; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic-list-meta { font-size: 0.74rem; color: #8a9bb0; }
.topic-list-badges { display: flex; gap: 6px; flex-shrink: 0; }
.topic-badge-sm { font-size: 0.68rem; padding: 3px 8px; border-radius: 8px; font-weight: 600; }
.topic-badge-q  { background: rgba(255,107,53,0.1); color: #e8521e; }
.topic-badge-m  { background: rgba(27,219,224,0.1); color: #0fa3b1; }

/* ===== MOBILE ===== */
@media (max-width: 991px) {
  .pub-sidebar { left: -280px; top: 0; height: 100vh; padding-top: 56px; }
  .pub-sidebar.open { left: 0; }
  .pub-main { margin-left: 0; }
  .topnav-toggle { display: flex; }
  .pub-main-inner { padding: 20px 16px; }
  .home-hero { padding: 28px 24px; }
  .home-hero h1 { font-size: 1.4rem; }
}
