/* ==========================================================================
   RABBANI — Scholar / Admin workspace
   A different product for a different job. Experts move between many tools in
   one sitting, so this shell is denser and more utilitarian than the student
   app — deliberately. What it must never become is the old mixed sidebar: no
   lessons, no reviews, no student destinations appear here, and the rail exists
   only on workspace routes.
   ========================================================================== */

.app-body { display: flex; align-items: flex-start; inline-size: 100%; min-inline-size: 0; }
/* A flex item defaults to min-width:auto, so a wide scrolling rail or a long
   unbroken Arabic string can push the whole shell sideways. Both children opt
   out explicitly — this is what keeps the page from scrolling horizontally. */
.app-body > * { min-inline-size: 0; }
.app-main { min-inline-size: 0; inline-size: 100%; }
#workspace-rail-slot:empty { display: none; }

/* A cooler, flatter ground so the workspace never reads as the student app. */
body.in-workspace { background: var(--surface-sunken); }
body.in-workspace .app-main { background: var(--surface-sunken); }

/* ---- The rail ------------------------------------------------------------ */
.ws-rail {
  position: sticky; inset-block-start: var(--topnav-h);
  inline-size: 232px; flex-shrink: 0;
  max-block-size: calc(100vh - var(--topnav-h));
  overflow-y: auto;
  padding: var(--s-5) var(--s-3);
  background: var(--surface);
  border-inline-end: 1px solid var(--line-hair);
}
.ws-rail-title {
  margin: 0 var(--s-3) var(--s-3);
  font-size: var(--fs-micro); font-weight: var(--fw-bold);
  letter-spacing: 0.14em; color: var(--ink-400);
}
.ws-rail-item {
  display: block; padding: var(--s-3);
  font-size: var(--fs-sm); color: var(--ink-700); text-decoration: none;
  border-radius: var(--r-sm); border-inline-start: 2px solid transparent;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.ws-rail-item:hover { background: var(--green-50); color: var(--green-800); }
/* Current tool marked by weight and a rule, never by colour alone. */
.ws-rail-item.active {
  background: var(--green-50); color: var(--green-800);
  font-weight: var(--fw-bold); border-inline-start-color: var(--green-700);
}

/* ---- Banner -------------------------------------------------------------- */
/* Standing, unmissable, and it carries the way out. */
.workspace-banner { position: sticky; inset-block-start: 0; z-index: 65; }

/* ---- Density ------------------------------------------------------------
   Expert screens earn their density: tighter cards, tighter type, wider
   measure. Still the same tokens — this is a different setting of one system,
   not a second design language. */
body.in-workspace .page { padding-block: var(--s-6) var(--s-12); max-inline-size: none; }
body.in-workspace .scholarly-card,
body.in-workspace .card { padding: var(--s-5); border-radius: var(--r-md); }
body.in-workspace .page-header { margin-block-end: var(--s-6); }
body.in-workspace h1 { font-size: var(--fs-h2); }
body.in-workspace h2 { font-size: var(--fs-h3); }
body.in-workspace table { font-size: var(--fs-sm); }

@media (max-width: 960px) {
  /* The rail becomes a horizontal strip rather than eating a narrow screen. */
  .app-body { flex-direction: column; }
  .ws-rail {
    position: static; inline-size: 100%; max-inline-size: 100%; max-block-size: none;
    display: flex; gap: var(--s-1); overflow-x: auto;
    padding: var(--s-2) var(--s-3);
    border-inline-end: 0; border-block-end: 1px solid var(--line-hair);
    scrollbar-width: none;
  }
  .ws-rail::-webkit-scrollbar { display: none; }
  .ws-rail-title { display: none; }
  .ws-rail-item {
    white-space: nowrap; border-inline-start: 0; border-block-end: 2px solid transparent;
    border-radius: var(--r-sm) var(--r-sm) 0 0; min-block-size: 40px;
    display: flex; align-items: center;
  }
  .ws-rail-item.active { border-inline-start: 0; border-block-end-color: var(--green-700); }
}

/* ---- Scholar readiness ----------------------------------------------------
   Two different authorities are reported here — an RBAC permission and a
   per-science scholarly authorization — so each line states which one it is.
   Never colour alone: the mark carries the state as a glyph too. */
.readiness-list { display: flex; flex-direction: column; gap: var(--s-3); }
.readiness-row { display: flex; align-items: flex-start; gap: var(--s-3); }
.readiness-mark {
  flex: 0 0 auto;
  inline-size: 1.5rem; block-size: 1.5rem;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: var(--fs-caption); font-weight: var(--fw-bold);
}
.readiness-row.is-ok .readiness-mark { background: var(--ok-bg); color: var(--ok); }
.readiness-row.is-pending .readiness-mark { background: var(--locked-bg); color: var(--locked); }
.readiness-body { display: flex; flex-direction: column; gap: 2px; min-inline-size: 0; }
.readiness-label { color: var(--ink-900); }
.readiness-row.is-pending .readiness-label { color: var(--ink-500); }

/* ---- Signature pad --------------------------------------------------------
   Sized by its container, drawn at 2x so a signature made on a phone still
   prints cleanly on an A4 certificate. */
.sig-pad { display: flex; flex-direction: column; gap: var(--s-2); }
.sig-canvas {
  inline-size: 100%;
  block-size: auto;
  aspect-ratio: 3.2 / 1;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  touch-action: none;           /* the pad owns the gesture, not the scroller */
  cursor: crosshair;
}
.sig-file { font: inherit; font-size: var(--fs-sm); color: var(--ink-700); }
.sig-preview-img {
  max-inline-size: 100%;
  block-size: auto;
  max-block-size: 120px;
  /* A transparent PNG needs a ground to be legible; this mirrors the
     certificate's parchment rather than the app surface. */
  background: var(--ivory-deep);
  border: 1px solid var(--line-hair);
  border-radius: var(--radius-sm);
  padding: var(--s-3);
}
.sig-version {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4); padding-block: var(--s-3);
  border-block-end: 1px solid var(--line-hair);
}
.sig-version:last-child { border-block-end: 0; }
.sig-version-body { display: flex; flex-direction: column; gap: 2px; min-inline-size: 0; }
.sig-version-title { font-weight: var(--fw-bold); color: var(--ink-900); }
.sig-version.is-active .sig-version-title { color: var(--green-800); }

