/* ============================================================
   SCHOOL WEBSITE — RESPONSIVE OVERRIDES
   Breakpoints:
     Desktop : 1200px+ (no changes)
     Laptop  : 992px-1199px (spacing only — RESTORE desktop layout)
     Tablet  : 768px-991px (layout stacking)
     Mobile  : 0px-767px (full single column)
   ============================================================ */

/* ---------- LAPTOP (992px - 1199px) ----------
   ONLY spacing reductions.
   Restore desktop multi-column layouts.
   ------------------------------------------------- */
@media (max-width: 1199px) and (min-width: 992px) {
  /* Spacing */
  .hero-text {
    max-width: 90%;
    padding: var(--spacing-2xl) var(--spacing-lg);
    margin-left: var(--spacing-lg);
  }
  .hero-text h1 {
    font-size: 2.5rem;
    max-width: 100%;
  }
  .hero-stats-wrapper {
    margin-top: -48px;
    padding: 0 var(--spacing-lg);
  }
  main {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .hero-swiper .swiper-slide img {
    height: 440px;
  }

  /* === RESTORE DESKTOP LAYOUT === */
  /* Keep main + sidebar in horizontal row */
  main > div[style*="display:flex"],
  main > div[style*="display: flex"] {
    flex-direction: row !important;
  }

  /* Keep sidebar at desktop width */
  main > aside,
  aside[style*="width:300px"] {
    width: 300px !important;
    flex-shrink: 0 !important;
  }

  /* Keep About + Principal in 2 columns (grid div is direct child of section) */
  section > div[style*="grid-template-columns:1fr 1fr"],
  section > div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 1.25rem !important;
  }

  /* Keep Photo + Video gallery in 2 columns (grid is direct child of section) */
  section > div[style*="grid-template-columns:1fr 1fr"],
  section > div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 1.25rem !important;
  }

  /* Keep Events/news in 3 columns */
  section > div[style*="grid-template-columns:repeat(3,1fr)"] {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 1rem !important;
  }

  /* Keep Management committee as 2 columns */
  .management-grid {
    grid-template-columns: 35% 65% !important;
    gap: var(--spacing-xl) !important;
  }

  /* Keep Gallery in 3 columns on index */
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: var(--spacing-sm) !important;
  }

  /* Keep stats as 4 columns */
  .hero-stats-wrapper > section > div {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: var(--spacing-lg) !important;
  }
}

/* ---------- TABLET (768px - 991px) ----------
   Layout stacking where required.
   ------------------------------------------------- */
@media (max-width: 991px) and (min-width: 769px) {
  /* Force main content + sidebar to vertical stack */
  main > div[style*="display:flex"],
  main > div[style*="display: flex"] {
    flex-direction: column !important;
  }

  /* Sidebar below content */
  main > aside,
  aside[style*="width:300px"] {
    width: 100% !important;
    display: block !important;
    flex-shrink: 1 !important;
    margin-top: 0;
  }

  /* Hero */
  .hero-text {
    max-width: 90%;
    padding: var(--spacing-xl);
  }
  .hero-text h1 {
    font-size: 2.25rem;
    max-width: 100%;
  }
  .hero-swiper .swiper-slide img {
    height: 420px;
  }
  .hero-notice-board {
    position: static;
    width: 100%;
    margin-top: var(--spacing-xl);
  }
  .notice-board-widget {
    height: 230px;
  }
  .hero-buttons {
    gap: var(--spacing-md);
  }

  /* Stats: 4 columns -> 2 columns */
  .hero-stats-wrapper > section > div {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--spacing-lg) !important;
  }

  /* About + Principal: keep 2 columns on tablet */
  section > div[style*="grid-template-columns:1fr 1fr"],
  section > div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 1.25rem !important;
  }

  /* Photo + Video gallery: keep 2 columns on tablet */
  section > div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 1.25rem !important;
  }

  /* Events/news: 3 columns -> 2 columns */
  section > div[style*="grid-template-columns:repeat(3,1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--spacing-md) !important;
  }

  /* Management committee: stack */
  .management-grid {
    grid-template-columns: 1fr !important;
    gap: var(--spacing-lg) !important;
  }

  /* Gallery: 3 columns -> 2 columns */
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--spacing-xs) !important;
  }

  /* News images */
  .news-card img {
    height: 160px;
  }
}

/* ---------- MOBILE (0px - 768px) ----------
   Everything stacks to single column.
   ------------------------------------------------- */
