/* App-style mobile layer (phones only). Loaded with media="(max-width: 768px)" from Web.Master and Default.aspx.
   - tap feedback, soft page entry, no grey tap flash
   - Tenders Search: the search bar stays at the top, the results come first, the filters live in a bottom sheet
     opened by the "Filters" button (mobile-app.js builds the button, the sheet header and footer).
   Logical properties keep Arabic (RTL) and English (LTR) symmetrical. Desktop is untouched. */

@media (max-width: 768px) {
  html { scroll-behavior: smooth; }
  body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }

  /* soft entry (opacity only: a transform here would trap the fixed bottom sheet) */
  @keyframes tgAppIn { from { opacity: 0; } to { opacity: 1; } }
  #content, #main { animation: tgAppIn .28s ease both; }

  /* pressed state on the things people tap */
  article[data-tender-id], .tender-card, .tg-mobile-bottombar a, .ts-loadmore-btn, .as-loadmore-btn,
  .tg-limit__btn, .tg-limit__opt, .tg-app-filterbtn { transition: transform .12s ease, background .15s ease; }
  article[data-tender-id]:active, .tender-card:active, .ts-loadmore-btn:active, .as-loadmore-btn:active,
  .tg-limit__btn:active, .tg-limit__opt:active, .tg-app-filterbtn:active { transform: scale(.985); }
  .tg-mobile-bottombar a:active { transform: scale(.94); }

  /* ================= Tenders Search ================= */
  body.tg-app-ts #main > .row { display: flex; flex-direction: column; margin-inline: 0; padding-inline: 12px; }
  body.tg-app-ts #main > .row > [class*="col-"] { display: contents; }
  body.tg-app-ts #main > .row > .col-sm-8 > * { order: 10; }
  body.tg-app-ts #main > .row > .col-sm-4 > * { order: 30; }
  body.tg-app-ts #main > .row > [class*="col-"] > * { min-width: 0; max-width: 100%; box-sizing: border-box; }

  /* search bar: sticky, full width, with the Filters button next to the field */
  body.tg-app-ts .travelo-box {
    order: 1 !important; position: sticky; top: 0; z-index: 900; margin: 0 -12px 8px; padding: 10px 12px;
    background: #fff; border: 0; border-radius: 0; box-shadow: 0 2px 10px rgba(23, 63, 69, .1);
  }
  body.tg-app-ts .travelo-box > .form-group { width: 100%; float: none; padding: 0; margin: 0; }
  body.tg-app-ts .travelo-box > .form-group > label { display: none; }
  body.tg-app-ts .tg-app-searchrow { display: flex; align-items: center; gap: 8px; }
  body.tg-app-ts .tg-app-searchrow .with-icon { flex: 1 1 auto; min-width: 0; }
  .tg-app-filterbtn {
    flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 48px; padding: 0 14px;
    font: inherit; font-size: 13px; font-weight: 700; color: #245f66; cursor: pointer;
    background: #eef7f8; border: 1.5px solid #378b95; border-radius: 12px; white-space: nowrap;
  }
  .tg-app-filterbtn .fa, .tg-app-filterbtn .fas { color: #378b95; }

  /* the result count becomes a slim line and the market chart is left out on phones */
  body.tg-app-ts .ts-market-widget { display: none; }
  body.tg-app-ts #main > .row > .col-sm-4 > .search-results-main-large { order: 2; margin: 4px 0 8px !important; padding: 8px 12px !important; min-height: 0 !important; }
  body.tg-app-ts .search-results-main-large b { font-size: 20px !important; line-height: 1.2 !important; }
  body.tg-app-ts .search-results-icon-enhanced { transform: scale(.7); transform-origin: center; margin: -6px !important; }

  /* ---- filters bottom sheet ---- */
  body.tg-app-ts .filters-container {
    position: fixed !important; inset-inline: 0; bottom: 0; top: auto; width: 100%; max-height: 86vh; margin: 0 !important;
    overflow-y: auto; -webkit-overflow-scrolling: touch; background: #fff; border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 30px rgba(23, 63, 69, .25); z-index: 10002; padding-bottom: 76px;
    transform: translateY(105%); visibility: hidden; transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .3s;
  }
  body.tg-sheet-open .filters-container { transform: none; visibility: visible; transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s; }
  body.tg-sheet-open { overflow: hidden; }
  .tg-sheet-backdrop {
    position: fixed; inset: 0; z-index: 10001; background: rgba(15, 35, 40, .5); opacity: 0; visibility: hidden;
    transition: opacity .25s ease, visibility 0s linear .25s;
  }
  body.tg-sheet-open .tg-sheet-backdrop { opacity: 1; visibility: visible; transition: opacity .25s ease, visibility 0s; }
  body.tg-app-ts .filters-container > h4 { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 6px; margin: 0; padding: 16px 16px 12px; background: #fff; border-bottom: 1px solid #e1e8e9; }
  .tg-sheet-grab { position: absolute; top: 6px; inset-inline: 0; margin: 0 auto; width: 40px; height: 4px; border-radius: 4px; background: #cfdadc; }
  .tg-sheet-close {
    margin-inline-start: auto; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
    background: #eef3f4; color: #35474e; font-size: 18px; line-height: 1;
  }
  .tg-sheet-foot {
    position: fixed; inset-inline: 0; bottom: 0; z-index: 10003; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
    background: #fff; border-top: 1px solid #e1e8e9; transform: translateY(105%); visibility: hidden;
    transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .3s;
  }
  body.tg-sheet-open .tg-sheet-foot { transform: none; visibility: visible; transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s; }
  .tg-sheet-foot button {
    width: 100%; height: 48px; font: inherit; font-size: 15px; font-weight: 700; color: #fff; cursor: pointer;
    background: #f5833d; border: 0; border-radius: 12px;
  }
  .tg-sheet-foot button:active { background: #d96b2c; }
  body.tg-app-ts .tg-sheet-sort { padding: 12px 16px; border-bottom: 1px solid #e1e8e9; }
  body.tg-app-ts .tg-sheet-sort .form-group { float: none; width: 100%; padding: 0; margin: 0; }
}

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  #content, #main { animation: none; }
  body.tg-app-ts .filters-container, .tg-sheet-backdrop, .tg-sheet-foot { transition: none; }
}

/* ================= Side menu (More tab), grouped app style ================= */
@media (max-width: 768px) {
  #tg-mobile-offcanvas.tg-app-menu { background: #f4f7f8; border-radius: 0; }
  #tg-mobile-offcanvas.tg-app-menu .tg-offcanvas-topbar { background: #fff; border-bottom: 1px solid #e1e8e9; min-height: 58px; }
  #tg-mobile-offcanvas.tg-app-menu .tg-offcanvas-topbar-icon:not(.tg-offcanvas-close) { display: none; }
  #tg-mobile-offcanvas.tg-app-menu .tg-offcanvas-close { width: 38px; height: 38px; border-radius: 50%; background: #eef3f4; color: #35474e; }
  #tg-mobile-offcanvas .tg-app-body { padding: 12px 12px calc(24px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 10px; }

  /* account card */
  .tg-app-account { padding: 14px; border-radius: 16px; background: linear-gradient(135deg, #245f66, #378b95); color: #fff; }
  .tg-app-account__title { margin: 0 0 10px; font-size: 15px; font-weight: 700; }
  .tg-app-account__actions { display: flex; gap: 8px; }
  .tg-app-btn { flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 10px; border-radius: 12px; font-size: 14px; font-weight: 700; text-decoration: none; text-align: center; border: 1.5px solid transparent; }
  .tg-app-btn--primary { background: #f5833d; color: #fff !important; }
  .tg-app-btn--ghost { background: transparent; color: #fff !important; border-color: rgba(255, 255, 255, .7); }
  .tg-app-btn:active { transform: scale(.97); }
  .tg-app-account__me { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-size: 15px; font-weight: 700; }
  .tg-app-account__me .fa-user-circle { font-size: 26px; }
  .tg-app-account__me .tg-app-chev { margin-inline-start: auto; opacity: .8; }

  /* quick tiles */
  .tg-app-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .tg-app-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; border-radius: 14px; background: #fff; border: 1px solid #e1e8e9; color: #245f66; text-decoration: none; font-size: 13px; font-weight: 700; line-height: 1.3; }
  .tg-app-tile .fas { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: #eef7f8; color: #378b95; font-size: 15px; }
  .tg-app-tile:active { transform: scale(.97); background: #eef7f8; }

  /* sister products */
  .tg-app-prods { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .tg-app-prod { display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 10px; min-height: 92px; padding: 12px; border-radius: 14px; background: #fff; border: 1px solid #e1e8e9; color: #245f66; text-decoration: none; font-size: 13px; font-weight: 700; line-height: 1.3; }
  .tg-app-prod img { display: block; width: 34px; height: 34px; object-fit: contain; }
  .tg-app-prod__t { display: flex; flex-direction: column; gap: 1px; }
  .tg-app-prod__t strong { font-size: 13px; }
  .tg-app-prod__t small { font-size: 11.5px; font-weight: 600; color: #6b7c82; }
  .tg-app-prod:active { transform: scale(.97); background: #eef7f8; }

  .tg-app-prods > .tg-app-prod:only-child { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: flex-start; min-height: 0; }

  /* sections */
  .tg-app-sec { border-radius: 14px; background: #fff; border: 1px solid #e1e8e9; overflow: hidden; }
  .tg-app-sec__head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 13px 14px; font: inherit; font-size: 14px; font-weight: 700; color: #245f66; text-align: start; background: #fff; border: 0; cursor: pointer; }
  .tg-app-sec__ic { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; background: #eef7f8; color: #378b95; font-size: 13px; }
  .tg-app-sec__t { flex: 1 1 auto; }
  .tg-app-sec__chev { color: #8aa0a5; font-size: 12px; transition: transform .25s ease; }
  .tg-app-sec.is-open .tg-app-sec__chev { transform: rotate(180deg); }
  .tg-app-sec__body { display: none; border-top: 1px solid #eef3f4; }
  .tg-app-sec.is-open .tg-app-sec__body { display: block; }

  /* link rows */
  .tg-app-row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 14px; color: #1f3d44; text-decoration: none; font-size: 14px; font-weight: 600; background: #fff; }
  .tg-app-sec__body .tg-app-row + .tg-app-row { border-top: 1px solid #f0f4f5; }
  .tg-app-row > .fas:first-child { width: 22px; text-align: center; color: #378b95; font-size: 14px; }
  .tg-app-row__t { flex: 1 1 auto; min-width: 0; }
  .tg-app-row:active { background: #eef7f8; }
  .tg-app-row--solo { border-radius: 14px; border: 1px solid #e1e8e9; }
  .tg-app-chev { color: #b3c2c6; font-size: 11px; }
  [dir="rtl"] .tg-app-chev.fa-chevron-right { transform: scaleX(-1); }

  /* country and language */
  .tg-app-region { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; font: inherit; text-align: start; cursor: pointer; background: #fff; border: 1px solid #e1e8e9; border-radius: 14px; }
  .tg-app-region img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex: none; }
  .tg-app-region__t { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
  .tg-app-region__t strong { font-size: 14px; color: #1f3d44; }
  .tg-app-region__t small { font-size: 12px; color: #6b7c82; }

  /* app badges keep their own look, in a card */
  .tg-app-stores { padding: 12px; border-radius: 14px; background: #fff; border: 1px solid #e1e8e9; }
}

/* the site's global button rules (fixed height / line-height / nowrap) must not squeeze the menu controls */
@media (max-width: 768px) {
  body .tg-app-region, body .tg-app-sec__head { height: auto; line-height: 1.4; white-space: normal; text-overflow: clip; overflow: visible; }
  body .tg-app-region { min-height: 56px; }
  body .tg-app-sec__head { min-height: 52px; }
  body .tg-app-region__t strong, body .tg-app-region__t small { line-height: 1.4; }
}

/* compact sub-lists: smaller, grey, tighter */
@media (max-width: 768px) {
  .tg-app-sec__body .tg-app-row { min-height: 38px; padding: 7px 14px; gap: 10px; font-size: 12.5px; font-weight: 500; color: #5a6c73; background: #fafbfb; }
  .tg-app-sec__body .tg-app-row > .fas:first-child { width: 18px; font-size: 12px; color: #8aa0a5; }
  .tg-app-sec__body .tg-app-row + .tg-app-row { border-top: 1px solid #f0f4f5; }
  .tg-app-sec__body .tg-app-chev { font-size: 9px; color: #c3cfd2; }
  .tg-app-sec__body .tg-app-row:active { background: #eef3f4; }
  .tg-app-sec__body { background: #fafbfb; }
  .tg-app-sec__head { min-height: 46px; padding: 10px 14px; }
}

/* menu brand (website name + icon) and the five-tab bottom bar */
@media (max-width: 768px) {
  #tg-mobile-offcanvas .tg-app-brand { display: flex; flex-direction: column; justify-content: center; gap: 2px; min-width: 0; text-decoration: none; }
  .tg-app-brand__row { display: flex; align-items: center; gap: 8px; }
  .tg-app-brand__icon { width: 28px; height: 28px; object-fit: contain; flex: none; }
  .tg-app-brand__word { width: 150px; max-width: 100%; height: auto; max-height: 34px; object-fit: contain; object-position: left center; }
  [dir="rtl"] .tg-app-brand__word { object-position: right center; }
  .tg-app-brand__name { font-size: 10.5px; line-height: 1.2; color: #6b7c82; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
  .tg-mobile-bottombar .tg-bottombar-link span { font-size: 10.5px; }
}

@media (max-width: 768px) {
  #tg-mobile-offcanvas .tg-app-brand img.tg-app-brand__icon { width: 28px; height: 28px; }
  #tg-mobile-offcanvas .tg-app-brand img.tg-app-brand__word { width: 150px; max-width: 100%; height: auto; max-height: 34px; }
}

/* Publishers tab: the publisher icon and the full Arabic term */
@media (max-width: 768px) {
  .tg-mobile-bottombar .tg-app-pubtab { min-width: 0; }
  .tg-mobile-bottombar .tg-app-pubtab .tg-app-pubtab__icon { display: block; width: 22px; height: 22px; margin: 0 auto 2px; object-fit: contain; }
  .tg-mobile-bottombar .tg-app-pubtab span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 10px; }
}

/* ================= Compact tender cards (phones) ================= */
@media (max-width: 768px) {
  .tg-card__body { padding: 10px 12px; }
  .tg-card .tg-badges { margin-bottom: 4px; }
  .tg-card .tg-title { margin: 4px 0 6px; font-size: 15px; line-height: 1.4; }
  .tg-card .tg-pub-banner { margin: 0 0 2px; }

  /* dates: icon and text side by side */
  .tg-card .tg-meta { padding: 8px 0; gap: 6px 8px; }
  .tg-card .tg-meta__item { min-height: 0; flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; padding: 0; text-align: start; }
  .tg-card .tg-meta__copy { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; text-align: start; }
  .tg-card .tg-meta__icon, .tg-card .tg-square-progress { flex: none; width: 36px; height: 36px; }
  .tg-card .tg-meta__icon svg, .tg-card .tg-square-progress__svg { width: 36px; height: 36px; }
  .tg-card .tg-meta__copy small { font-size: 10.5px; }
  .tg-card .tg-meta__copy strong { font-size: 12px; }

  /* actions: Details + favourite and the website icon on one row */
  .tg-card .tg-actions { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
  .tg-card .tg-actions__primary { flex: 1 1 auto; min-width: 0; }
  .tg-card .tg-actions__icons { flex: none; }
  .tg-card .tg-btn-split, .tg-card .tg-btn-split__main { min-height: 42px; }

  /* subcategories: one slim row, without the helper sentence */
  .tg-card .tg-category__toggle { min-height: 40px; padding: 6px 10px; }
  .tg-card .tg-category__copy > span { display: none; }
}

/* ================= Sticky app header (phones) ================= */
@media (max-width: 768px) {
  .TenderHeaderMenu { position: sticky; top: 0; z-index: 1000; background: #fff; }
  body.tg-app-ts .travelo-box { top: 58px; }
}

/* sticky needs the page (not the body box) to be the scroller: the site sets overflow on both html and body, which makes
   the body a scroll container and stops position: sticky from ever sticking */
@media (max-width: 768px) {
  html body { overflow-x: clip !important; overflow-y: visible !important; }
}

/* scroll lock for the menu (mobile-tab-bar.js sets overflow inline) and the filters sheet still has to win over the rule above */
@media (max-width: 768px) {
  html body[style*="overflow: hidden"], html body.tg-sheet-open { overflow: hidden !important; }
}
