/* ============================================================
   style.css — Cổng Thông Tin & Học Tập Số THPT Cao Bá Quát
   Fully Responsive & Cross-Browser Optimized (PC / Laptop / Tablet / Mobile)
   ============================================================ */

/* ---- CSS Variables ---- */
:root {
  --cbq-blue:    #1e40af;
  --cbq-teal:    #059669;
  --cbq-gold:    #d97706;
  --cbq-red:     #dc2626;
  --cbq-dark:    #0f172a;
  --primary:     #1e40af;
  --orange:      #059669;
  --primary-color: #1e3a8a;
  --secondary-color: #0f172a;
  --dark:        #0f172a;
  --text:        #1e293b;
  --muted:       #64748b;
  --bg:          #f4f6f9;
  --white:       #ffffff;
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --shadow-sm:   0 1px 4px rgba(15, 23, 42, 0.05);
  --shadow-md:   0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg:   0 10px 28px rgba(15, 23, 42, 0.12);
  --transition:  all 0.2s ease;
}

/* ---- Base Reset & Cross-Browser Normalization ---- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  font-family: 'Inter', 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #e2e8f0 0%, #edf2f7 320px, #e8eef5 100%);
  background-attachment: fixed;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  max-width: 100vw;
  margin: 0;
  position: relative;
}

/* ================================================================
   CỔNG THÔNG TIN WRAPPER (KHUNG TRANG ĐỒNG BỘ, GỌN GÀNG TRÊN MÀN HÌNH LỚN)
   ================================================================ */
.cbq-site-shell {
  max-width: 1380px;
  width: 100%;
  overflow-x: hidden;
  margin: 0 auto;
  background-color: #f8fafc;
  box-shadow: 0 0 40px rgba(15, 23, 42, 0.11);
  border-left: 1px solid #cbd5e1;
  border-right: 1px solid #cbd5e1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.cbq-site-shell > main {
  flex: 1 0 auto;
}
.cbq-site-shell .container {
  max-width: 1320px;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}
@media (max-width: 767.98px) {
  .cbq-site-shell .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}

img, svg, video, canvas {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

a {
  transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

/* ---- Polyfill cho các class khoảng cách .5 (tránh mất padding gây tràn chữ khỏi nút) ---- */
.p-1\.5  { padding: 0.375rem !important; }
.p-2\.5  { padding: 0.65rem !important; }
.p-3\.5  { padding: 1.15rem !important; }
.px-1\.5 { padding-left: 0.375rem !important; padding-right: 0.375rem !important; }
.px-2\.5 { padding-left: 0.65rem !important; padding-right: 0.65rem !important; }
.px-3\.5 { padding-left: 1.15rem !important; padding-right: 1.15rem !important; }
.py-0\.5 { padding-top: 0.15rem !important; padding-bottom: 0.15rem !important; }
.py-1\.5 { padding-top: 0.375rem !important; padding-bottom: 0.375rem !important; }
.py-2\.5 { padding-top: 0.625rem !important; padding-bottom: 0.625rem !important; }
.ps-2\.5 { padding-left: 0.65rem !important; }
.pe-2\.5 { padding-right: 0.65rem !important; }
.mt-0\.5 { margin-top: 0.15rem !important; }
.mb-0\.5 { margin-bottom: 0.15rem !important; }
.mb-1\.5 { margin-bottom: 0.375rem !important; }
.mb-2\.5 { margin-bottom: 0.65rem !important; }
.gap-0\.5 { gap: 0.15rem !important; }
.gap-1\.5 { gap: 0.375rem !important; }
.gap-2\.5 { gap: 0.65rem !important; }
.g-2\.5, .gx-2\.5 { --bs-gutter-x: 0.65rem; }
.g-2\.5, .gy-2\.5 { --bs-gutter-y: 0.65rem; }
.min-w-0 { min-width: 0 !important; }

@media (min-width: 768px) {
  .p-md-3\.5 { padding: 1.2rem !important; }
}

/* ---- Chuẩn hóa Nút bấm (Buttons) & Nhãn (Badges) chống tràn chữ trên mọi trình duyệt ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  line-height: 1.35;
  font-weight: 600;
  text-align: center;
  vertical-align: middle;
  max-width: 100%;
  white-space: normal;
  word-wrap: break-word;
}
.btn-sm {
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
}
.badge {
  font-weight: 600;
  letter-spacing: 0.2px;
  line-height: 1.25;
  vertical-align: middle;
  max-width: 100%;
  white-space: normal;
}

/* ---- Neutralize MS Word inline relative wrapper spans ---- */
.question-text span[style*="relative"],
.option-text span[style*="relative"],
.lesson-body span[style*="relative"],
.explanation span[style*="relative"],
.theory-section span[style*="relative"] {
  position: static !important;
  top: auto !important;
  vertical-align: baseline !important;
}

/* ---- Công thức Toán học (MathJax & Image Formulas) ---- */
.math-formula {
  vertical-align: middle !important;
  display: inline-block !important;
  position: static !important;
  margin: 0 4px !important;
  max-width: 100% !important;
  height: auto !important;
}

mjx-container[jax="CHTML"]:not([display="true"]),
mjx-container[jax="SVG"]:not([display="true"]),
.MathJax {
  position: relative;
  top: -0.08em;
}

.question-text img:not(.math-formula):not(.img-illustration), 
.lesson-body img:not(.math-formula):not(.img-illustration),
.option-text img:not(.math-formula):not(.img-illustration),
.explanation img:not(.math-formula):not(.img-illustration) {
  vertical-align: middle;
  position: relative;
  top: -0.06em; 
}

.img-illustration,
.question-text figure img, 
.lesson-body figure img, 
.question-text p.text-center img, 
.lesson-body p.text-center img {
  vertical-align: top !important;
  position: static !important;
  top: auto !important;
  display: block !important;
  margin: 15px auto !important;
  max-width: 100% !important;
  height: auto !important;
}

/* ================================================================
   COURSE & BLOG CARDS
   ================================================================ */
.course-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  height: 100%;
}
.course-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}
.course-icon { font-size: 2.5rem; margin-bottom: 0.85rem; }

