/* =============================================
   IT Learning Hub — Shared Stylesheet
   ============================================= */

:root {
  --primary:       #0f4c81;
  --primary-light: #1a6bb5;
  --primary-dark:  #0a3358;
  --accent:        #00b4d8;
  --accent2:       #48cae4;
  --bg:            #f0f4f8;
  --bg-card:       #ffffff;
  --sidebar-bg:    #0f2942;
  --sidebar-text:  #c8dff5;
  --sidebar-hover: #1a4a72;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --border:        #dde3ec;
  --success:       #22c55e;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --radius:        10px;
  --shadow:        0 2px 12px rgba(0,0,0,0.08);
  --shadow-md:     0 4px 24px rgba(0,0,0,0.13);
  --sidebar-width: 270px;
  --header-h:      62px;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
ul { list-style: none; }

/* ---- Header ---- */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}
.site-header .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}
.site-header .brand-icon {
  font-size: 1.6rem;
}
.site-header .brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
}
.site-header .brand-name span {
  color: var(--accent);
}
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.header-search {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 24px;
  padding: 6px 14px;
  gap: 8px;
}
.header-search input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 0.9rem;
  width: 200px;
}
.header-search input::placeholder { color: rgba(255,255,255,0.5); }
.header-search .search-icon { color: rgba(255,255,255,0.6); font-size: 1rem; }
.hamburger {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
}

/* ---- Layout ---- */
.layout {
  display: flex;
  padding-top: var(--header-h);
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  min-height: calc(100vh - var(--header-h));
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 900;
  transition: transform 0.3s ease;
  padding-bottom: 40px;
}
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.sidebar-section {
  padding: 18px 0 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.sidebar-section:last-child { border-bottom: none; }

.sidebar-cat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  cursor: pointer;
  color: #fff;
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 6px;
  margin: 0 8px;
  transition: background 0.2s;
  user-select: none;
}
.sidebar-cat-header:hover { background: var(--sidebar-hover); }
.sidebar-cat-header .cat-icon { font-size: 1.1rem; }
.sidebar-cat-header .cat-chevron {
  margin-left: auto;
  font-size: 0.8rem;
  transition: transform 0.25s;
  color: var(--sidebar-text);
}
.sidebar-cat-header.open .cat-chevron { transform: rotate(90deg); }

.sidebar-sub {
  display: none;
  padding: 4px 0 8px 0;
}
.sidebar-sub.open { display: block; }

.sidebar-subcat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 18px 7px 42px;
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 0.88rem;
  border-radius: 6px;
  margin: 0 8px;
  transition: background 0.2s, color 0.2s;
}
.sidebar-subcat:hover, .sidebar-subcat.active {
  background: var(--sidebar-hover);
  color: #fff;
}
.sidebar-subcat .sub-icon { font-size: 0.85rem; }
.sidebar-subcat .sub-chevron {
  margin-left: auto;
  font-size: 0.75rem;
  transition: transform 0.25s;
  opacity: 0.6;
}
.sidebar-subcat.open .sub-chevron { transform: rotate(90deg); }

.sidebar-topics {
  display: none;
  padding: 2px 0 4px 0;
}
.sidebar-topics.open { display: block; }

.sidebar-topic {
  display: block;
  padding: 5px 18px 5px 60px;
  color: rgba(200,223,245,0.75);
  font-size: 0.82rem;
  border-radius: 4px;
  margin: 0 8px;
  transition: background 0.2s, color 0.2s;
  text-decoration: none;
}
.sidebar-topic:hover, .sidebar-topic.active {
  background: rgba(255,255,255,0.06);
  color: #fff;
  text-decoration: none;
}

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 36px 40px;
  max-width: 980px;
}

/* ---- Breadcrumb ---- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--primary-light); }
.breadcrumb .sep { color: var(--border); }

/* ---- Page Title ---- */
.page-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary-dark);
  margin-bottom: 8px;
  line-height: 1.2;
}
.page-subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 32px;
}