@media (max-width: 768px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  main {
    padding: 0.75rem 0.75rem 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  main > div[style*="display:flex"],
  main > div[style*="display: flex"] {
    flex-direction: column !important;
    gap: 1rem !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  main > div[style*="display:flex; gap:1.5rem; align-items:flex-start;"] > div[style*="flex:1; min-width:0;"] {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 1 100% !important;
    min-width: 0 !important;
  }

  main > div[style*="display:flex; gap:1.5rem; align-items:flex-start;"] {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  main > div[style*="display:flex"] > div,
  main > div[style*="display: flex"] > div {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 1 100% !important;
    min-width: 0 !important;
  }

  .container-fluid,
  section,
  section > div,
  .about-card,
  .hero-stats-wrapper,
  .hero-stats-wrapper > section,
  .hero-stats-wrapper > section > div,
  .hero-wrapper,
  .hero-container,
  .hero-notice-board,
  .hero-text,
  .management-section-card,
  .management-grid,
  .committee-column,
  .president-column,
  .committee-members-grid,
  .teacher-card,
  .news-card,
  .gallery-item,
  .principal-photo-col,
  .principal-text-col {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
  }

  .news-grid-home {
    grid-template-columns: 1fr !important;
  }

  section div[style*="grid-template-columns:1fr 1fr"],
  section div[style*="grid-template-columns: 1fr 1fr"],
  section div[style*="grid-template-columns:repeat(2,1fr)"],
  section div[style*="grid-template-columns: repeat(2,1fr)"],
  section div[style*="grid-template-columns:repeat(3,1fr)"],
  section div[style*="grid-template-columns: repeat(3,1fr)"],
  section div[style*="grid-template-columns:repeat(4,1fr)"],
  section div[style*="grid-template-columns: repeat(4,1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  .hero-stats-wrapper > section > div[style*="grid-template-columns:repeat(4,1fr)"],
  .hero-stats-wrapper > section > div[style*="grid-template-columns: repeat(4,1fr)"] {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 0.2rem !important;
    padding: 0.65rem 0.2rem !important;
  }

  .hero-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    overflow: hidden;
  }

  .hero-container {
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden;
  }

  .hero-text {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: auto;
    max-width: 100%;
    margin: 0;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    z-index: 3;
  }

  .hero-text h1 {
    font-size: 1.7rem;
    line-height: 1.2;
    max-width: 100%;
    margin-bottom: 0.4rem;
  }

  .section-header .section-title,
  .section-title {
    font-size: 1rem !important;
    line-height: 1.35 !important;
  }

  .section-header .section-title::before,
  .section-title::before {
    height: 18px !important;
  }

  .hero-text p {
    display: block;
    font-size: 0.9375rem;
    margin-bottom: 0.85rem;
    line-height: 1.55;
  }

  .hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.85rem;
  }

  .hero-meta-item {
    font-size: 0.72rem;
    padding: 4px 8px;
  }

  .hero-buttons {
    gap: 0.5rem;
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
  }

  .btn-hero-primary,
  .btn-hero-outline {
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
    justify-content: center;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.8125rem;
  }

  .hero-swiper .swiper-slide img {
    height: 460px !important;
  }

  .hero-swiper {
    min-height: 320px;
  }

  .hero-overlay {
    background: linear-gradient(
      90deg,
      rgba(10, 35, 74, 0.78) 0%,
      rgba(10, 35, 74, 0.58) 48%,
      rgba(10, 35, 74, 0.25) 100%
    );
  }

  .hero-notice-board {
    position: static;
    width: 100% !important;
    max-width: 100% !important;
    margin: 1rem 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .notice-board-widget {
    width: 100%;
    height: auto;
    min-height: 220px;
    max-height: none;
  }

  .notice-board-body {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .notice-board-body .notice-item {
    width: 100%;
  }

  .hero-stats-wrapper {
    margin-top: 1rem !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .hero-stats-wrapper > section > div {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
    padding: 1rem !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .hero-stats-wrapper > section > div {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 0.2rem !important;
    padding: 0.65rem 0.2rem !important;
  }

  .hero-stats-wrapper .stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.15rem;
    padding: 0;
  }

  .hero-stats-wrapper .stat-icon,
  .hero-stats-wrapper .stat-item .stat-icon {
    width: 26px !important;
    height: 26px !important;
  }

  .hero-stats-wrapper .stat-number {
    font-size: 0.72rem !important;
  }

  .hero-stats-wrapper .stat-label {
    font-size: 0.56rem !important;
    line-height: 1.1 !important;
  }

  .about-principal-grid,
  .principal-message-grid,
  .management-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: var(--spacing-md) !important;
  }

  .about-principal-section .about-card,
  .about-principal-section .about-card-principal,
  .about-principal-section .about-card-school,
  .management-section-card,
  .committee-column,
  .president-column,
  .committee-member-card,
  .teacher-card {
    width: 100%;
    max-width: 100%;
  }

  .about-principal-section .about-card {
    height: auto;
  }

  .about-principal-section .about-card-principal {
    order: 1;
  }

  .about-principal-section .about-card-school {
    order: 2;
  }

  .principal-message-grid .principal-photo-col,
  .principal-message-grid .principal-text-col {
    width: 100%;
    max-width: 100%;
  }

  .principal-message-grid .principal-photo-col {
    order: 1;
  }

  .principal-message-grid .principal-text-col {
    order: 2;
  }

  .principal-text-col .btn-outline-modern {
    align-self: flex-start;
  }

  .management-section-card {
    padding: var(--spacing-lg) var(--spacing-md);
  }

  .president-column {
    order: 1;
    text-align: center;
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border);
  }

  .committee-column {
    order: 2;
  }

  .committee-members-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
  }

  #teachersSwiper.teachers-swiper,
  #studentsSwiper.teachers-swiper {
    overflow: hidden;
    padding: 0 0 1rem;
  }

  #teachersSwiper .swiper-wrapper,
  #studentsSwiper .swiper-wrapper {
    display: flex !important;
    flex-direction: row !important;
    height: auto !important;
  }

  #teachersSwiper .swiper-slide,
  #studentsSwiper .swiper-slide {
    width: 100% !important;
    height: auto !important;
    margin-right: 0 !important;
    display: flex !important;
  }

  #teachersSwiper .teacher-card,
  #studentsSwiper .teacher-card {
    width: 100%;
  }

  #teachersSwiper .swiper-button-prev,
  #teachersSwiper .swiper-button-next,
  #studentsSwiper .swiper-button-prev,
  #studentsSwiper .swiper-button-next {
    display: flex !important;
    width: 38px;
    height: 38px;
  }

  .btn-primary-modern,
  .btn-outline-modern {
    min-height: 44px;
    justify-content: center;
  }

  .news-card img {
    height: 160px;
  }

  .news-date-badge {
    min-width: 55px;
    padding: var(--spacing-xs);
  }

  .teacher-card,
  .teacher-contact,
  .notice-title,
  .justified-text,
  .teacher-name,
  .teacher-designation {
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  main > div[style*="display:flex; gap:1.5rem; align-items:flex-start;"] {
    display: flex !important;
    flex-direction: column !important;
  }

  main > aside,
  aside[style*="width:300px"] {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 1 100% !important;
    margin-top: 1rem !important;
  }

  .site-footer {
    padding: var(--spacing-2xl) 0 0;
    margin-top: var(--spacing-xl);
  }

  .footer-heading {
    font-size: 1rem;
    margin-bottom: var(--spacing-md);
  }

  .footer-link {
    font-size: 0.8125rem;
  }

  .footer-social a {
    width: 36px;
    height: 36px;
  }

  .ticker-bar > div > div:first-child {
    font-size: 0.72rem;
    padding: 3px 6px;
  }

  img {
    max-width: 100%;
    height: auto;
  }
}

