/* CLIK.ma - the web app (clik-pwa.js): the install banner, the iPhone / iPad steps, the "installed" toast, the iPhone
   back arrow. Day / night, French / Arabic (logical sides), phones (above the bottom bar) and computers. */

/* the "Install the app" rows of the menus show only where the app can be installed */
html:not(.clik-can-install) .clik-pwa-only { display: none !important; }

/* ---------- the banner ---------- */
.clik-pwa-banner {
  position: fixed; z-index: 1050; inset-inline-start: 16px; bottom: 16px; width: max-content; max-width: calc(100vw - 32px);
  display: grid; grid-template-columns: 48px minmax(0, auto) auto auto; grid-template-areas: "ic tx btn x"; align-items: center; gap: 8px;
  padding: 8px; border-radius: 18px;
  background: #fff; color: #050505; box-shadow: 0 10px 34px rgba(15, 23, 42, .18), 0 0 0 1px rgba(15, 23, 42, .06);
  opacity: 0; transform: translateY(16px) scale(.98); transition: opacity .3s ease, transform .35s cubic-bezier(.2, .9, .25, 1.15);
  pointer-events: none;
}
.clik-pwa-banner[hidden] { display: none; }
.clik-pwa-banner.is-active { opacity: 1; transform: none; pointer-events: auto; }
body.night-mode .clik-pwa-banner { background: #242526; color: #e4e6eb; box-shadow: 0 10px 34px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .06); }
body.clik-hdr-menu-open .clik-pwa-banner, body.clik-pwa-sheet-open .clik-pwa-banner, body.modal-open .clik-pwa-banner { display: none; }
.clik-pwa-banner-ic { grid-area: ic; width: 48px; height: 48px; display: grid; place-items: center; background: none; } /* the 3D cube alone - never a plate behind the logo */
.clik-pwa-banner-ic .clik-cube3d { display: block; width: 44px; height: auto; filter: drop-shadow(0 4px 5px rgba(8, 40, 120, .28)); }
body.night-mode .clik-pwa-banner-ic .clik-cube3d { filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .55)); }
.clik-pwa-banner-tx { grid-area: tx; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
/* the title and its logo on ONE line, whatever the language and the screen (the banner grows to hold them;
   on phones the buttons go to their own row and the words scale with the screen) */
.clik-pwa-banner-title { display: flex; flex-wrap: nowrap; align-items: center; gap: 8px; min-width: 0; font-size: 15px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.clik-pwa-banner-words { flex: none; white-space: nowrap; }
.clik-pwa-banner-title .clik-brand.is-inline { flex: none; gap: 3px; margin: 0 !important; }
.clik-pwa-banner-title .clik-brand.is-inline .clik-brand-cube { width: auto; height: 18px; }
.clik-pwa-banner-title .clik-brand.is-inline .clik-brand-word { height: 14px !important; width: auto; }
.clik-pwa-banner-sub { font-size: 12.5px; line-height: 1.3; color: #65676b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.night-mode .clik-pwa-banner-sub { color: #b0b3b8; }
.clik-pwa-banner .clik-pwa-btn { grid-area: btn; }
.clik-pwa-banner .clik-pwa-x { grid-area: x; }
.clik-pwa-btn {
  flex: none; height: 36px; padding: 0 16px; border: 0; border-radius: 999px; cursor: pointer;
  font-weight: 700; font-size: 14px; color: #fff; white-space: nowrap;
  background: linear-gradient(180deg, #3d8bff 0%, #0866ff 55%, #0052d6 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 3px 8px rgba(8, 102, 255, .35);
  transition: transform .12s ease, box-shadow .2s ease;
}
.clik-pwa-btn:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 5px 14px rgba(8, 102, 255, .45); }
.clik-pwa-btn:active { transform: scale(.95); }
.clik-pwa-btn:focus-visible, .clik-pwa-x:focus-visible { outline: 2px solid #0866ff; outline-offset: 2px; }

/* a round close with a thin X (as every window's) */
.clik-pwa-x {
  flex: none; position: relative; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: #e4e6eb; color: #606770; transition: transform .2s ease, background-color .2s ease;
}
.clik-pwa-x::before {
  content: ""; position: absolute; inset: 0; margin: auto; width: 14px; height: 14px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 5l14 14M19 5 5 19' stroke='%23000' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 5l14 14M19 5 5 19' stroke='%23000' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.clik-pwa-x:hover { transform: rotate(90deg); }
.clik-pwa-x:active { transform: scale(.9); }
body.night-mode .clik-pwa-x { background: #3a3b3c; color: #e4e6eb; }

/* ---------- the iPhone / iPad steps ---------- */
.clik-pwa-sheet { position: fixed; inset: 0; z-index: 1090; display: flex; align-items: center; justify-content: center; padding: 16px; }
.clik-pwa-sheet[hidden] { display: none; }
.clik-pwa-sheet-back { position: absolute; inset: 0; background: rgba(5, 10, 20, .5); opacity: 0; transition: opacity .25s ease; }
.clik-pwa-sheet-box {
  position: relative; width: 420px; max-width: 100%; padding: 16px 24px 24px; border-radius: 20px;
  background: #fff; color: #050505; box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
  opacity: 0; transform: translateY(24px); transition: opacity .25s ease, transform .3s cubic-bezier(.2, .9, .25, 1.1);
}
.clik-pwa-sheet.is-on .clik-pwa-sheet-back { opacity: 1; }
.clik-pwa-sheet.is-on .clik-pwa-sheet-box { opacity: 1; transform: none; }
body.night-mode .clik-pwa-sheet-box { background: #242526; color: #e4e6eb; }
.clik-pwa-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.clik-pwa-sheet-head .clik-pwa-x { width: 36px; height: 36px; }
.clik-pwa-sheet-title { display: flex; flex-wrap: nowrap; align-items: center; gap: 10px; min-width: 0; margin: 0; font-size: 20px; font-weight: 800; line-height: 1.2; }
.clik-pwa-sheet-title .clik-brand.is-inline { flex: none; margin: 0 !important; }
.clik-pwa-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; counter-reset: s; }
.clik-pwa-steps li { display: flex; align-items: center; gap: 12px; }
.clik-pwa-steps li > span:last-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.clik-pwa-steps b { font-size: 15px; font-weight: 700; line-height: 1.3; }
.clik-pwa-steps small { font-size: 13px; line-height: 1.35; color: #65676b; }
body.night-mode .clik-pwa-steps small { color: #b0b3b8; }
.clik-pwa-step-ic { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 2px 5px rgba(15, 23, 42, .12); }
.clik-pwa-step-ic.is-blue { background: #e7f0ff; color: #0866ff; }
.clik-pwa-step-ic.is-green { background: #e4f7ec; color: #12a150; }
.clik-pwa-step-ic.is-red { background: #ffe8ee; color: #e0164e; }
body.night-mode .clik-pwa-step-ic.is-blue { background: rgba(8, 102, 255, .18); color: #6aa5ff; }
body.night-mode .clik-pwa-step-ic.is-green { background: rgba(18, 161, 80, .18); color: #4ad685; }
body.night-mode .clik-pwa-step-ic.is-red { background: rgba(224, 22, 78, .2); color: #ff6b8e; }

/* ---------- the "installed" toast ---------- */
.clik-pwa-toast {
  position: fixed; z-index: 1095; left: 50%; bottom: 24px; max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 999px;
  background: rgba(14, 16, 28, .92); color: #fff; font-size: 14px; font-weight: 600;
  transform: translate(-50%, 12px); opacity: 0; transition: opacity .25s ease, transform .3s ease; pointer-events: none;
}
.clik-pwa-toast.is-on { transform: translate(-50%, 0); opacity: 1; }

/* ---------- the iPhone / iPad home-screen app's back arrow (header, before the menu cube) ---------- */
.clik-pwa-back {
  flex: none; width: 36px; height: 36px; margin-inline-end: 4px; padding: 0; border: 0; border-radius: 50%;
  display: inline-grid; place-items: center; background: transparent; color: var(--header-color, #050505); cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: background-color .2s ease, transform .12s ease;
}
.clik-pwa-back:active { transform: scale(.88); background: rgba(0, 0, 0, .06); }
body.night-mode .clik-pwa-back { color: #e4e6eb; }
html[dir="rtl"] .clik-pwa-back svg, html[dir="RTL"] .clik-pwa-back svg { transform: scaleX(-1); }

/* ---------- phones: above the bottom bar, the steps as a sheet from the bottom ---------- */
@media (max-width: 668px) {
  .clik-pwa-banner { inset-inline: 8px; width: auto; max-width: none; bottom: calc(45px + 8px + env(safe-area-inset-bottom, 0px)); }
  .clik-pwa-sheet { align-items: flex-end; padding: 0; }
  .clik-pwa-sheet-box { width: 100%; border-radius: 20px 20px 0 0; padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px)); }
  .clik-pwa-toast { bottom: calc(45px + 16px + env(safe-area-inset-bottom, 0px)); }
}
/* phones: the title and its logo get the banner's whole width on the first row (the 3D cube beside them), the
   Installer button and the × on the second; the words and the logo scale with the screen - one line at 320 px */
@media (max-width: 480px) {
  .clik-pwa-banner { grid-template-columns: 40px minmax(0, 1fr) auto; grid-template-areas: "ic tx tx" "btn btn x"; column-gap: 8px; row-gap: 8px; }
  .clik-pwa-banner .clik-pwa-btn { width: 100%; }
  .clik-pwa-banner .clik-pwa-x { width: 36px; height: 36px; }
  .clik-pwa-banner-ic { width: 40px; height: 40px; }
  .clik-pwa-banner-ic .clik-cube3d { width: 38px; }
  .clik-pwa-banner-title { gap: 6px; font-size: clamp(13px, 4vw, 15px); }
  .clik-pwa-banner-title .clik-brand.is-inline .clik-brand-cube { height: clamp(14px, 4.4vw, 18px); }
  .clik-pwa-banner-title .clik-brand.is-inline .clik-brand-word { height: clamp(11px, 3.4vw, 14px) !important; }
}
@media (prefers-reduced-motion: reduce) {
  .clik-pwa-banner, .clik-pwa-sheet-back, .clik-pwa-sheet-box, .clik-pwa-toast, .clik-pwa-x, .clik-pwa-btn { transition: none; }
}

/* ---------- the installed app in full screen (Android: no status bar, no navigation bar - AdminCP -> Apps -> PWA)
   and the iPhone app under its translucent status bar (html.clik-ios-translucent): the page starts under the camera's
   cutout / the status bar (the safe area, viewport-fit=cover) - html is padded (body keeps its own 56 px under the
   header), the fixed header moves down with it, a band of the bar's colour (AdminCP) covers that strip so nothing
   scrolls under the camera, and the full-screen menus end under it. Where there is no cutout env() is 0: nothing
   moves. ---------- */
@media (display-mode: fullscreen) {
  html { padding-top: env(safe-area-inset-top, 0px); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
  .clik-navbar-top { top: env(safe-area-inset-top, 0px); }
  body::before { content: ""; position: fixed; z-index: 1060; top: 0; left: 0; right: 0; height: env(safe-area-inset-top, 0px); background: var(--clik-app-bar, #fff); pointer-events: none; }
  body.night-mode::before { background: var(--clik-app-bar-night, #212121); }
  body:has(#clik-rl)::before { background: #000; }
}
html.clik-ios-translucent { padding-top: env(safe-area-inset-top, 0px); }
html.clik-ios-translucent .clik-navbar-top { top: env(safe-area-inset-top, 0px); }
html.clik-ios-translucent body::before { content: ""; position: fixed; z-index: 1060; top: 0; left: 0; right: 0; height: env(safe-area-inset-top, 0px); background: var(--clik-app-bar, #fff); pointer-events: none; }
html.clik-ios-translucent body.night-mode::before { background: var(--clik-app-bar-night, #212121); }
html.clik-ios-translucent body:has(#clik-rl)::before { background: #000; }
@media (display-mode: fullscreen) and (min-width: 669px) {
  .clik-navbar-top-right { top: env(safe-area-inset-top, 0px); }
}
@media (display-mode: fullscreen) and (max-width: 668px) {
  body .clik-navbar-top-right > .dropdown .dropdown-menu, body .clik-header-sarch-dropdown {
    top: env(safe-area-inset-top, 0px);
    max-height: calc(100% - 45px - env(safe-area-inset-bottom, 0px) - env(safe-area-inset-top, 0px));
    height: calc(var(--vh, 1vh) * 100 - 45px - env(safe-area-inset-bottom, 0px) - env(safe-area-inset-top, 0px));
  }
}
@media (max-width: 668px) {
  html.clik-ios-translucent body .clik-navbar-top-right > .dropdown .dropdown-menu, html.clik-ios-translucent body .clik-header-sarch-dropdown {
    top: env(safe-area-inset-top, 0px);
    max-height: calc(100% - 45px - env(safe-area-inset-bottom, 0px) - env(safe-area-inset-top, 0px));
    height: calc(var(--vh, 1vh) * 100 - 45px - env(safe-area-inset-bottom, 0px) - env(safe-area-inset-top, 0px));
  }
}
@media (min-width: 669px) {
  html.clik-ios-translucent .clik-navbar-top-right { top: env(safe-area-inset-top, 0px); }
}
