/* ============================================================
   EduSphere — Responsive (responsive.css)
   ============================================================ */

/* ---------- ≤ 1200px ---------- */
@media (max-width: 1200px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 30px; }
  .hero-inner { gap: 38px; }
}

/* ---------- ≤ 1024px : tablets ---------- */
@media (max-width: 1024px) {
  :root { --sidebar-w: 250px; }
  .hero-inner { grid-template-columns: 1fr; text-align: center; }
  .hero-sub { margin-left: auto; margin-right: auto; }
  .hero-actions { justify-content: center; }
  .hero-stats { justify-content: center; }
  .hero-visual { max-width: 560px; margin: 0 auto; width: 100%; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .search-box { width: 180px; }
  .hs-minis { grid-template-columns: repeat(2, 1fr); margin-top: -46px; }
  .hs-content { padding: 40px 42px; }
}

/* ---------- ≤ 900px : sidebar collapses ---------- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%);
    box-shadow: 0 0 60px rgba(0, 0, 0, .4);
  }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .sidebar-backdrop {
    position: fixed; inset: 0; z-index: 190;
    background: rgba(10, 12, 30, .55); backdrop-filter: blur(3px);
    opacity: 0; visibility: hidden; transition: var(--tr);
  }
  .sidebar-backdrop.show { opacity: 1; visibility: visible; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 20px 17px 40px; }
  .topbar { padding: 11px 17px; }

  /* public nav → drawer */
  .hamburger { display: inline-flex; margin-left: auto; }
  .mobile-menu { display: none; }
  .mobile-menu.open { display: block; }
  .nav-links {
    position: fixed; top: 0; right: 0; z-index: 350;
    height: 100vh; width: min(310px, 84vw);
    background: var(--card); box-shadow: var(--shadow-lg);
    flex-direction: column; align-items: stretch; gap: 4px; margin: 0;
    padding: 76px 18px 22px; transform: translateX(100%);
    transition: transform .32s cubic-bezier(.4, 0, .2, 1);
    overflow-y: auto;
  }
  .nav-links.open { transform: none; }
  .nav-links a { padding: 13px 16px; font-size: 14.5px; border-radius: 13px; }
  .nav-cta { margin-left: 0; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- ≤ 768px : phones landscape ---------- */
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .hero { padding: 58px 18px 56px; }
  .hero-title { font-size: 32px; }
  .hero-stats { gap: 26px; }
  .hero-card { grid-template-columns: 1fr 1fr; padding: 18px; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 13px; }
  .stat-value { font-size: 21px; }
  .stat-icon { width: 40px; height: 40px; border-radius: 13px; }
  .welcome-banner { padding: 22px; }
  .welcome-banner h3 { font-size: 18px; }
  .footer-grid { grid-template-columns: 1fr; gap: 26px; }
  .section { padding: 48px 17px 0; }
  .page-title small { display: none; }
  .search-box { display: none; }
  .doc-sheet { padding: 26px 20px; }
  .doc-stamp { right: 14px; bottom: 14px; width: 100px; height: 100px; font-size: 10px; }
  .doc-watermark { font-size: 56px; }
  .toast-container { right: 14px; left: 14px; bottom: 14px; }
  .auth-card { padding: 32px 24px; }
  .auth-top-link { padding: 8px 13px; font-size: 12px; }
  .modal { border-radius: 17px; }
  .modal-body { padding: 18px; }
  .hero-slider { height: 340px; border-radius: 19px; margin-top: 18px; }
  .hs-content { padding: 28px 26px; }
  .hs-sub { font-size: 13.5px; margin: 12px 0 18px; }
  .hs-arrow { width: 38px; height: 38px; }
  .hs-arrow.prev { left: 10px; }
  .hs-arrow.next { right: 10px; }
  .hs-minis { padding: 0 17px; gap: 12px; margin-top: -40px; }
  .stats-strip { padding: 0 17px; margin-top: 26px; }
  .stats-strip-card { padding: 22px 18px; }
}

/* ---------- ≤ 480px : phones ---------- */
@media (max-width: 480px) {
  .hero-card { grid-template-columns: 1fr; }
  .hero-mini { min-height: 88px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: 1fr; }
  .hero-actions .btn { width: 100%; }
  .nav-cta .btn { display: none; }
  .table-modern { min-width: 560px; }
  .filter-bar .form-control { min-width: 120px; flex: 1; }
  .pagination { justify-content: center; }
  .hero-slider { height: 388px; }
  .hs-title { font-size: 26px; }
  .hs-minis { grid-template-columns: 1fr 1fr; }
  .hs-minis .hero-mini { min-height: 92px; padding: 14px; }
  .hs-actions .btn { width: 100%; }
  .hs-dots { bottom: 14px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

/* ============================================================
   v5 additions — Design & Templates + full-width safety
   ============================================================ */

/* ---------- never allow horizontal page scroll ----------
   v6 fix: overflow-x: clip (not hidden) on html/body — 'hidden' turned the
   body into a scroll container which silently broke position:sticky/fixed
   for the sidebar & topbar. 'clip' clips overflow WITHOUT creating a
   scroll container. Fixed sidebar in dashboard.css is immune either way. */
html, body { max-width: 100vw; }
@supports (overflow-x: clip) {
  html, body { overflow-x: clip; }
}
@supports not (overflow-x: clip) {
  html { overflow-x: hidden; }
  body { overflow-x: visible; }
}
body { min-width: 0; }
img, svg, video, canvas { max-width: 100%; height: auto; }

/* ---------- ≤ 992px ---------- */
@media (max-width: 992px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .hero-title { font-size: 36px; }
  .section-title { font-size: 26px; }
  /* designer stacks vertically */
  .designer-wrap { flex-direction: column; }
  .designer-panel { width: 100%; position: static; max-height: none; }
  .designer-toolbar { gap: 6px; }
  .designer-toolbar .btn { padding: 6px 10px; font-size: 12px; }
}

/* ---------- ≤ 576px ---------- */
@media (max-width: 576px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .section-title { font-size: 23px; }
  .nav-cta .btn-outline { display: none; }
  .branch-actions { flex-wrap: wrap; }
  /* documents scale to any screen: pinch-zoom friendly */
  .card-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .doc-page { transform-origin: top left; }
  .designer-stage { padding: 12px; }
  .props-grid { grid-template-columns: 1fr; }
  .el-item .el-pos { display: none; }
  .verify-body { padding: 20px 18px; }
  .verify-head h1 { font-size: 17px; }
  .v-meta > div { flex-wrap: wrap; gap: 4px 12px; }
}

/* ---------- document canvases: shrink to container ---------- */
.doc-page, .doc-page * { box-sizing: border-box; }
.doc-el { overflow: visible; }
.doc-table table { table-layout: fixed; word-break: break-word; }

/* ---------- print: exact colours on documents ---------- */
@media print {
  .doc-page { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