/* ---------- SMALL MOBILE (0px - 480px) ----------
   Compact mobile adjustments.
   ------------------------------------------------- */
@media (max-width: 480px) {
  .hero-swiper .swiper-slide img {
    height: 380px !important;
  }
  .hero-text {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    right: auto;
    max-width: 92%;
    margin-left: var(--spacing-sm);
    padding: var(--spacing-lg) var(--spacing-md);
    justify-content: flex-start;
    align-items: flex-start;
  }
  .hero-text h1 {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-xs);
    max-width: 100%;
  }
  .hero-text p {
    display: block;
    font-size: 0.875rem;
  }
  .hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
  }
  .hero-meta-item {
    font-size: 0.68rem;
  }
  .hero-buttons {
    gap: var(--spacing-xs);
    flex-direction: column;
    width: 70%;
  }
  .btn-hero-primary,
  .btn-hero-outline {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.8125rem;
  }
  .hero-notice-board {
    width: 80%;
    max-width: 80%;
    margin-left: auto;
    margin-right: auto;
  }
  .notice-board-widget {
    height: auto;
    min-height: 200px;
    max-height: 280px;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-xs);
  }

  .hero-stats-wrapper {
    padding: 0 var(--spacing-xs) !important;
  }

  .hero-stats-wrapper > section > div {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 0.18rem !important;
    padding: 0.45rem 0.1rem !important;
  }

  .hero-stats-wrapper .stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.12rem;
    padding: 0;
  }

  .hero-stats-wrapper .stat-number {
    font-size: 0.68rem !important;
  }

  .hero-stats-wrapper .stat-label {
    font-size: 0.5rem !important;
    line-height: 1.05 !important;
  }

  .hero-stats-wrapper .stat-icon,
  .hero-stats-wrapper .stat-item .stat-icon {
    width: 24px !important;
    height: 24px !important;
  }

  .hero-container .swiper-button-prev,
  .hero-container .swiper-button-next {
    display: none;
  }
}