/*
 * Touch screens and vertical (portrait) phones (SKILL.md §13, references/ui-layout.md "Touch").
 * Loaded in layout.html after menu.css. Goals: every button, link-in-a-list, field, tab and menu row is at least
 * 44 x 44 px with at least 8 px between neighbours, the main action sits where a thumb reaches it (bottom of the
 * screen), and nothing important is only a tiny icon. Applies on coarse pointers and on narrow screens.
 */
/* groups of buttons: a row that wraps with 8 px gaps on EVERY screen (desktop too) */
.app-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

@media (pointer: coarse), (max-width: 767.98px) {
  .btn, .btn-sm, .btn-lg { min-height: 44px; min-width: 44px; padding: .55rem 1rem; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
  .btn-close { width: 44px; height: 44px; background-size: 1rem; }
  .form-control, .form-select, .input-group-text { min-height: 44px; font-size: 16px; }          /* 16 px: iOS must not zoom */
  .form-check { min-height: 44px; display: flex; align-items: center; gap: .6rem; padding-left: 0; }
  .form-check-input { width: 1.5rem; height: 1.5rem; margin: 0; float: none; flex: none; }
  .form-check-label { padding: .5rem 0; flex: 1; }
  .nav-tabs .nav-link, .nav-pills .nav-link, .dropdown-item, .page-link, .list-group-item-action { min-height: 44px; display: flex; align-items: center; }
  .table td a:not(.btn), .table th a:not(.btn), .app-dash-recent a { display: inline-block; padding: .7rem 0; min-width: 44px; text-align: center; }   /* links in rows: also short ones (an id, "Edit") */
  .card-header a:not(.btn), a.small, .small a:not(.btn) { display: inline-flex; align-items: center; min-height: 44px; }   /* small text links */
  .app-table-pager .btn { min-width: 44px; }
  .app-table-tools .form-control, .app-table-tools .form-select { max-width: none !important; flex: 1 1 100%; }   /* search + Sort by: full width */
  .app-icon-btn { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .app-actions > .btn { flex: 1 1 10rem; }                                        /* ...and wide enough to hit */
  .app-dash-actions .btn { width: 100%; }
  .app-notif-btn, .app-notif-panel button, .app-notif-panel .btn { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .app-notif-panel a:not(.btn), .app-notif-list a { display: inline-flex; align-items: center; min-height: 44px; }      /* "Open result" links */
  .app-dash-start a, .app-dash-alert, .app-dash-tile { min-height: 44px; }
  .app-dash-start li a { display: inline-block; padding: .7rem 0; }                                                   /* getting-started links */
  .form-switch.form-check { min-height: 44px; }                                                                        /* the whole row (label + switch) is the 44 px target */
  summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; }
}

/* Portrait phones: the main action of a form/page in the thumb zone, buttons stacked and full width */
@media (max-width: 767.98px) and (orientation: portrait) {
  /* <div class="app-sticky-actions"> <button class="btn btn-primary">Save</button> <a class="btn btn-outline-secondary">Cancel</a> </div>
     as the LAST element of a form: stays at the bottom of the screen while the form scrolls */
  .app-sticky-actions { position: sticky; bottom: var(--app-notif-h, 0px); z-index: 5; display: flex; gap: .5rem; margin: 1rem -1rem 0;
                        padding: .6rem 1rem calc(.6rem + env(safe-area-inset-bottom)); background: var(--bs-body-bg);
                        border-top: 1px solid var(--bs-border-color); }
  .app-sticky-actions .btn { flex: 1 1 0; }
  .app-sticky-actions .btn-primary { flex: 2 1 0; order: 2; }                      /* primary on the right = under the right thumb */
  /* The page's one frequent "add" action as a floating button, bottom right, above the notification window */
  .app-fab { position: fixed; right: 1rem; bottom: calc(1rem + var(--app-notif-h, 0px) + env(safe-area-inset-bottom)); z-index: 20;
             width: 56px; height: 56px; min-width: 56px; border-radius: 50%; padding: 0; box-shadow: 0 .25rem .75rem rgba(0,0,0,.3); }
  .app-fab .label { display: none; }
  main.app-main { padding-bottom: 5.5rem; }                                         /* the fab/sticky bar never covers the last row */
}

/* Short landscape phones: a compact sticky bar (one row, small padding) so Save stays reachable without scrolling to the end of a long form */
@media (max-height: 480px) and (orientation: landscape) {
  .app-sticky-actions { position: sticky; bottom: var(--app-notif-h, 0px); z-index: 5; display: flex; gap: .5rem; padding: .3rem 1rem; background: var(--bs-body-bg); border-top: 1px solid var(--bs-border-color); }
  .app-sticky-actions .btn { flex: 1 1 0; }
  .app-fab { position: static; width: auto; border-radius: .5rem; box-shadow: none; }
}

@media (pointer: coarse), (max-width: 767.98px){.app-topbar-brand,.app-sidebar-brand{min-height:44px;display:inline-flex;align-items:center}}
