/* iConnect mobile layer: loaded LAST on every page, so it can correct layouts that only break on phones.
   Global safety rules come first, then page-specific fixes grouped by page. Keep every rule inside a
   max-width media query unless it is harmless on desktop too. */

/* ---------- global (all widths) ---------- */
/* fieldsets default to min-width:min-content, which stops grid/flex parents from shrinking below their widest field */
fieldset{min-width:0}
img,video,canvas,iframe{max-width:100%}
dialog{max-width:calc(100vw - 16px)}

/* ---------- global (phones) ---------- */
@media (max-width:640px){
  html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
  /* iOS Safari zooms the page when a focused field's text is under 16px */
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=file]),select,textarea{font-size:16px!important}
  /* long unbroken values (emails, URLs, reference numbers) wrap instead of widening the page */
  /* (table cells are excluded: tables sit in horizontal scrollers and should keep words whole) */
  h1,h2,h3,h4,p,li,dd,label,small{overflow-wrap:break-word}
  pre{white-space:pre-wrap}
}

/* ---------- shared portal bar (portal-bar.js) + academic period bar: small phones (360-400px) ---------- */
@media (max-width:400px){
  .ipb-bar{padding:0 8px!important;gap:6px!important}
  .ipb-brand{font-size:14px!important;gap:6px!important;min-width:0}
  .ipb-brand img{width:26px!important;height:26px!important}
  .ipb-actions{gap:0!important}
  .ipb-icon-btn{width:36px!important;height:36px!important}
  .portal-period-bar label{flex-direction:column!important;align-items:stretch!important;gap:2px!important}
  .portal-period-bar select{padding-right:28px!important}
}

/* ---------- main dashboard (/dashboard.html) ---------- */
@media (max-width:900px){
  /* single column that may shrink below the form's min-content width */
  .faculty-profile-dashboard{grid-template-columns:minmax(0,1fr)!important}
}
@media (max-width:640px){
  .faculty-profile-fields{grid-template-columns:minmax(0,1fr)!important}
  .faculty-profile-dashboard .table-title{flex-wrap:wrap;gap:10px}
  .people-tools{flex-wrap:wrap;width:100%}
  .people-tools input{min-width:0!important;flex:1 1 100%}
  .people-tools select{flex:1 1 auto}
  .panel-head{flex-wrap:wrap;gap:10px}
}

/* ---------- Minor Degree (/minor-degree/dashboard, /minor-degree/public): headers are styled inline ---------- */
@media (max-width:760px){
  .iconnect-brand-block,.iconnect-public-brand{min-height:0!important;padding:10px 14px!important;flex-wrap:wrap!important;gap:10px!important;align-items:center!important}
  .iconnect-brand-content,.iconnect-public-brand>a{gap:10px!important;min-width:0;flex:1 1 220px}
  .iconnect-brand-content img,.iconnect-public-brand img{width:44px!important;height:44px!important;max-width:44px!important;flex:0 0 44px!important}
  .iconnect-brand-copy b,.iconnect-public-brand b{font-size:15px!important}
  .iconnect-brand-copy strong,.iconnect-public-brand strong{font-size:16px!important;white-space:normal}
  .iconnect-brand-copy small,.iconnect-public-brand small{display:none!important}
  .iconnect-brand-actions,.iconnect-public-brand>div{white-space:normal!important;flex-wrap:wrap;gap:8px!important;margin-left:auto}
  .iconnect-brand-actions #who{display:none}
  .iconnect-brand-actions .dashboard-button,.iconnect-public-brand>div>a{padding:8px 12px!important;font-size:14px!important}
}

/* ---------- Requisition (/requisition) ---------- */
@media (max-width:640px){
  #adminTabs{flex-wrap:wrap}
  #adminTabs button{flex:1 1 auto}
}

/* ---------- iMeet (/meetup) ---------- */
@media (max-width:860px){
  .lobby-grid{grid-template-columns:minmax(0,1fr)!important}
  .lobby-card{padding:20px}
  .my-meetings li{flex-wrap:wrap}
  .my-meetings li .acts{flex-wrap:wrap}
}
@media (max-width:400px){
  /* 8 code boxes + dash must fit a ~280px card body; keep digits large (overrides the global 16px rule) */
  .code-boxes{gap:3px!important}
  .code-boxes input{width:29px!important;height:44px!important;font-size:19px!important;padding:0}
}

/* ---------- Attendance Pro (/attendance) ---------- */
@media (max-width:480px){
  header.top{gap:8px}
  header.top .brand{min-width:0;flex:1 1 auto}
  header.top .brand span{min-width:0}
  header.top .brand b{font-size:15px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block}
  header.top .who{flex:none}
  header.top .who a{white-space:nowrap;padding:8px 10px;font-size:13px}
}
