/* Pharmacy lecture pages — Khalid Turkish style gallery and isolated page viewer. */

.mrph-pages-library-root {
  --pages-navy: #061b3f;
  --pages-navy-2: #0a2f4c;
  --pages-cyan: #22bfd6;
  --pages-cyan-soft: #65dce9;
  --pages-text: #102b45;
  --pages-muted: #6b7c89;
  --pages-line: rgba(16, 69, 96, .15);
  width: 100%;
  min-width: 0;
  direction: ltr;
}

html[dir="rtl"] .mrph-pages-library-root { direction: rtl; }

.mrph-pages-library-root *,
.mrph-pages-library-root *::before,
.mrph-pages-library-root *::after,
.mrph-page-viewer *,
.mrph-page-viewer *::before,
.mrph-page-viewer *::after { box-sizing: border-box; }

.mrph-pages-loading,
.mrph-pages-error {
  min-height: 420px;
  display: grid;
  place-items: center;
  padding: 32px;
  border: 1px solid var(--pages-line);
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 0%, rgba(34,191,214,.10), transparent 35%),
    linear-gradient(145deg, rgba(255,255,255,.99), rgba(242,250,252,.96));
  text-align: center;
}

.mrph-pages-loading-inner,
.mrph-pages-error-inner {
  width: min(560px, 100%);
  display: grid;
  justify-items: center;
  gap: 13px;
}

.mrph-pages-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(19,88,114,.12);
  border-top-color: var(--pages-cyan);
  border-radius: 50%;
  animation: mrph-pages-spin-v28 .78s linear infinite;
}

@keyframes mrph-pages-spin-v28 { to { transform: rotate(360deg); } }

.mrph-pages-loading strong,
.mrph-pages-error h3 {
  margin: 0;
  color: var(--pages-text);
  font-size: clamp(22px, 3vw, 32px);
}

.mrph-pages-loading p,
.mrph-pages-error p {
  margin: 0;
  color: var(--pages-muted);
  line-height: 1.8;
}

.mrph-pages-progress {
  width: min(360px, 82vw);
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(8,68,93,.10);
}

.mrph-pages-progress > span {
  display: block;
  width: var(--pages-progress, 8%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pages-cyan-soft), var(--pages-cyan));
  transition: width .18s ease;
}

.mrph-pages-error-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 19px;
  background: linear-gradient(145deg, #0b3655, #087c93);
  color: #fff;
  font-size: 28px;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(4,54,78,.20);
}

.mrph-pages-error .primary {
  min-height: 46px;
  padding: 10px 20px;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(135deg, #5adeea, #1ebdd4);
  color: #06243a;
  font: inherit;
  font-weight: 900;
}

#view-pages.mrph-pages-library {
  display: grid;
  gap: 22px;
  min-width: 0;
}

.mrph-pages-library-head {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 28px;
  border: 1px solid rgba(29,95,122,.16);
  border-radius: 28px;
  background:
    radial-gradient(circle at 92% 0%, rgba(54,208,224,.12), transparent 34%),
    linear-gradient(145deg, rgba(255,255,255,.99), rgba(241,249,251,.96));
  box-shadow: 0 18px 44px rgba(9,48,68,.09);
}

html[dir="rtl"] .mrph-pages-library-head {
  background:
    radial-gradient(circle at 8% 0%, rgba(54,208,224,.12), transparent 34%),
    linear-gradient(145deg, rgba(255,255,255,.99), rgba(241,249,251,.96));
}

.mrph-pages-library-head::after {
  content: "";
  position: absolute;
  width: 260px;
  height: 260px;
  inset: auto -90px -180px auto;
  border: 1px solid rgba(36,193,214,.13);
  border-radius: 50%;
  pointer-events: none;
}

html[dir="rtl"] .mrph-pages-library-head::after { inset: auto auto -180px -90px; }

