/* Phone layout — loaded only on screens up to 700px wide (see the media attribute on its <link> in index.html).
   Computers and tablets never see any of this. */

:root { --bnav-h: 62px; }
html { -webkit-text-size-adjust: 100%; }

/* ---- frame: slim top bar + bottom tab bar ---- */
.topbar { flex-wrap: nowrap; height: 52px; padding: 0 14px; gap: 10px; }
.topbar-nav, .topbar-toggle, #topbar-side-toggle, .topbar-user .who, .topbar-user .role-chip { display: none !important; }
.topbar-brand { flex: 1; font-size: 16px; }
.page, body.wide-view .page { padding: 12px 12px calc(var(--bnav-h) + env(safe-area-inset-bottom) + 18px); }

.bottom-nav {
  display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 10px rgba(20, 25, 40, 0.08);
}
.bnav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 48px;
  border: 0; background: transparent; border-radius: 10px; padding: 6px 0;
  font: inherit; font-size: 11px; font-weight: 600; color: var(--text-muted); cursor: pointer;
}
.bnav-ico { font-size: 21px; line-height: 1; }
.bnav-btn[aria-current="page"] { color: var(--primary); background: #eef4ff; }

/* ---- touch comfort: bigger targets, and 16px fields so iPhones don't zoom in on focus ---- */
input, select, textarea { font-size: 16px; }
.btn { min-height: 42px; }
.btn-sm { min-height: 38px; padding: 8px 12px; }
.grid2 { grid-template-columns: minmax(0, 1fr); }
.tabbar { overflow-x: auto; white-space: nowrap; flex-wrap: nowrap; }
.tab-btn { flex: none; }
.modal-scrim { padding: 10px; align-items: flex-end; }
.modal { width: 100% !important; max-height: 92vh; border-radius: 16px 16px 12px 12px; }
.note-x { opacity: 1; }  /* there is no hover on a touch screen */

/* ---- Home ---- */
.home-hero { padding: 14px; gap: 14px; }
.home-id { min-width: 0; width: 100%; }
.home-boxes { width: 100%; }
.home-box { flex: 1 1 100%; min-width: 0; padding: 14px; }
.home-box .btn { width: 100%; min-height: 52px; font-size: 18px; }   /* Sign In / Sign Out */
.home-box-num { font-size: 36px; }
.home-urgent { margin-left: 0; width: 100%; align-items: stretch; }
.home-urgent .btn { width: 100%; min-height: 46px; }
.home-push { margin: 0 0 12px; }
.home-push-actions { margin-left: 0; width: 100%; }
.home-push-actions .btn { flex: 1; }
.note-add { flex-wrap: wrap; }
.note-add > input[type="text"] { flex: 1 1 100%; order: 1; }
.note-add .note-plus { display: none; }
.note-add input[type="date"] { order: 2; flex: 1; }
.note-add .btn { order: 3; }
.note-row { flex-wrap: wrap; row-gap: 0; }
.note-row .note-text { flex: 1 1 0; min-width: 0; }
.note-row .note-date { order: 5; flex: 1 1 100%; width: auto; margin-left: 30px; padding-bottom: 6px; }
.week-day { width: 84px; }
.week-tasks { margin-left: 0; text-align: left; width: 100%; padding-left: 96px; }

/* ---- Rota as a day-by-day list ---- */
.rp { display: flex; flex-direction: column; gap: 10px; }
.rp.is-loading { opacity: 0.5; }
.rp-bar { display: flex; align-items: center; gap: 8px; }
.rp-week { flex: 1; text-align: center; font-weight: 700; font-size: 15px; }
.rp-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.rp-day {
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 0;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  font: inherit; font-size: 11px; color: var(--text-muted); cursor: pointer;
}
.rp-day strong { font-size: 17px; color: var(--text); }
.rp-day i { font-style: normal; font-size: 10px; color: var(--text-muted); }
.rp-day i.has { color: var(--primary); font-weight: 700; }
.rp-day.is-today strong { color: var(--primary); }
.rp-day.is-sel { background: var(--primary); border-color: var(--primary); }
.rp-day.is-sel span, .rp-day.is-sel strong, .rp-day.is-sel i { color: #fff; }
/* Everyone / Only me, then one card per department — a strip that scrolls sideways. */
.rp-filter { display: flex; align-items: center; gap: 6px; overflow-x: auto; padding: 2px 2px 6px; margin: 0 -2px; scrollbar-width: none; }
.rp-filter::-webkit-scrollbar { display: none; }
.rp-pill {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  font: inherit; font-size: 14px; font-weight: 600; color: var(--text-muted); cursor: pointer; white-space: nowrap;
}
.rp-pill b { font-size: 12px; font-weight: 700; color: var(--primary); background: #eef4ff; border-radius: 999px; padding: 1px 7px; }
.rp-pill.is-on { background: #e8f1fd; border-color: #b9cff0; color: #1d4f91; }
.rp-pill.is-on b { background: #fff; }
.rp-sep { flex: none; width: 1px; height: 22px; background: var(--border); margin: 0 2px; }
.rp-dayhead { margin: 6px 0 0; font-size: 16px; }
.rp-card {
  display: flex; gap: 12px; padding: 10px 12px; border-radius: 12px;
  border: 1.5px solid #bfd3f5; border-left-width: 6px; background: #eef3ff;
}
.rp-card.has-ec {
  background: linear-gradient(180deg, var(--ec-top), var(--ec-bot));
  border-color: var(--ec-bd); border-left-color: var(--ec-dot);
}
.rp-card.is-mine { box-shadow: 0 0 0 2px rgba(31, 111, 235, 0.35); }
.rp-card.is-tail { border-style: dashed; border-left-style: solid; }
.rp-time { width: 92px; flex: none; display: flex; flex-direction: column; }
.rp-time strong { font-size: 14px; }
.rp-time small { color: var(--text-muted); font-size: 11px; }
.rp-main { flex: 1; min-width: 0; }
.rp-name { font-weight: 700; font-size: 15px; }
.rp-me { font-size: 10px; background: var(--primary); color: #fff; border-radius: 999px; padding: 1px 6px; vertical-align: middle; }
.rp-bureau { font-size: 10px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; border: 1px solid rgba(20, 25, 40, 0.25); border-radius: 999px; padding: 0 6px; margin-left: 4px; color: var(--text-muted); }
.rp-prog { font-style: italic; color: var(--text-muted); font-size: 12px; }
.rp-slots { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.rp-slot { font-size: 11px; font-weight: 600; border-radius: 6px; padding: 2px 6px; background: #fff; border: 1px solid var(--border); }
.rp-slot-live { color: #1d4f91; border-color: #b9cff0; }
.rp-slot-rec { color: #7a2f2f; border-color: #e3c4c4; }
.rp-slot-ext { color: #1f6b3d; border-color: #bfe0cb; }
.rp-event { background: #fff8e6; border: 1px solid #f1e0b0; border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.rp-leave { font-size: 13px; color: var(--text-muted); padding: 4px 2px; }
.rp-empty { padding: 24px 0; text-align: center; }
.rp-note { text-align: center; }


/* ---- Booking on a phone: same look as the Rota list, plus a full-width form sheet ---- */
.bk-plive { border: 1px solid; }
.bk-plive-qatar { background: linear-gradient(180deg, rgba(255, 234, 240, 0.95), rgba(251, 208, 221, 0.7)); border-color: rgba(228, 156, 180, 0.9); color: #7a1f3a; }
.bk-plive-uae { background: linear-gradient(180deg, rgba(230, 241, 255, 0.95), rgba(190, 217, 252, 0.7)); border-color: rgba(125, 165, 228, 0.9); color: #1e4a8f; }
.bk-fab {
  position: fixed; right: 14px; bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom) + 14px); z-index: 40;
  border: 0; border-radius: 999px; padding: 14px 20px; background: var(--primary); color: #fff;
  font: inherit; font-size: 16px; font-weight: 700; box-shadow: 0 6px 18px rgba(20, 25, 40, 0.3); cursor: pointer;
}
.rp-card { cursor: pointer; }
.modal-scrim.bk-sheet { padding: 0; }
.modal-scrim.bk-sheet .modal { max-height: 94vh; border-radius: 18px 18px 0 0; display: flex; flex-direction: column; overflow: hidden; }
.modal-scrim.bk-sheet .modal-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; -webkit-overflow-scrolling: touch; }
.modal-scrim.bk-sheet .modal-foot { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); }
.modal-scrim.bk-sheet .modal-foot .btn { flex: 1; min-height: 46px; font-size: 16px; }
.modal-scrim.bk-sheet .modal-foot .btn-danger { flex: none; }
.bk-formgrid { gap: 12px; }
.bk-fcol { gap: 12px; }
.bk-when { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.bk-when > label:first-child { grid-column: 1 / -1; }
.bk-gnew { grid-template-columns: minmax(0, 1fr); }
.bk-gnew .btn { width: 100%; }
.bk-dept-box { max-height: 200px; }
.bk-rp .rp-bureau { display: inline-block; white-space: nowrap; margin: 3px 0 0 0; }
.bk-rp .rp-name { display: block; }
/* on a phone the form is one column in this order: title, place, time, people, guests, then Notes last */
.bk-formgrid { display: flex; flex-direction: column; }
.bk-fcol { display: contents; }
.bk-notes-field { order: 8; }
.bk-formgrid .banner { order: 9; }

/* iPhones zoom the whole page in when a field with text smaller than 16px gets focus (that is what cut the booking form off
   at the right). Forms use ".stack input { font: inherit }" which made fields 12px, so on a phone every field is forced to 16px. */
.stack input, .stack select, .stack textarea, .modal input, .modal select, .modal textarea,
.calfield-btn, .timefield select, .datefield select { font-size: 16px !important; }
.modal-scrim.bk-sheet, .modal-scrim.bk-sheet .modal { max-width: 100vw; }
.modal-scrim.bk-sheet .modal-body { overflow-x: hidden; }

/* suggestions under a field are big enough to tap; nothing may push the page sideways */
.grid-suggest.is-inline { max-height: 260px; font-size: 16px; }
.grid-suggest.is-inline .grid-suggest-opt { padding: 13px 10px; }
html, body { max-width: 100%; overflow-x: hidden; }

/* Booking sheet footer: small buttons that all fit on one line across the phone screen */
.modal-scrim.bk-sheet .modal-foot { display: flex; flex-wrap: nowrap; gap: 6px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
.modal-scrim.bk-sheet .modal-foot .spacer { display: none; }
.modal-scrim.bk-sheet .modal-foot .btn,
.modal-scrim.bk-sheet .modal-foot .btn-danger { flex: 1 1 0; min-width: 0; min-height: 38px; padding: 6px 4px; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-scrim.bk-sheet .modal-foot .btn-danger { flex: 0 0 auto; padding: 6px 10px; overflow: visible; }

/* ---- Dashboard on a phone ---- */
.dash-title { font-size: 24px; }
.dash-range { gap: 6px; }
.dash-range .input { width: auto; flex: 1 1 130px; min-width: 0; }
.dash-block + .dash-block { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 14px; }
.dash-top .dash-stats { gap: 6px; }
.dash-top .dash-stat-pill { padding: 6px 9px; }
.dash-stat-sep { display: none; }
.dash-charts { flex-direction: column; }
.dash-chart-box, .dash-chart-box-small { min-width: 0; max-width: none; flex: 1 1 auto; width: 100%; }
.dash-topics-list { max-width: none; flex: 1 1 100%; }
.dash-map-box { flex: 1 1 100%; min-width: 0; }
.dash-map { height: 260px; }

/* Dashboard on a phone, neat: From / To / This week each on its own line; no department bar chart */
.dash-range { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; align-items: center; }
.dash-range .dr-long { display: none; }
.dash-range .dr-short { display: inline; font-weight: 600; color: var(--text); }
.dash-range .input { width: 100%; flex: none; }
.dash-range .dr-week { grid-column: 1 / -1; width: 100%; min-height: 42px; }
.dash-range .dr-note { grid-column: 1 / -1; }
.dash-chart-box:not(.dash-chart-box-small) { display: none; }

.dash-range .calfield, .dash-range .calfield-btn { display: block; width: 100%; }

/* Home on a phone: a small Urgent leave button (not full width) with the notifications switch under it */
.home-urgent { align-items: flex-start; }
.home-urgent .btn { width: auto; min-height: 36px; padding: 6px 14px; }
.home-notif { align-items: flex-start; }
.notif-note { text-align: left; max-width: none; }
