/* ==========================================================================
   pageHelp.css
   In the top bar of every _Layout screen, beside the user's name: the
   labelled «? راهنمای این صفحه» pill (this page's help) and the red round
   EN/FA switch — and the centred help dialog. Colours follow admin-theme.css.
   The dock sits outside the collapsing menu, so it is visible at every width.
   ========================================================================== */

.phDock {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0.25rem 0 0.75rem;
}

.phDockBtn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-family: Vazir, iranyekan, sans-serif;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.9);
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease, filter 0.15s ease;
}

.phDockBtn:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}

.phDockBtn:focus-visible {
  outline: 3px solid rgba(147, 197, 253, 0.8);
  outline-offset: 2px;
}

.phDockBtn[hidden] {
  display: none;
}

/* The help pill: labelled, so a first-time visitor sees what it is without hovering. */
#phHelpBtn {
  position: relative;
  width: auto;
  padding: 0 0.95rem 0 0.75rem;
  gap: 0.45rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 55%, #1d4ed8 100%);
  font-size: 0.88rem;
  white-space: nowrap;
}

#phHelpBtn .bi {
  font-size: 1.1rem;
}

/* The label follows the page-wide EN switch; the dock itself is never run through the translator. */
.phLabelEn,
html.st-en .phLabelFa {
  display: none;
}

html.st-en .phLabelEn {
  display: inline;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Until the visitor has opened help once, a soft ring pulses around the pill. */
#phHelpBtn.phPulse::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid rgba(96, 165, 250, 0.9);
  animation: phPulse 1.8s ease-out infinite;
  pointer-events: none;
}

@keyframes phPulse {
  0% { opacity: 0.9; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.2); }
}

@media (prefers-reduced-motion: reduce) {
  #phHelpBtn.phPulse::after {
    animation: none;
    opacity: 0.7;
  }
}

/* The EN/FA switch: red, so it stands apart from the blue help pill. */
#stLangBtn {
  background: #dc2626;
  border-color: rgba(255, 255, 255, 0.28);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

#stLangBtn:hover {
  background: #b91c1c;
}

html.st-en #stLangBtn {
  font-family: Vazir, iranyekan, sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0;
}

/* Full label on wide screens; between 576px and 1599px the menu needs the room, so «راهنما» / «Help». */
.phShort {
  display: none;
}

@media only screen and (min-width: 576px) and (max-width: 1599px) {
  .phLong {
    display: none;
  }

  .phShort {
    display: inline;
  }
}

/* Narrow screens: the pill keeps its «?» and drops the words, so the bar still fits on one line. */
@media only screen and (max-width: 575px) {
  .phDock {
    margin: 0 0.25rem;
    gap: 0.35rem;
  }

  #phHelpBtn {
    width: 38px;
    padding: 0;
  }

  #phHelpBtn .phLabelFa,
  #phHelpBtn .phLabelEn {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   The dialog
   -------------------------------------------------------------------------- */

.phDialog {
  position: fixed;
  inset: 0;
  z-index: 1090;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 12, 16, 0.6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.phDialog[hidden] {
  display: none;
}

body.phOpen {
  overflow: hidden;
}

/* Sized against .phDialog, not the viewport: on a zoomed phone fitOverlay.js shrinks .phDialog to
   the part of the page actually on screen, and vh would still measure the whole page. */
.phBox {
  width: 100%;
  max-width: 440px;
  max-height: 100%;
  overflow-y: auto;
  background: #242a35;
  color: #e8ecf3;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.9);
  animation: phIn 0.18s ease-out;
}

@keyframes phIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.phHead {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 1.15rem 0.6rem 1.15rem;
}

.phHead .bi {
  color: #60a5fa;
  font-size: 1.25rem;
}

.phTitle {
  flex: 1 1 auto;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #f2f5fa;
}

.phClose {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #a9b3c2;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.phClose:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.phText {
  margin: 0;
  padding: 0 1.15rem 1rem 1.15rem;
  font-size: 0.92rem;
  line-height: 1.9;
  color: #cdd5e1;
}

.phBox[dir="ltr"] .phText {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.6;
}

.phBox[dir="ltr"] .phTitle {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.phFoot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.15rem 1rem 1.15rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* «راهنمای کامل»: to this page's section of Home/Guide. */
.phGuideLink {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: #93c5fd;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
}

.phGuideLink:hover {
  color: #fff;
  text-decoration: underline;
}

.phLang {
  min-width: 4.5rem;
  padding: 0.35rem 0.9rem;
  border-radius: 8px;
  border: 1px solid #3d4756;
  background: #2b3240;
  color: #e8ecf3;
  font-weight: 700;
  cursor: pointer;
}

.phLang:hover {
  border-color: #3b82f6;
  color: #fff;
}

@media only screen and (max-width: 768px) {
  .phText {
    font-size: 0.88rem;
  }
}

@media print {
  .phDock,
  .phDialog {
    display: none !important;
  }
}