.blog-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
  border: 1px solid #e2e8f0;
}
.blog-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.blog-card img { height: 200px; object-fit: cover; width: 100%; }

/* ================================================================
   SECTIONS & CONTAINERS
   ================================================================ */
section { padding: 3rem 0; }

@media (max-width: 767.98px) {
  section { padding: 2rem 0; }
  .container { padding-left: 0.85rem; padding-right: 0.85rem; }
}

/* ================================================================
   LESSON PAGE
   ================================================================ */
.lesson-container { padding-top: 1.5rem; padding-bottom: 2.5rem; }

.theory-section {
  background: var(--white);
  padding: 1.75rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.practice-section {
  position: sticky;
  top: 75px;
}
.iframe-container {
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.iframe-container iframe { width: 100%; border: none; display: block; }

@media (max-width: 991.98px) {
  .practice-section { position: static; margin-top: 1.5rem; }
  .theory-section { padding: 1.2rem; }
  .iframe-container iframe { min-height: 340px; }
}

/* ================================================================
   CODE BLOCKS & FORMS
   ================================================================ */
pre {
  background: var(--dark);
  color: #a3e635;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.65;
}
code { font-family: 'Consolas', 'Monaco', 'Courier New', monospace; }

.form-control, .form-select {
  border-radius: var(--radius-sm);
  border: 1px solid #cbd5e1;
  font-size: 0.9rem;
  transition: var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--cbq-blue);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.12);
}

/* ================================================================
   UTILITY / REUSABLE
   ================================================================ */
.btn-primary-custom {
  background: linear-gradient(135deg, #1e40af, #2563eb);
  color: white !important;
  padding: 0.55rem 1.4rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.88rem;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-primary-custom:hover {
  background: linear-gradient(135deg, #1e3a8a, #1d4ed8);
  transform: translateY(-1px);
  color: white !important;
  box-shadow: 0 4px 12px rgba(30, 64, 175, 0.25);
}

.section-title {
  color: var(--cbq-blue);
  font-weight: 800;
  position: relative;
}

.card-lift { transition: var(--transition); }
.card-lift:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }

/* Thin Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* Accordion */
.accordion-button:not(.collapsed) {
  background: #eff6ff;
  color: var(--cbq-blue);
  font-weight: 700;
}
.accordion-button:focus { box-shadow: none; }
.accordion-item { border-radius: var(--radius-sm) !important; margin-bottom: 0.5rem; }