.mrph-pages-library-copy {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.mrph-pages-library-copy > span {
  display: block;
  margin-bottom: 7px;
  color: #22879a;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.mrph-pages-library-copy h3 {
  margin: 0;
  color: var(--pages-text);
  font-size: clamp(26px, 3.8vw, 43px);
  line-height: 1.15;
  letter-spacing: -.025em;
}

.mrph-pages-library-copy p {
  max-width: 780px;
  margin: 9px 0 0;
  color: var(--pages-muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.8;
}

.mrph-pages-library-count {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  min-width: 108px;
  min-height: 94px;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 13px;
  border: 1px solid rgba(29,184,205,.22);
  border-radius: 23px;
  background: linear-gradient(145deg, rgba(7,49,76,.96), rgba(9,111,130,.88));
  box-shadow: 0 16px 32px rgba(7,62,83,.18), inset 0 1px 0 rgba(255,255,255,.13);
  color: #fff;
  text-align: center;
}

.mrph-pages-library-count strong {
  display: block;
  font-size: 30px;
  line-height: 1;
}

.mrph-pages-library-count span {
  display: block;
  margin-top: 6px;
  color: rgba(255,255,255,.72);
  font-size: 11px;
  font-weight: 800;
}

#thumbs.mrph-pages-gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  min-width: 0;
}

.page-gallery-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(16,69,96,.15);
  border-radius: 24px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 13px 30px rgba(8,45,64,.09);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.page-gallery-card:hover,
.page-gallery-card:focus-within {
  transform: translateY(-3px);
  border-color: rgba(30,190,212,.48);
  box-shadow: 0 20px 42px rgba(8,57,77,.14);
}

.page-gallery-card > button {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  margin: 0;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.page-gallery-preview {
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  background: linear-gradient(145deg, #e8f1f3, #f8fbfc);
  color: var(--pages-text);
  text-align: start;
}

.page-gallery-thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background:
    linear-gradient(90deg, transparent 0 48%, rgba(33,180,200,.04) 48% 52%, transparent 52%),
    linear-gradient(#edf5f6, #f9fcfd);
}

.page-gallery-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.5);
}

.page-gallery-thumb canvas {
  display: block;
  max-width: calc(100% - 12px);
  max-height: calc(100% - 12px);
  border-radius: 5px;
  background: #fff;
  box-shadow: 0 10px 25px rgba(7,40,56,.16);
}

.page-gallery-thumb > i {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(30,128,146,.13);
  border-top-color: rgba(31,187,209,.82);
  border-radius: 50%;
  animation: mrph-pages-spin-v28 .82s linear infinite;
}

.page-gallery-index {
  position: absolute;
  inset: 12px auto auto 12px;
  min-width: 62px;
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.34);
  border-radius: 999px;
  background: rgba(5,34,58,.80);
  backdrop-filter: blur(10px);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 7px 18px rgba(4,28,45,.20);
}

html[dir="rtl"] .page-gallery-index { inset: 12px 12px auto auto; }

.page-gallery-card > .primary {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 11px 10px;
  border: 0;
  border-top: 1px solid rgba(16,69,96,.11);
  background: rgba(255,255,255,.98);
  color: #173b54;
  font-weight: 900;
  line-height: 1.15;
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
  text-wrap: nowrap;
}

.page-gallery-card:hover > .primary,
.page-gallery-card:focus-within > .primary {
  background: linear-gradient(135deg, rgba(94,220,234,.18), rgba(31,188,211,.12));
  color: #0a6073;
}

html:has(.mrph-page-viewer),
body:has(.mrph-page-viewer) {
  overscroll-behavior: none !important;
}

.mrph-page-viewer {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483600 !important;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto !important;
  width: 100vw !important;
  height: 100dvh !important;
  overflow: hidden !important;
  direction: ltr;
  background:
    radial-gradient(circle at 84% 0%, rgba(32,183,207,.14), transparent 34%),
    linear-gradient(145deg, #050b12, #071827 55%, #06111c) !important;
  color: #fff !important;
  touch-action: none !important;
  overscroll-behavior: contain !important;
  -webkit-user-select: none !important;
  user-select: none !important;
}

html[dir="rtl"] .mrph-page-viewer { direction: rtl; }

.mrph-page-viewer-bar {
  position: relative;
  z-index: 5;
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(160px, auto) minmax(0, 1fr) minmax(220px, auto);
  align-items: center;
  gap: 14px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid rgba(255,255,255,.10);
  background: rgba(6,16,27,.90);
  backdrop-filter: blur(20px);
  box-shadow: 0 12px 30px rgba(0,0,0,.26);
}

.mrph-page-viewer-back,
.mrph-page-viewer-tools button,
.mrph-page-viewer-footer button,
.mrph-page-viewer-footer select {
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.08);
  color: #fff;
  font: inherit;
  font-weight: 900;
  touch-action: manipulation;
}

.mrph-page-viewer-back {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  padding: 8px 14px;
  border-radius: 15px;
  cursor: pointer;
}

.mrph-page-viewer-back span {
  font-size: 29px;
  line-height: .7;
}

html[dir="rtl"] .mrph-page-viewer-back span { transform: rotate(180deg); }

.mrph-page-viewer-title {
  min-width: 0;
  text-align: center;
}

.mrph-page-viewer-title > span {
  display: block;
  overflow: hidden;
  color: rgba(255,255,255,.62);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .15em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.mrph-page-viewer-title strong {
  display: block;
  margin-top: 4px;
  color: #fff;
  font-size: 16px;
  line-height: 1.2;
}

.mrph-page-viewer-title i {
  color: #69dfeb;
  font-style: normal;
}

.mrph-page-viewer-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.mrph-page-viewer-tools button {
  min-width: 42px;
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 7px 10px;
  border-radius: 13px;
  cursor: pointer;
}

.mrph-page-viewer-tools > span {
  min-width: 58px;
  color: rgba(255,255,255,.80);
  text-align: center;
  font-size: 12px;
  font-weight: 900;
}

.mrph-page-viewer-tools .mrph-page-viewer-close {
  border-color: rgba(96,222,235,.30);
  background: linear-gradient(145deg, rgba(53,199,218,.22), rgba(13,99,122,.32));
  font-size: 24px;
  line-height: 1;
}

.mrph-page-viewer-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 50%, rgba(35,83,105,.23), transparent 45%),
    #03070c;
  touch-action: pan-y;
  cursor: default;
}

