/* ============================================================
   AMEU: fit every screen, from small phones to wide desktops.
   Loaded after style.css and the header's own styles, so the
   rules here win. Public site first, admin panel at the end.
   ============================================================ */

/* ---- Safety net for content typed into the admin (long links, big images, embeds) ---- */
img, video, iframe, embed, object { max-width: 100%; }
img { height: auto; }
.main-content, .page-hero h1, .news-card-body h3, .college-card-body h3 { overflow-wrap: anywhere; }
.data-table { min-width: 100%; }
/* Grid columns may shrink below their content instead of pushing the page wider */
[style*="display:grid"] > *, [style*="display: grid"] > *, .responsive-grid > * { min-width: 0; }
.logo-text-block { min-width: 0; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---- Top bar: links scroll sideways instead of pushing the page wider ---- */
.top-bar-inner { height: auto; min-height: 38px; }
.top-bar-left { flex: none; }
.top-bar-right {
  min-width: 0; margin-left: auto; overflow-x: auto; scrollbar-width: none;
  white-space: nowrap; gap: 18px; padding: 6px 0;
}
.top-bar-right::-webkit-scrollbar { display: none; }

/* ---- An old style.css rule (.nav-item > a) turned plain-link menu items dark
        green on the green bar, so "News & Events" was almost invisible ---- */
.nav-bar .nav-item > a.nav-link { display: flex; padding: 0 15px; border-radius: 0; color: rgba(255,255,255,.92); }
.nav-bar .nav-item:hover > a.nav-link,
.nav-bar .nav-item.active > a.nav-link { background: rgba(0,0,0,.18); color: #fff; }
.nav-live .nav-live-dot { margin-left: 2px; }
.nav-apply a { white-space: nowrap; }

/* ---- Menus near the right edge open leftwards so they stay on screen ---- */
.mega-wrap.mega-right { left: auto; right: 0; }
.mega-wrap { max-width: calc(100vw - 24px); }
.nav-item:focus-within .mega-wrap { display: block; }   /* keyboard users */

/* The old drawer rules in style.css clash with the header's drawer: reset them */
.mobile-nav { padding: 0; right: auto; }
.mobile-nav a.mob-link { display: flex; align-items: center; padding: 12px 24px; font-size: 14px; color: rgba(255,255,255,.85); border-bottom: 1px solid rgba(255,255,255,.07); }
.mobile-nav a.mob-link .lv-badge { margin-left: auto; }
.mob-header img { filter: none; background: #fff; border-radius: 50%; padding: 2px; }  /* the white-out filter left a blank disc */
.mobile-nav a.mob-apply { display: flex; padding: 13px; font-size: 14px; color: var(--green-dark); border-bottom: 0; }

/* ---- Common laptop widths (1366/1440): tighten the menu so it fits on one line ---- */
@media (max-width: 1440px) {
  .nav-bar-inner { padding: 0 16px; }
  .nav-bar .nav-item > .nav-link, .nav-bar .nav-item > a.nav-link { padding: 0 11px; }
  .nav-apply { padding-left: 8px; }
  .nav-apply a { padding: 9px 16px; }
}

/* ---- Below that the full menu no longer fits, so switch to the drawer ---- */
@media (max-width: 1200px) {
  .nav-bar-inner .nav-item, .nav-apply { display: none; }
  .nav-bar-inner { min-height: 50px; padding: 0 12px; }
  .nav-hamburger { display: flex; margin-left: auto; padding: 0 12px; }
}

@media (max-width: 1024px) {
  .top-bar-left { display: none; }
  .top-bar-inner { padding: 0 16px; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 28px; }
  .main-layout { grid-template-columns: 240px minmax(0, 1fr); gap: 24px; }
}

/* ---- Tablets and phones ---- */
@media (max-width: 860px) {
  .brand-bar-inner { flex-wrap: wrap; padding: 12px 16px; gap: 12px; }
  .brand-actions { flex: 1 1 100%; }
  .search-box { flex: 1 1 auto; min-width: 0; }
  .search-box input { width: 100%; min-width: 0; }

  /* Content first, the sidebar widgets after it */
  .main-layout { grid-template-columns: minmax(0, 1fr); padding: 28px 0; }
  .main-content { order: 1; }
  .sidebar { order: 2; position: static; }

  /* Two-column layouts written inline in page files stack into one column */
  [style*="grid-template-columns:3fr 2fr"],
  [style*="grid-template-columns:2fr 1fr"],
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns:1fr 2fr"],
  [style*="grid-template-columns:1fr 1fr 1fr"],
  [style*="grid-template-columns:repeat(3"],
  [style*="grid-template-columns:repeat(4"] { grid-template-columns: minmax(0, 1fr) !important; }
}

@media (max-width: 768px) {
  .container { padding-left: 16px; padding-right: 16px; }
  .logo-main { font-size: 16px; line-height: 1.25; }
  .logo-link { gap: 12px; min-width: 0; }
  .apply-btn-top { padding: 9px 16px; font-size: 13px; }

  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-item:nth-child(2) { border-right: 0; }
  .stat-number { font-size: 1.6rem; }

  .welcome-section { padding: 24px 20px; }
  .welcome-section h2 { font-size: 1.5rem; }
  .section-header { margin-bottom: 22px; }
  .page-hero { padding: 36px 0; }
  .breadcrumb { flex-wrap: wrap; }
  .colleges-grid, .news-grid { grid-template-columns: minmax(0, 1fr); }
  .news-card-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; }

  /* Bigger tap targets */
  .college-trigger { padding: 15px 18px; }
  .dept-trigger { padding: 12px 18px 12px 30px; }
  .btn { min-height: 40px; }

  /* Wide tables scroll inside their box instead of the whole page */
  .data-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }

  .footer-grid { grid-template-columns: minmax(0, 1fr); }
  .footer-bottom { justify-content: center; text-align: center; }
  .course-popup { width: calc(100vw - 24px); max-height: 85vh; }

  /* Stops iPhones zooming in when a form field is tapped */
  input, select, textarea, .form-control { font-size: 16px; }
}

@media (max-width: 480px) {
  .logo-sub { font-size: 10.5px; letter-spacing: .06em; }
  .logo-main { font-size: 15px; }
  .brand-actions { flex-wrap: wrap; gap: 8px; }
  .search-box { flex: 1 1 150px; }
  .apply-btn-top { flex: 0 1 auto; justify-content: center; padding: 9px 14px; font-size: 12.5px; }
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:repeat(2"] { grid-template-columns: minmax(0, 1fr) !important; }
  [style*="margin-left:12px"].btn { margin: 10px 0 0 !important; }
  /* Inline "auto-fit, minmax(300px…)" grids: one column on phones */
  [style*="minmax(3"], [style*="minmax(2"] { grid-template-columns: minmax(0, 1fr) !important; }
}

/* Very small phones (320–380px) */
@media (max-width: 380px) {
  .logo-link img { width: 46px; height: 46px; }
  .logo-main { font-size: 14px; }
  .logo-sub { font-size: 9.5px; letter-spacing: .03em; }
  .container { padding-left: 12px; padding-right: 12px; }
  .lv-count span { min-width: 44px; }
}

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

/* ============================================================
   ADMIN PANEL: on phones the menu becomes a slide-in drawer
   ============================================================ */
.admin-menu-btn { display: none; }
.admin-main { min-width: 0; }
.admin-card-body { overflow-x: auto; }
.admin-sidebar-overlay { display: none; }

@media (max-width: 900px) {
  .admin-layout { grid-template-columns: minmax(0, 1fr); }
  .admin-sidebar {
    display: block; position: fixed; top: 0; bottom: 0; left: 0; z-index: 9001;
    width: min(280px, 85vw); overflow-y: auto;
    transform: translateX(-100%); transition: transform .25s ease;
  }
  .admin-sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .admin-sidebar-overlay.open { display: block; position: fixed; inset: 0; z-index: 9000; background: rgba(0,0,0,.5); }
  .admin-menu-btn {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 40px; height: 40px; margin-right: 10px; border-radius: 8px;
    border: 1.5px solid var(--gray-200); background: var(--white); color: var(--green-dark); font-size: 17px; cursor: pointer;
  }
  .admin-topbar { position: sticky; top: 0; z-index: 50; flex-wrap: wrap; gap: 8px; padding: 10px 14px; justify-content: flex-start; }
  .admin-topbar h1 { flex: 1; min-width: 0; font-size: 17px !important; }
  .admin-topbar-actions { gap: 8px !important; }
  .admin-topbar-actions > a:not(.btn) { display: none; }
  .admin-content { padding: 16px 12px; }
  .admin-card-header { flex-wrap: wrap; gap: 10px; padding: 14px 16px; }
  .admin-card-body { padding: 16px; }
  .form-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
}
