/* =====================================================
   Al Qur'an Ul Mubeen — Global Responsive Styles
   Breakpoints: 1200 / 1024 / 900 / 768 / 640 / 480
   ===================================================== */

/* ---------- Shared layout utilities ---------- */
.dash-split {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}
.dash-split-sm {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}
.dash-split-checkout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}
.msg-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 550px;
}
.courses-page-layout {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.courses-page-sidebar {
  width: 220px;
  flex-shrink: 0;
}
.courses-page-main {
  flex: 1;
  min-width: 0;
}
.teacher-profile-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
}
.page-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* Ensure tables never blow out page width */
.dtable-wrap,
.table-responsive,
.card > div[style*="overflow"] {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.dtable, .data-table {
  min-width: 640px;
}

/* Images & media */
img, video, iframe, canvas, svg {
  max-width: 100%;
  height: auto;
}

/* Prevent long words from overflowing */
.book-title, .course-card h3, .dpost-text, .dsession-name {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ---------- Large tablets / small desktops ---------- */
@media (max-width: 1200px) {
  .dash-split,
  .dash-split-sm,
  .dash-split-checkout {
    grid-template-columns: 1fr 300px;
  }
  .container { padding: 0 18px; }
}

@media (max-width: 1024px) {
  .dash-split,
  .dash-split-sm,
  .dash-split-checkout,
  .teacher-profile-grid {
    grid-template-columns: 1fr;
  }
  .msg-layout {
    grid-template-columns: 260px 1fr;
  }
  .page-two-col {
    grid-template-columns: 1fr;
  }
  .dstat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .lib-featured-row {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .library-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  .footer-grid {
    grid-template-columns: 1fr 1fr !important;
  }
  .courses-page-sidebar {
    width: 100%;
  }
  .courses-page-sidebar .card {
    position: static !important;
  }
  .features-grid,
  .courses-grid,
  .teachers-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ---------- Tablets ---------- */
@media (max-width: 900px) {
  .msg-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .msg-layout > div:first-child {
    max-height: 280px;
    border-right: none !important;
    border-bottom: 1px solid #E2E8F0;
  }
  .admin-nav-scroll,
  .dpage-actions {
    width: 100%;
  }
  .dpage-header {
    flex-direction: column;
    align-items: stretch !important;
  }
  .dpage-actions {
    justify-content: flex-start;
  }
  .top-notif-panel {
    width: min(340px, calc(100vw - 24px));
    right: -40px;
  }
}

@media (max-width: 768px) {
  .container { padding: 0 14px; }

  /* Navbar */
  .nav-hamburger {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    margin-left: auto;
  }
  .nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 70px;
    left: 0;
    right: 0;
    background: var(--green-dark, #0F3D25);
    padding: 12px 16px 20px;
    gap: 2px;
    z-index: 999;
    border-bottom: 2px solid rgba(201,168,76,0.3);
    max-height: calc(100vh - 70px);
    overflow-y: auto;
  }
  .nav-links.open { display: flex; }
  .nav-links .nav-link {
    width: 100%;
    padding: 12px 14px;
  }
  .nav-links .has-dropdown .dropdown {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    background: rgba(0,0,0,0.15);
    margin: 4px 0 8px 12px;
    display: none;
  }
  .nav-links .has-dropdown.open .dropdown,
  .nav-links .has-dropdown:focus-within .dropdown {
    display: block;
  }
  .nav-right .btn-sm.btn-outline-gold,
  .nav-right .btn-sm.btn-gold {
    display: none;
  }
  .logo-english { display: none; }

  /* Hero */
  .hero { padding: 100px 0 50px; min-height: auto; }
  .hero-title { font-size: 1.85rem !important; }
  .hero-buttons { flex-direction: column; align-items: stretch; }
  .hero-buttons .btn { width: 100%; justify-content: center; }
  .hero-stats { flex-wrap: wrap; justify-content: center; gap: 16px; }

  /* Grids */
  .features-grid,
  .courses-grid,
  .teachers-grid,
  .library-grid,
  .lib-featured-row {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 14px !important;
  }
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
  }
  .stats-grid,
  .stats-row {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Forms */
  .form-card { padding: 24px 18px; margin: 0 8px; }
  .form-card-wide { max-width: 100%; }
  .form-row { grid-template-columns: 1fr !important; }

  /* Community */
  .community-layout {
    grid-template-columns: 1fr !important;
    padding-top: 90px !important;
  }
  .feed-sidebar { display: none !important; }

  /* Classroom */
  .classroom-page { overflow-x: hidden; overflow-y: auto; }
  .classroom-header {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px;
  }
  .classroom-title {
    font-size: 0.92rem;
    width: 100%;
    order: -1;
  }
  .classroom-body {
    grid-template-columns: 1fr !important;
    height: auto !important;
    min-height: 70vh;
  }
  .classroom-main {
    min-height: 50vh;
  }
  .classroom-sidebar {
    height: 360px;
    border-left: none !important;
    border-top: 1px solid rgba(255,255,255,0.1);
  }
  .classroom-toolbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
  }
  .wb-tools {
    flex-wrap: wrap;
  }

  /* Library */
  .lib-page { padding: 28px 14px 48px; }
  .lib-search {
    flex-direction: column;
    align-items: stretch;
  }
  .lib-search input { padding-right: 16px; }
  .lib-search .btn { width: 100%; border-radius: 0 0 10px 10px; }
  .lib-quran-cta { padding: 32px 18px; }
  .lib-quran-btns { flex-direction: column; }
  .lib-quran-btns .btn { width: 100%; justify-content: center; }

  /* Courses public page */
  .courses-page-layout {
    flex-direction: column;
  }
  .courses-page-sidebar {
    width: 100%;
  }

  /* Dashboard extras */
  .dash-user-meta { display: none; }
  .dpage-title { font-size: 1.35rem !important; }
  .admin-subnav {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    padding-bottom: 6px;
    margin-bottom: 16px !important;
  }
  .admin-subnav .dbtn {
    flex-shrink: 0;
  }

  /* Profile cover */
  .dprofile-cover { height: 140px !important; }
  .dprofile-avatar { width: 72px !important; height: 72px !important; }

  /* Hide non-essential topbar bits */
  .dash-breadcrumb span { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---------- Phones ---------- */
@media (max-width: 640px) {
  .library-grid,
  .lib-featured-row,
  .features-grid,
  .courses-grid,
  .teachers-grid {
    grid-template-columns: 1fr 1fr !important;
  }
  .dstat-grid {
    grid-template-columns: 1fr 1fr !important;
  }
  .dstat-grid[style*="repeat(3"] {
    grid-template-columns: 1fr 1fr !important;
  }
  .dash-main { padding: 14px 12px 28px !important; }
  .dcard-header {
    flex-wrap: wrap;
    gap: 10px;
  }
  .dcard-header .dbtn { margin-left: 0 !important; }
  .dsession-item {
    flex-wrap: wrap;
  }
  .dsession-item .dbtn {
    width: 100%;
    justify-content: center;
  }
  .msg-layout > div:first-child {
    max-height: 220px;
  }
  .top-user-menu {
    right: -8px;
    min-width: 200px;
  }
  .notif-wrap .top-notif-panel,
  .top-notif-panel {
    position: fixed;
    left: 12px;
    right: 12px;
    width: auto;
    top: 70px;
  }
  .dayah-arabic { font-size: 1.15rem; }
  .lib-hero h1 { font-size: 1.55rem !important; }
  .lib-hero-ar { font-size: 1.35rem !important; }
  .calligraphy { font-size: 1.6rem; }
}

@media (max-width: 480px) {
  .library-grid,
  .lib-featured-row,
  .features-grid,
  .courses-grid,
  .teachers-grid,
  .stats-grid,
  .stats-row,
  .dstat-grid,
  .dquick-grid {
    grid-template-columns: 1fr !important;
  }
  .hero-title { font-size: 1.5rem !important; }
  .hero-bismillah { font-size: 1.4rem !important; }
  .nav-container { padding: 0 12px; gap: 10px; }
  .logo-icon { width: 38px; height: 38px; font-size: 1.1rem; }
  .dstat-val { font-size: 1.35rem !important; }
  .book-cover { height: 160px !important; }
  .lib-chip { font-size: 0.78rem; padding: 6px 10px; }
  .dbtn-lg { width: 100%; justify-content: center; }
  .dpage-actions .dbtn { flex: 1; justify-content: center; }
  .footer-ayah { font-size: 1.1rem; }
  .form-section { padding: 90px 12px 32px; }
}

/* Landscape phones */
@media (max-height: 500px) and (orientation: landscape) {
  .hero { min-height: auto; padding: 90px 0 40px; }
  .dnav { overflow-y: auto; }
  .classroom-page { height: auto; min-height: 100vh; }
}

/* Touch-friendly targets */
@media (hover: none) and (pointer: coarse) {
  .nav-link,
  .dnav-item,
  .lib-chip,
  .dbtn,
  .btn {
    min-height: 42px;
  }
  .dash-icon-btn,
  .dash-menu-btn {
    min-width: 42px;
    min-height: 42px;
  }
}