/* ---- Category Cards (Home) ---- */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 22px;
  margin-top: 8px;
}
.cat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  border-left: 5px solid var(--primary);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  text-decoration: none;
  display: block;
  color: var(--text);
}
.cat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  color: var(--text);
}
.cat-card .cat-emoji { font-size: 2.2rem; margin-bottom: 12px; display: block; }
.cat-card h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; color: var(--primary-dark); }
.cat-card p { font-size: 0.87rem; color: var(--text-muted); margin-bottom: 14px; }
.cat-card .cat-meta {
  display: flex;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.cat-card .meta-badge {
  background: var(--bg);
  border-radius: 20px;
  padding: 2px 10px;
  font-weight: 600;
}

/* Category card color accents */
.cat-card.c1 { border-left-color: #0f4c81; }
.cat-card.c2 { border-left-color: #7c3aed; }
.cat-card.c3 { border-left-color: #0891b2; }
.cat-card.c4 { border-left-color: #16a34a; }
.cat-card.c5 { border-left-color: #dc2626; }
.cat-card.c6 { border-left-color: #d97706; }
.cat-card.c7 { border-left-color: #0e7490; }
.cat-card.c8 { border-left-color: #9333ea; }

/* ---- Sub-category listing ---- */
.subcat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 36px;
}
.subcat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  border-top: 3px solid var(--accent);
  display: block;
  color: var(--text);
  transition: transform 0.2s, box-shadow 0.2s;
}
.subcat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  color: var(--text);
}
.subcat-card h3 { font-size: 0.97rem; font-weight: 700; margin-bottom: 4px; }
.subcat-card p { font-size: 0.82rem; color: var(--text-muted); }
.subcat-card .q-count { font-size: 0.78rem; color: var(--accent); font-weight: 600; margin-top: 8px; }

/* ---- Q&A Accordion ---- */
.qa-section-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 28px 0 14px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.qa-section-title::after {
  content: '';
  flex: 1;
  height: 2px;
  background: var(--border);
  border-radius: 2px;
}

.qa-list { display: flex; flex-direction: column; gap: 10px; }

.qa-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: box-shadow 0.2s;
}
.qa-item:hover { box-shadow: var(--shadow-md); }

.qa-question {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 0.97rem;
  color: var(--primary-dark);
  transition: background 0.15s;
}
.qa-question:hover { background: #f8fafc; }
.qa-question .q-badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 4px;
  padding: 2px 7px;
  flex-shrink: 0;
}
.qa-question .q-text { flex: 1; }
.qa-question .q-chevron {
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: transform 0.25s;
  flex-shrink: 0;
}
.qa-item.open .q-chevron { transform: rotate(180deg); }
.qa-item.open .qa-question { background: #f0f6ff; border-bottom: 1px solid var(--border); }

.qa-answer {
  display: none;
  padding: 18px 20px 18px 52px;
  font-size: 0.93rem;
  color: var(--text);
  line-height: 1.75;
  background: #fafcff;
}
.qa-item.open .qa-answer { display: block; }
.qa-answer p { margin-bottom: 10px; }
.qa-answer p:last-child { margin-bottom: 0; }
.qa-answer code {
  background: #eef2ff;
  color: #4338ca;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.88em;
}
.qa-answer pre {
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  font-size: 0.85rem;
  margin: 12px 0;
  font-family: 'Consolas', 'Courier New', monospace;
}
.qa-answer ul { margin: 8px 0 8px 18px; list-style: disc; }
.qa-answer ul li { margin-bottom: 4px; }
.qa-answer .tip {
  background: #ecfdf5;
  border-left: 4px solid #22c55e;
  border-radius: 0 8px 8px 0;
  padding: 10px 14px;
  margin: 12px 0;
  font-size: 0.88rem;
  color: #166534;
}
.qa-answer .note {
  background: #fffbeb;
  border-left: 4px solid #f59e0b;
  border-radius: 0 8px 8px 0;
  padding: 10px 14px;
  margin: 12px 0;
  font-size: 0.88rem;
  color: #78350f;
}

/* ---- Difficulty Tags ---- */
.diff-tag {
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 20px;
  padding: 2px 9px;
  flex-shrink: 0;
}
.diff-beginner  { background: #dcfce7; color: #166534; }
.diff-intermediate { background: #fef3c7; color: #78350f; }
.diff-advanced  { background: #fee2e2; color: #991b1b; }

/* ---- Search Results ---- */
.search-results { margin-top: 8px; }
.search-result-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  margin-bottom: 12px;
  border-left: 4px solid var(--accent);
}
.search-result-item h4 { font-size: 0.97rem; font-weight: 700; margin-bottom: 4px; color: var(--primary-dark); }
.search-result-item p { font-size: 0.85rem; color: var(--text-muted); }
.search-result-item .result-path { font-size: 0.78rem; color: var(--accent); margin-top: 6px; }
.no-results { text-align: center; padding: 60px 20px; color: var(--text-muted); font-size: 1rem; }

/* ---- Hero (Home) ---- */
.hero {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  border-radius: 14px;
  padding: 44px 40px;
  color: #fff;
  margin-bottom: 36px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: '🌐';
  position: absolute;
  right: 30px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 7rem;
  opacity: 0.12;
}
.hero h1 { font-size: 2rem; font-weight: 800; margin-bottom: 10px; }
.hero p { font-size: 1rem; opacity: 0.88; max-width: 540px; margin-bottom: 20px; }
.hero-stats {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}
.hero-stat { text-align: center; }
.hero-stat .num { font-size: 1.7rem; font-weight: 800; color: var(--accent); }
.hero-stat .lbl { font-size: 0.78rem; opacity: 0.8; letter-spacing: 0.04em; }

/* ---- Section Heading ---- */
.section-heading {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- Footer ---- */
.site-footer {
  background: var(--primary-dark);
  color: rgba(255,255,255,0.55);
  text-align: center;
  padding: 20px;
  font-size: 0.82rem;
  margin-left: var(--sidebar-width);
}

/* ---- Highlight (search) ---- */
mark { background: #fde68a; color: #78350f; border-radius: 2px; padding: 0 2px; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  :root { --sidebar-width: 0px; }
  .sidebar {
    transform: translateX(-270px);
    width: 270px;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
  }
  .hamburger { display: block; }
  .main-content { margin-left: 0; padding: 24px 18px; }
  .site-footer { margin-left: 0; }
  .header-search input { width: 130px; }
  .hero { padding: 28px 22px; }
  .hero h1 { font-size: 1.4rem; }
  .cat-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .cat-grid { grid-template-columns: 1fr; }
  .subcat-grid { grid-template-columns: 1fr; }
  .header-search { display: none; }
}

/* ---- Sidebar overlay (mobile) ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 850;
}
.sidebar-overlay.open { display: block; }