/* ---- Availability --------------------------------------------------------- */
.avail-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4); padding-block: var(--s-3);
  border-block-end: 1px solid var(--line-hair);
}
.avail-row:last-child { border-block-end: 0; }
.avail-body { display: flex; flex-direction: column; gap: 2px; min-inline-size: 0; }
.avail-day { font-weight: var(--fw-bold); color: var(--ink-900); }
.avail-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  gap: var(--s-4);
}

.confirm-card { border: 1px solid var(--gold-500); }
.row.wrap { flex-wrap: wrap; gap: var(--s-3); }


/* R6 scientific-evidence reviewer surface */
.evidence-arabic-text {
  font-family: var(--font-arabic-heading);
  font-size: 1.15rem;
  line-height: 2.1;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: var(--space-3) 0;
  padding: var(--space-3) var(--space-4);
  border-inline-start: 3px solid var(--border-strong);
  background: var(--bg-surface-alt);
  border-radius: var(--radius-md);
}
.evidence-anchor-editor {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-3);
}
.evidence-field {
  display: grid;
  gap: var(--space-1);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}
.evidence-anchor-editor .btn {
  justify-self: start;
}
@media (max-width: 640px) {
  .evidence-arabic-text { font-size: 1.05rem; line-height: 2; }
  .evidence-anchor-editor .btn { inline-size: 100%; white-space: normal; }
}
