/*
 * hims-responsive.css — whole-software responsive layer (entry, view, edit pages).
 * Loaded last by Layouts/default.ctp (and the other screen layouts).
 * Rules apply ONLY below 992px wide, so desktop screens and every print are unchanged.
 * Helper classes (hr-*) are added by js/hims-responsive.js; nothing inside a table is moved.
 * Opt out: add data-hims-noresp to any element (it and everything inside are skipped by the JS).
 */

@media screen and (max-width: 991px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  body { -webkit-text-size-adjust: 100%; }

  /* The page itself never scrolls sideways: content boxes shrink to the screen. */
  #container, #content, .maincontent { max-width: 100% !important; box-sizing: border-box; }
  .maincontent :is(div, form, fieldset, section, article, ul, ol, p, h1, h2, h3, h4, h5, h6, label, span.input, .panel, .well, .modal-dialog):not(.rowedit):not(.rowedit *):not(.dataTables_scrollHeadInner):not(.dataTables_scrollHeadInner *) {
    max-width: 100%;
  }
  .maincontent :is(img, video, canvas, iframe, embed, object):not([data-hims-noresp]) { max-width: 100%; height: auto; }
  .maincontent :is(input:not([type=checkbox]):not([type=radio]):not([type=button]):not([type=submit]):not([type=reset]):not([type=image]), select, textarea) {
    max-width: 100%;
    box-sizing: border-box;
  }
  .maincontent :is(pre, code) { white-space: pre-wrap; word-break: break-word; }

  /* Wide tables (marked hr-wide by the JS): scroll sideways inside their own box. */
  table.hr-wide { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .hr-scroll { max-width: 100%; overflow-x: auto !important; -webkit-overflow-scrolling: touch; }

  /* Boxes with a fixed desktop width (marked hr-fit by the JS). */
  .hr-fit { width: auto !important; max-width: 100% !important; min-width: 0 !important; flex-shrink: 1 !important; }
  .hr-wrap.hr-wrap { flex-wrap: wrap !important; row-gap: 4px; }
  .hr-wrap > * { min-width: 0; max-width: 100%; }
  .hr-row0.hr-row0 { margin-left: 0 !important; margin-right: 0 !important; }
  div.hr-scroll.hr-scroll, table.hr-wide.hr-wide { overflow-x: auto !important; }

  /* Long button captions wrap inside narrow columns instead of running off the screen. */
  .maincontent :is(.btn, button, a.action-btn) { white-space: normal; max-width: 100%; height: auto; }
  .hr-fit-left { margin-left: 0 !important; margin-right: 0 !important; left: auto !important; }

  /* Bootstrap modals and jQuery UI dialogs fit the screen. */
  .modal-dialog { width: auto !important; max-width: calc(100vw - 16px) !important; margin: 8px auto !important; }
  .ui-dialog { max-width: calc(100vw - 8px) !important; left: 4px !important; }
  .ui-dialog .ui-dialog-content { max-width: 100%; overflow: auto; }

  /* Long words, ids and e-mails wrap instead of pushing the page wide. */
  .maincontent { overflow-wrap: anywhere; }
  .maincontent table { overflow-wrap: normal; }

  /* Buttons rows wrap. */
  .maincontent .btn-group, .maincontent .btn-toolbar { flex-wrap: wrap; }
  .maincontent .nav-tabs, .maincontent .nav-pills { display: flex; flex-wrap: wrap; }
  .maincontent .nav-tabs > li, .maincontent .nav-pills > li { float: none; }
}

/* Phones */
@media screen and (max-width: 767px) {
  /* Fixed header becomes part of the page so it never covers a form when it wraps to 2-3 lines. */
  .rowedit { position: sticky !important; top: 0; left: 0; margin-left: 0 !important; margin-right: 0 !important; }
  .rowedit + .hr-head-spacer, .hr-head-spacer { display: none !important; }

  /* Form-layout tables (label | field | label | field): each cell takes a full line, label above field. */
  table.hr-form, table.hr-form > tbody, table.hr-form > thead, table.hr-form > tfoot,
  table.hr-form > tbody > tr, table.hr-form > thead > tr, table.hr-form > tfoot > tr, table.hr-form > tr {
    display: block; width: 100% !important; max-width: 100%;
  }
  table.hr-form > tbody > tr > td, table.hr-form > thead > tr > td, table.hr-form > tfoot > tr > td, table.hr-form > tr > td {
    display: block; width: 100% !important; max-width: 100%; box-sizing: border-box;
    border-left: 0; border-right: 0; text-align: left;
  }
  table.hr-form td.hr-label { padding-bottom: 0 !important; padding-top: 8px !important; font-weight: 600; border-bottom: 0; }
  table.hr-form td.hr-empty { display: none; }
  table.hr-form td :is(input:not([type=checkbox]):not([type=radio]):not([type=button]):not([type=submit]):not([type=reset]):not([type=image]), select, textarea) {
    width: 100% !important;
  }

  /* Rows split into many fixed col-xs-1/2/3 columns (marked hr-xs-tight by the JS) get 2 per line. */
  .maincontent .hr-xs-tight { width: 50% !important; float: left; }

  /* Touch-friendly controls. */
  .maincontent :is(input:not([type=checkbox]):not([type=radio]), select, textarea, .btn) { min-height: 34px; font-size: 16px; }
  .maincontent :is(.btn, button, input[type=button], input[type=submit]) { margin-bottom: 4px; }

  /* Page headings stay readable. */
  .maincontent h1 { font-size: 22px; } .maincontent h2 { font-size: 20px; } .maincontent h3 { font-size: 18px; }

  /* DataTables controls stack. */
  .dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_paginate { float: none !important; text-align: left !important; }
  .dataTables_wrapper .dataTables_filter input { width: 100% !important; margin-left: 0 !important; }
  .dataTables_wrapper .dt-buttons { float: none !important; display: flex; flex-wrap: wrap; gap: 4px; }
}

/* 2026-11-18: dashboard tiles (hospitals/index) on small phones: the 90px icon left 47px for the label, so
   "Pharmacy", "Laboratory", "IPD-Stay" were cut. Smaller icon, label may wrap. Desktop unchanged. */
@media screen and (max-width: 480px) {
  .info-box.action-btn { padding: 0 6px !important; min-height: 74px; }
  .info-box.action-btn .info-box-icon { width: 50px !important; height: 70px !important; line-height: 70px !important; font-size: 30px !important; }
  .info-box.action-btn .info-box-content { margin-left: 50px !important; padding: 6px 2px 6px 6px !important; }
  .info-box.action-btn, .info-box.action-btn a, .info-box.action-btn .info-box-content, .info-box.action-btn .info-box-content span { white-space: normal !important; overflow-wrap: anywhere; }
  .info-box.action-btn .info-box-content { font-size: 12px; line-height: 1.3; }
}

/* 2026-11-18: the header bar (.rowedit) is a centred flex row that never wraps; on a 375px phone it was 507px wide,
   so the hospital name and Task Pending sat off the left edge and Dashboard/language off the right. Wrap it. */
@media screen and (max-width: 767px) {
  .rowedit { flex-wrap: wrap !important; justify-content: center !important; align-items: center; row-gap: 4px; width: 100% !important; max-width: 100vw; box-sizing: border-box; }
  .rowedit > * { flex: 0 1 auto !important; max-width: 100%; min-width: 0; }
}

/* 2026-11-19: the fixed footer bar had no left edge, so on phones it started at the container padding and ran 15px past the screen */
@media (max-width: 767px) {
  footer .hms-footer-bar { left: 0 !important; right: 0 !important; }
}