.mrph-page-viewer-stage.is-zoomed {
  touch-action: none;
  cursor: grab;
}

.mrph-page-viewer-stage.is-dragging { cursor: grabbing; }

.mrph-page-viewer-anchor {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.mrph-page-viewer-surface {
  position: relative;
  overflow: hidden;
  transform-origin: center center;
  will-change: transform;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 26px 80px rgba(0,0,0,.58), 0 0 0 1px rgba(255,255,255,.10);
  pointer-events: none;
}

.mrph-page-viewer-surface canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  background: #fff;
  -webkit-user-drag: none;
}

.mrph-page-viewer-status {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2,7,12,.72);
  backdrop-filter: blur(5px);
  color: rgba(255,255,255,.84);
  font-weight: 900;
}

.mrph-page-viewer-status[hidden] { display: none; }

.mrph-page-viewer-footer {
  position: relative;
  z-index: 5;
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(110px, 170px) minmax(140px, 190px) minmax(110px, 170px) minmax(0, 1fr);
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,.10);
  background: rgba(6,16,27,.92);
  backdrop-filter: blur(20px);
}

.mrph-page-viewer-footer button,
.mrph-page-viewer-footer select {
  width: 100%;
  min-height: 45px;
  padding: 9px 13px;
  border-radius: 14px;
}

.mrph-page-viewer-footer button { cursor: pointer; }

.mrph-page-viewer-footer button.primary {
  border-color: transparent;
  background: linear-gradient(135deg, #62deeb, #1cbdd5);
  color: #06243a;
}

.mrph-page-viewer-footer button:disabled {
  opacity: .35;
  cursor: default;
}

.mrph-page-viewer-footer label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: rgba(255,255,255,.62);
  font-size: 11px;
  font-weight: 900;
}

.mrph-page-viewer-footer select {
  min-width: 0;
  color-scheme: dark;
  cursor: pointer;
}

.mrph-page-viewer-footer p {
  margin: 0;
  color: rgba(255,255,255,.56);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.6;
  text-align: end;
}

@media (max-width: 1180px) {
  #thumbs.mrph-pages-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  #thumbs.mrph-pages-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .mrph-pages-library-head { padding: 22px; }
  .mrph-page-viewer-bar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    min-height: 64px;
    padding-inline: 10px;
  }
  .mrph-page-viewer-back { min-width: 44px; width: 44px; padding: 7px; justify-content: center; }
  .mrph-page-viewer-back b { display: none; }
  .mrph-page-viewer-tools button { min-width: 38px; min-height: 38px; padding: 6px; }
  .mrph-page-viewer-tools > span { min-width: 48px; }
  .mrph-page-viewer-footer {
    grid-template-columns: 1fr minmax(125px, 170px) 1fr;
    min-height: 66px;
    padding-inline: 10px;
  }
  .mrph-page-viewer-footer p { display: none; }
}

@media (max-width: 560px) {
  .mrph-pages-library-head {
    align-items: flex-start;
    padding: 19px;
    border-radius: 23px;
  }
  .mrph-pages-library-copy p { font-size: 13px; }
  .mrph-pages-library-count {
    min-width: 76px;
    min-height: 76px;
    border-radius: 20px;
  }
  .mrph-pages-library-count strong { font-size: 25px; }
  #thumbs.mrph-pages-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .page-gallery-card { border-radius: 18px; }
  .page-gallery-card > .primary { min-height: 45px; padding: 9px 5px; font-size: 12px; }
  .page-gallery-index { inset: 8px auto auto 8px; min-width: 52px; padding: 6px 8px; font-size: 10px; }
  html[dir="rtl"] .page-gallery-index { inset: 8px 8px auto auto; }
  .mrph-page-viewer-bar { gap: 7px; }
  .mrph-page-viewer-title > span { display: none; }
  .mrph-page-viewer-title strong { margin: 0; font-size: 13px; }
  .mrph-page-viewer-tools button[data-viewer-action="zoom-out"],
  .mrph-page-viewer-tools button[data-viewer-action="zoom-in"],
  .mrph-page-viewer-tools button[data-viewer-action="reset"],
  .mrph-page-viewer-tools > span { display: none; }
  .mrph-page-viewer-footer {
    grid-template-columns: 1fr minmax(105px, 145px) 1fr;
    gap: 7px;
  }
  .mrph-page-viewer-footer button,
  .mrph-page-viewer-footer select { min-height: 42px; padding: 7px 8px; font-size: 12px; }
  .mrph-page-viewer-footer label > span { display: none; }
  .mrph-page-viewer-footer label { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .page-gallery-card,
  .mrph-pages-progress > span { transition: none; }
  .mrph-pages-spinner,
  .page-gallery-thumb > i { animation-duration: 1.5s; }
}
