/* ShiftCore — light-blue glass UI (own style, same family as FitCore2 Phase 2.5).
 * RTL Persian, Vazirmatn font with Tahoma fallback for offline use. */

html { font-size: 14px; }
@media (min-width: 768px) { html { font-size: 16px; } }

html { position: relative; min-height: 100%; }

body {
    display: flex;
    flex-direction: column;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    margin-bottom: 0;
    background: linear-gradient(135deg, #dbeafe 0%, #eff6ff 45%, #e0f2fe 100%);
    background-attachment: fixed;
    color: #1e3a5f;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus,
.form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

/* --- Glass surfaces --- */
.glass-nav {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(147, 197, 253, 0.55);
    box-shadow: 0 4px 24px rgba(37, 99, 235, 0.12);
}
.glass-nav .navbar-brand { color: #1d4ed8; }
.glass-nav .nav-link { color: #1e40af; font-weight: 500; }
.glass-nav .nav-link:hover { color: #0c4a6e; }

.glass-card {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(147, 197, 253, 0.5);
    border-radius: 1rem;
    box-shadow: 0 8px 28px rgba(37, 99, 235, 0.10);
}

.btn-glass {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.9), rgba(14, 165, 233, 0.9));
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 0.75rem;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
    font-weight: 500;
}
.btn-glass:hover, .btn-glass:focus { color: #fff; filter: brightness(1.08); }
.btn-glass-outline {
    background: rgba(255, 255, 255, 0.7);
    color: #1d4ed8;
    border: 1px solid #93c5fd;
    border-radius: 0.75rem;
    font-weight: 500;
}
.btn-glass-outline:hover { background: rgba(219, 234, 254, 0.9); color: #1e40af; }

.seed-banner {
    background: rgba(255, 251, 235, 0.85);
    border: 1px solid #fcd34d;
    border-radius: 0.75rem;
    font-size: 0.9rem;
}

.shift-badge {
    color: #1e3a5f;
    font-size: 0.85rem;
    font-weight: 500;
    margin-inline-start: 0.25rem;
    border: 1px solid rgba(30, 58, 95, 0.15);
}

/* --- Roster grid: sticky header + sticky name/stats columns + sticky shortage row (Phase 5) ---
   Layout (RTL: the right edge is the start): name column 11rem, then six 3.2rem
   stat columns; their sticky `right` offsets are fixed so they never drift.
   The header row's height is content-driven (day number + weekday line),
   so the shortage row sticks at the measured --roster-header-h (see below),
   not at a fixed offset. */
/* --- Roster layout (Ali 2026-11-23): viewport-filling shell ---
   The previous fix (2026-11-22) pinned .roster-wrap itself below the
   toolbar — but a sticky element stays pinned as long as its containing
   block extends below it, so the help text, fairness meter and handover
   card scrolled up UNDER the opaque pinned grid and were never readable
   (measured live: at max page scroll the handover card sat in the
   viewport yet elementFromPoint hit a grid cell). The shell below fixes
   it: toolbar + grid + resize handle + bottom panel live in ONE flex
   column (.roster-shell) pinned at the top of the viewport and exactly
   viewport-minus-footer tall, so the page barely scrolls on the roster
   page and the below-grid content sits INSIDE the shell, below the grid,
   in its own scrollable panel — never behind it. (Phase 14: the toolbar
   left the shell — it scrolls away with the page so the days row sits
   directly under the navbar; the shell now holds only grid + handle +
   bottom panel.) The shell height is
   the viewport minus the fixed footer reserve (61px: 60px line-height +
   1px border); roster-grid.js measures the real footer height live and
   sets --roster-shell-h (on a phone the footer wraps to two lines, so a
   hardcoded 61px would let the shell slide up under the toolbar again).
   The grid takes the remaining space by default (flex: 1) and the panel
   gets 200px; dragging the handle sets an explicit grid height
   (.roster-shell--sized + --roster-grid-h, persisted per ward).
   roster-grid.js also sets the height of the .roster-shell-spacer div
   after the shell: without it the document ends ~41px below the shell,
   so the page can only scroll to 20px short of the shell's natural
   top on desktop (more on a phone, where the footer wraps) and the
   shell never quite reaches top:0; the spacer is measured live from
   the real footer height. Print hides it. */
.roster-shell {
    position: sticky;
    /* Phase 13 — the main navbar is sticky now (see shiftcore.css:
       .shiftcore-header), so the shell sticks directly BELOW it, not
       at viewport top:0. The offset is the navbar's real measured
       height (--roster-shell-top, set by layoutRosterShell in
       roster-grid.js — the navbar wraps on small screens and grows
       when its mobile menu opens, so it is measured live, never
       hardcoded). 0px is the no-JS fallback. */
    top: var(--roster-shell-top, 0px);
    z-index: 20;
    display: flex;
    flex-direction: column;
    height: var(--roster-shell-h, calc(100dvh - 61px));
    overflow: hidden;
}
.roster-shell > .roster-staff-tools {
    flex: 0 0 auto;
    background: #fff;
    border-bottom: 1px solid #bfdbfe;
}
.roster-wrap {
    overflow: auto;
    flex: 1 1 auto;
    min-height: 0;
    background: #fff;
    border-radius: 1rem;
}
/* A user-chosen grid height (drag handle / keyboard): the wrapper takes
   exactly that height and the bottom panel takes the rest. */
.roster-shell--sized .roster-wrap {
    flex: 0 0 auto;
    height: var(--roster-grid-h);
}
/* Bottom panel collapsed (toggle on the handle): the grid fills the shell. */
.roster-shell--panel-collapsed .roster-bottom-panel { display: none; }
.roster-shell--panel-collapsed .roster-wrap { flex: 1 1 auto; height: auto; }

/* --- Roster layout — drag handle between the grid and the bottom panel ---
   A visible full-width grip bar (not the native corner grip): drag with
   mouse or touch (Pointer Events + touch-action: none so a touch drag
   never scrolls the page), arrow keys when focused (±24px, PageUp/
   PageDown ±120px, Home/End min/max), double-click resets to the default
   height. The chosen height persists per ward (localStorage). */
.roster-resize-handle {
    flex: 0 0 auto;
    height: 30px;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 0.75rem;
    background: linear-gradient(#dbeafe, #bfdbfe);
    border: 1px solid #93c5fd;
    border-radius: 0.75rem;
    cursor: row-resize;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.roster-resize-handle:hover { background: linear-gradient(#bfdbfe, #93c5fd); }
.roster-resize-handle:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.roster-resize-handle--dragging { background: linear-gradient(#93c5fd, #60a5fa); cursor: grabbing; }
.roster-resize-handle .resize-grip { display: flex; flex-direction: column; gap: 2px; flex: 0 0 auto; }
.roster-resize-handle .resize-grip span { display: block; width: 36px; height: 2px; background: #1e40af; border-radius: 1px; opacity: 0.55; }
.roster-resize-handle .resize-hint { font-size: 0.85rem; color: #1e40af; flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roster-resize-handle .roster-panel-toggle { flex: 0 0 auto; cursor: pointer; }

/* --- Roster layout — bottom panel: help text + fairness meter + handover ---
   Always visible below the grid, with its own vertical scroll (the
   fairness table alone is 74 rows in the demo ward). Default 200px tall;
   when the grid has an explicit height the panel takes the rest. */
.roster-bottom-panel {
    flex: 0 0 200px;
    min-height: 100px;
    overflow-y: auto;
    padding-top: 0.25rem;
}
.roster-shell--sized .roster-bottom-panel { flex: 1 1 auto; }
/* Short viewport (a 1366x768 laptop, a phone in landscape): the panel's
   default 200px would squeeze the grid below ~6 rows, so the panel
   starts at 120px and the grid keeps its rows. Sized mode is unaffected
   (the sized rule above wins on specificity) — the drag still decides. */
@media (max-height: 900px) {
    .roster-bottom-panel { flex: 0 0 120px; }
}
/* Roster layout — bottom spacer div after the shell (height set live by
   roster-grid.js from the measured footer; 0 by default). It must be a
   separate element, not a margin on the shell (see Index.cshtml). */
.roster-shell-spacer { height: 0; }
.roster-grid { border-collapse: separate; border-spacing: 0; min-width: 100%; }
.roster-grid th, .roster-grid td {
    border: 1px solid #bfdbfe;
    text-align: center;
    vertical-align: middle;
    padding: 0.35rem 0.4rem;
    background: #fff;
    white-space: nowrap;
}
.roster-grid thead tr.header-row th {
    position: sticky;
    top: 0;
    z-index: 4;
    background: #dbeafe;
    font-weight: 700;
    height: 3.4rem;
}
.roster-grid thead tr.shortage-row th,
.roster-grid thead tr.shortage-row td {
    position: sticky;
    /* The header row's height is content-driven (day number + weekday
       line ≈ 61px, not the 3.4rem minimum), so the shortage row sticks
       at the MEASURED header height (--roster-header-h, set by
       layoutRosterShell in roster-grid.js) instead of a fixed 3.4rem,
       which left a ~7px overlap. 3.4rem stays as the no-JS fallback. */
    top: var(--roster-header-h, 3.4rem);
    z-index: 3;
    background: #eff6ff;
    font-weight: 700;
}
.roster-grid thead tr.shortage-row td.shortage { background: #fee2e2; color: #991b1b; }
/* Phase 10 — surplus in the shortage row: green, distinct from the red
   shortage. A cell with both shows red ⚠ N and green ▲ +N side by side;
   a surplus-only cell gets the green tint. */
.roster-grid thead tr.shortage-row td.surplus { background: #dcfce7; color: #166534; }
.roster-grid thead tr.shortage-row td.shortage.surplus { background: linear-gradient(135deg, #fee2e2 50%, #dcfce7 50%); }
.roster-grid td.shortage-cell .sh-short { color: #991b1b; font-weight: 700; }
.roster-grid td.shortage-cell .sh-surplus { color: #166534; font-weight: 700; }

/* Phase 11 — cell combobox: a fixed-position listbox on <body> (z 1070,
   above modals), parked next to the clicked cell by roster-grid.js
   (computeAnchor: 16px offset, flip at viewport edges; centred below
   576px). The list itself scrolls when the space is short. */
.cell-combo {
    position: fixed;
    z-index: 1070;
    background: #fff;
    border: 1px solid #93c5fd;
    border-radius: 0.75rem;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.25);
    padding: 0.5rem;
    overflow-y: auto;
    direction: rtl;
}
.cell-combo .combo-title { font-weight: 700; padding: 0.25rem 0.5rem 0.5rem; border-bottom: 1px solid #e5e7eb; margin-bottom: 0.25rem; }
.cell-combo .combo-fixed { background: #eff6ff; color: #1e40af; border-radius: 0.5rem; padding: 0.4rem 0.5rem; margin-bottom: 0.25rem; font-size: 0.9rem; }
.cell-combo .combo-leave { background: #fef3c7; border-radius: 0.5rem; padding: 0.4rem 0.5rem; margin-bottom: 0.25rem; font-size: 0.9rem; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; justify-content: space-between; }
.cell-combo .combo-item { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.25rem 0.5rem; padding: 0.45rem 0.5rem; border-radius: 0.5rem; cursor: pointer; }
.cell-combo .combo-chip { flex: 0 0 auto; width: 0.85rem; height: 0.85rem; border-radius: 0.25rem; border: 1px solid rgba(0, 0, 0, 0.15); }
.cell-combo .combo-label { flex: 1 1 auto; }
.cell-combo .combo-reason { flex: 1 1 100%; font-size: 0.85rem; color: #92400e; background: #fef3c7; border-radius: 0.35rem; padding: 0.15rem 0.4rem; white-space: normal; }
/* Phase 14 — short description under each option (sample image layout),
   and the YELLOW warning box under a still-selectable option (a soft /
   policy warning, e.g. rest below the ward's 11h minimum — the option
   stays choosable; a hard violation keeps the disabled-with-reason row
   above). The role badge sits in the combobox title, next to the name. */
.cell-combo .combo-desc { flex: 1 1 100%; font-size: 0.82rem; color: #6b7280; white-space: normal; }
.cell-combo .combo-warning { flex: 1 1 100%; font-size: 0.85rem; color: #92400e; background: #fef3c7; border: 1px solid #f59e0b; border-radius: 0.35rem; padding: 0.3rem 0.4rem; white-space: normal; }
.cell-combo .combo-warning::before { content: "⚠ "; }
.cell-combo .combo-role { display: inline-block; background: #dbeafe; color: #1e40af; border-radius: 0.35rem; font-size: 0.8rem; font-weight: 700; padding: 0.1rem 0.4rem; margin-inline-start: 0.35rem; vertical-align: middle; }
.cell-combo .combo-request { border-radius: 0.5rem; padding: 0.4rem 0.5rem; margin-bottom: 0.25rem; font-size: 0.9rem; }
.cell-combo .combo-request-honored { background: #dcfce7; color: #166534; }
.cell-combo .combo-request-not-honored { background: #fef3c7; color: #92400e; }
.cell-combo .combo-request-pending { background: #f3f4f6; color: #374151; }
.cell-combo .combo-reminders { background: #fffbeb; border: 1px solid #f59e0b; border-radius: 0.5rem; padding: 0.4rem 0.5rem; margin-bottom: 0.25rem; font-size: 0.9rem; }
.cell-combo .combo-reminders h6 { margin: 0 0 0.25rem; font-size: 0.9rem; color: #92400e; }
.cell-combo .combo-reminders ul { margin: 0; padding-inline-start: 1.1rem; }
.cell-combo .combo-override-delete { width: 100%; margin-top: 0.25rem; }

/* Phase 14 — reminders inside the staff-detail modal (head nurse only):
   add form + list with a resolve button per reminder. */
.sd-reminders { margin-top: 0.5rem; }
.sd-reminders .sd-reminder-item { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; background: #fffbeb; border: 1px solid #f59e0b; border-radius: 0.5rem; padding: 0.4rem 0.5rem; margin-bottom: 0.35rem; font-size: 0.92rem; }
.sd-reminders .sd-reminder-item small { color: #92400e; }
.cell-combo .combo-item:hover, .cell-combo .combo-item.combo-focused { background: #dbeafe; outline: none; }
.cell-combo .combo-item.combo-disabled { cursor: not-allowed; color: #6b7280; }
.cell-combo .combo-item.combo-disabled:hover { background: transparent; }
.cell-combo .combo-clear { border-top: 1px solid #e5e7eb; margin-top: 0.25rem; }
.cell-combo .combo-leave-add { color: #92400e; }
.cell-combo .combo-leave-form { border-top: 1px solid #e5e7eb; margin-top: 0.25rem; padding-top: 0.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.cell-combo .combo-error { margin-top: 0.5rem; padding: 0.4rem 0.5rem; border-radius: 0.5rem; font-size: 0.9rem; }
.cell-combo .combo-error-danger { background: #fee2e2; color: #991b1b; }
.cell-combo .combo-error-info { background: #dcfce7; color: #166534; }
/* Phase 11 — fixed-shift cell: solid blue outline + a small «ثابت» badge. */
.roster-grid td.cell.fixed { outline: 2px solid #2563eb; outline-offset: -2px; }
.roster-grid td.cell .fixed-badge { display: inline-block; background: #2563eb; color: #fff; border-radius: 0.35rem; font-size: 0.6rem; font-weight: 700; padding: 0 0.25rem; margin-right: 0.2rem; vertical-align: middle; }
.roster-grid .stick-name {
    position: sticky;
    /* Phase 13 — the row-number column (2.6rem) now sits at the RTL
       start (far right), so the name column starts at right:2.6rem
       instead of 0. The six stat columns shift by the same 2.6rem. */
    right: 2.6rem;
    width: 11rem;
    min-width: 11rem;
    max-width: 11rem;
    overflow: hidden;
    text-overflow: ellipsis;
    background: #eff6ff;
    text-align: right;
}
.roster-grid thead tr.header-row th.stick-name { z-index: 5; background: #dbeafe; }
.roster-grid thead tr.shortage-row th.stick-name { z-index: 4; }
.roster-grid tbody th.stick-name { z-index: 2; }

/* Phase 13 — row-number column: narrow sticky column at the RTL start
   (far right), before the name column; visible on desktop, mobile and
   in print. z-index is one above the name column at each row so the
   corner cells stack correctly when scrolling both ways. */
.roster-grid .row-num {
    position: sticky;
    right: 0;
    width: 2.6rem;
    min-width: 2.6rem;
    max-width: 2.6rem;
    text-align: center;
    padding-left: .25rem;
    padding-right: .25rem;
    background: #eff6ff;
}
.roster-grid thead tr.header-row th.row-num { z-index: 6; background: #dbeafe; }
.roster-grid thead tr.shortage-row td.row-num { z-index: 5; color: #94a3b8; }
.roster-grid tbody td.row-num { z-index: 3; color: #475569; font-weight: 600; }

/* Phase 13 — the staff name is a real button ONLY for the verified head
   nurse (opens the staff-detail modal); everyone else sees plain text.
   The button looks like the name text (no chrome) so the grid layout
   is identical in both cases. */
.staff-detail-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: #0b3d91;
    text-decoration: underline dotted;
    cursor: pointer;
    text-align: inherit;
}
.staff-detail-btn:hover, .staff-detail-btn:focus-visible { color: #2563eb; }
.staff-detail-btn:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }

.roster-grid .stat-col {
    position: sticky;
    width: 3.2rem;
    min-width: 3.2rem;
    max-width: 3.2rem;
    background: #eff6ff;
    font-weight: 700;
}
/* Phase 13 — shifted +2.6rem for the row-number column. */
.roster-grid .stat-1 { right: 13.6rem; }
.roster-grid .stat-2 { right: 16.8rem; }
.roster-grid .stat-3 { right: 20rem; }
.roster-grid .stat-4 { right: 23.2rem; }
.roster-grid .stat-5 { right: 26.4rem; }
.roster-grid .stat-6 { right: 29.6rem; }
.roster-grid thead tr.header-row th.stat-col { z-index: 5; background: #dbeafe; }
.roster-grid thead tr.shortage-row td.stat-col { z-index: 4; }
.roster-grid tbody td.stat-col { z-index: 2; }
.roster-grid th.holiday-col, .roster-grid td.holiday-col { background: #fef2f2; }
.roster-grid td.cell { position: relative; cursor: default; font-weight: 700; font-size: 1.05rem; }
.roster-grid td.cell:focus-visible { outline: 2px solid #2563eb; outline-offset: -2px; }
.roster-grid td.cell.locked { outline: 2px dashed #64748b; outline-offset: -2px; }

/* --- Phase 14 — cell edit icon + request markers + override badge ---
   The shift picker opens ONLY from the small pencil icon in the cell
   corner (clicking the cell body no longer opens it). The icon is
   visible on hover/focus of the cell and always visible on touch
   (hover: none) so it is tappable on a phone. The request mark sits in
   the opposite corner: ✓ green = the assigned shift is the person's
   preferred shift, ! amber = a preference for another shift exists or
   the assigned shift was "avoid" — a symbol, not colour alone, so it
   reads in print too (the print rules force black text). The «استثنا»
   badge is amber to differ from the blue «ثابت» badge. */
.roster-grid td.cell .cell-edit {
    position: absolute;
    top: 1px;
    inset-inline-end: 1px;
    width: 24px;
    height: 24px;
    padding: 3px;
    border: none;
    border-radius: 0.35rem;
    background: rgba(255, 255, 255, 0.85);
    color: #1e40af;
    cursor: pointer;
    opacity: 0;
    line-height: 0;
    z-index: 1;
    /* Phase 14 fix — the icon is a VISUAL affordance only, never a tap
       target: Chrome on touch screens snaps a tap on the cell body onto
       the nearest small button, which opened the picker from a body tap
       (caught live by the Phase 14 smoke). With pointer-events:none the
       tap always lands on the cell and the JS gate (cellEditHit) opens
       the picker only when the tap point itself is inside the icon's
       24px box. Keyboard opening is unaffected (Enter/Space on the
       focused cell). */
    pointer-events: none;
}
.roster-grid td.cell:hover .cell-edit,
.roster-grid td.cell:focus-within .cell-edit,
.roster-grid td.cell .cell-edit:focus-visible { opacity: 1; }
.roster-grid td.cell .cell-edit:hover { background: #dbeafe; }
.roster-grid td.cell .cell-edit:focus-visible { outline: 2px solid #2563eb; outline-offset: 1px; opacity: 1; }
@media (hover: none) {
    .roster-grid td.cell .cell-edit { opacity: 1; }
}
.roster-grid td.cell .override-badge { display: inline-block; background: #d97706; color: #fff; border-radius: 0.35rem; font-size: 0.6rem; font-weight: 700; padding: 0 0.25rem; margin-right: 0.2rem; vertical-align: middle; }
.roster-grid td.cell .req-mark {
    position: absolute;
    top: 1px;
    inset-inline-start: 1px;
    font-size: 0.75rem;
    font-weight: 900;
    line-height: 1;
    z-index: 1;
}
.roster-grid td.cell .req-honored { color: #166534; }
.roster-grid td.cell .req-not-honored { color: #b45309; }
.roster-grid td.shortage { background: #fee2e2; color: #991b1b; font-weight: 700; }

/* Phase 14 — the toolbar is NO LONGER sticky and NO LONGER inside the
   shell: it scrolls away with the page so the days row can sit directly
   under the navbar (Ali 2026-11-23: no room for the toolbar sections
   when scrolled). The glass styling stays; only the sticky positioning
   is gone. The shell still sticks below the navbar (see .roster-shell).
   The toolbar buttons stay reachable by scrolling back up. */
.roster-toolbar {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(147, 197, 253, 0.5);
    border-radius: 1rem;
    box-shadow: 0 8px 28px rgba(37, 99, 235, 0.10);
    padding: 0.75rem;
    margin-bottom: 1rem;
}
.roster-toolbar .card { margin-bottom: 0.75rem !important; }
.roster-toolbar .card:last-child { margin-bottom: 0 !important; }

/* --- Phase 6 — shortage cells open the day-coverage modal. --- */
.roster-grid td.shortage-cell { cursor: pointer; }
.roster-grid td.shortage-cell:hover { outline: 2px solid #2563eb; outline-offset: -2px; }
.roster-grid td.shortage-cell:focus-visible { outline: 2px solid #2563eb; outline-offset: -2px; }

/* --- Phase 6 — fairness meter: flash a cell whose value just changed, so the
   live refresh is visible even when only the mean moves. --- */
@keyframes fm-flash { 0% { background: #dbeafe; } 100% { background: transparent; } }
.fm-flash { animation: fm-flash 1.2s ease-out; }

/* --- Print-only title (screen: hidden by Bootstrap d-none; print: shown). --- */
.print-title { display: none; }

.stat-card { text-align: center; }
.stat-card .stat-number { font-size: 2rem; font-weight: 900; color: #1d4ed8; }

.footer {
    position: static;
    flex: 0 0 auto;
    width: 100%;
    line-height: 1.4;
    background: rgba(255, 255, 255, 0.6);
    border-top: 1px solid rgba(147, 197, 253, 0.5);
}

/* --- Phase 2 (ported from FitCore2 Phase 13) — inline-create modals
   («+» beside the skill / shift-type pickers). Fixed overlay, dimmed
   backdrop, rounded white dialog, header/body/footer. --- */
.ic-modal { position: fixed; inset: 0; z-index: 1050; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.ic-modal[hidden] { display: none; }
.ic-modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.65); }
.ic-modal-dialog { position: relative; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; background: #fff; color: #212529; border: 1px solid #dee2e6; border-radius: 1rem; box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.35); }
.ic-modal-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 1rem; border-bottom: 1px solid #dee2e6; }
.ic-modal-title { margin: 0; font-size: 1.1rem; }
.ic-modal-close { border: none; background: transparent; font-size: 1.25rem; line-height: 1; cursor: pointer; color: inherit; padding: 0.25rem 0.5rem; border-radius: 0.5rem; }
.ic-modal-close:hover { background: rgba(0, 0, 0, 0.08); }
.ic-modal-body { padding: 1rem; }
.ic-modal-hint { margin: 0 0 0.75rem; font-size: 0.85rem; }
.ic-modal-error { margin-bottom: 0.75rem; }
.ic-modal-footer { display: flex; gap: 0.5rem; justify-content: flex-start; padding: 0.75rem 1rem; border-top: 1px solid #dee2e6; }
.ic-toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); z-index: 1060; background: #198754; color: #fff; padding: 0.6rem 1.25rem; border-radius: 0.75rem; box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.3); font-size: 0.95rem; }
.ic-toast[hidden] { display: none; }

/* --- Phase 7 — print: READABLE A4 first, A3 only as an explicit choice ---
   Phase 6 diagnosis (measured live on the Azar 1405 grid, 8 nurses, 30 days):
   - screen grid 2188px; Phase 6 computed the scale from the SCREEN width
     (1025/2188 = 0.47 -> A3, scale 0.71) but the printed layout is only
     1256px wide (print fonts/padding shrink it), so the grid was over-shrunk
     to ~69% of the A3 page; on A4 paper the printer shrank it AGAIN x0.707,
     so grid glyphs measured 5.9pt tall on A4 (8.3pt on A3) — «خیلی ریز».
     Two compounding causes: (1) the scale came from the screen width, not
     the printed width; (2) the A3 @page was a silent fallback while the
     paper stayed A4.
   - Phase 7: the default «چاپ برنامه» prints A4 landscape, condensed:
     the 6 stat columns are hidden (they stay on screen), weekday names and
     the role in the name cell are hidden, leave/on-call cells use one-letter
     codes (م / آ — see the print legend), name column 9rem, grid font 10pt.
     Measured condensed natural width for Azar 1405: 1013px < A4 printable
     1063px (8mm margins) -> scale 1.0, effective font 10pt. A 31-day month
     is ~1042px and still fits at scale 1.0.
   - «چاپ A3» prints the FULL table (stats + weekdays + full codes) on A3
     at 10pt; measured full width at 10pt 1712px vs A3 printable 1527px
     (8mm margins) -> scale 0.89, effective ~8.9pt (median grid glyph
     14.2pt in the live A3 PDF, vs 8.3pt in Phase 6). The A3 @page rule
     (with the same 8mm margins) is injected by JS ONLY for that button;
     the default print is always A4.
   - The layout rules live under html.printing-a4 / html.printing-a3 (added
     by roster-grid.js in beforeprint, so the measured width IS the printed
     width); the @media print block below only hides page chrome. */
@page { size: A4 landscape; margin: 8mm; }
@media print {
    body { background: #fff !important; color: #000 !important; margin-bottom: 0; }
    /* Phase 6 — body/html min-height:100vh would fill a whole printed page
       by itself and spill a blank second page; neutralise it for print. */
    html, body { min-height: 0 !important; height: auto !important; }
    header, footer, .seed-banner, .btn, .fh-help, #pwa-install-banner { display: none !important; }
    /* Phase 6 — status banners (InMemory warning, trial banner, demo
       banner, TempData messages) have no place on the printed roster. */
    .alert { display: none !important; }
    .glass-card, .card { box-shadow: none !important; border: 1px solid #999 !important; background: #fff !important; }
    .roster-wrap { max-height: none !important; overflow: visible !important; position: static !important; top: auto !important; }
    /* Roster layout — the shell/handle/panel are screen-only: the print
       shows the grid at its natural height (the panel's cards are already
       .no-print, so the panel would print empty anyway). */
    .roster-shell { position: static !important; height: auto !important; display: block !important; overflow: visible !important; }
    .roster-shell--sized .roster-wrap { height: auto !important; flex: none !important; }
    .roster-resize-handle, .roster-bottom-panel, .roster-shell-spacer { display: none !important; }
    .roster-grid th, .roster-grid td { background: #fff !important; color: #000 !important; border-color: #999 !important; }
    .roster-grid td.shortage { background: #eee !important; color: #000 !important; }
    .container { max-width: none !important; }
    /* Phase 6 — one page, all columns. */
    .roster-toolbar, .no-print, .roster-toolbar .btn { display: none !important; }
    .print-title { display: block !important; margin-bottom: 0.5rem; }
    .print-title h1 { font-size: 14pt; margin: 0; }
    .print-title p { font-size: 10pt; margin: 0; }
    .print-title .print-legend { font-size: 9pt; margin-top: 0.25rem; }
    .print-legend-a3 { display: none; }
    .roster-grid th, .roster-grid td { padding: 1px 2px !important; position: static !important; white-space: nowrap; }
}

/* Short print codes (م for leave, آ for on-call): hidden on screen, shown
   only in the condensed A4 print where the full words would widen every
   day column. The full words stay on screen and in the A3 print. */
.roster-grid .cell-short { display: none; }

/* --- Phase 7 — A4 condensed print layout (default «چاپ برنامه»).
   min-width: 0 cancels the screen min-width: 100% so the measured width
   is the table's natural width, not the stretched-to-container width.
   The padding/position rules are duplicated here (they also live in the
   @media print block as a fallback): beforeprint measures in SCREEN media,
   so without them the measurement would see the screen padding
   (0.35rem 0.4rem) instead of the print padding (1px 2px) and over-shrink
   the grid — that is exactly the Phase 6 measurement error. --- */
html.printing-a4 .roster-grid { font-size: 10pt; min-width: 0; }
html.printing-a4 .roster-grid th, html.printing-a4 .roster-grid td { padding: 1px 2px !important; position: static !important; }
html.printing-a4 .roster-grid td.cell { font-size: 10pt; }
html.printing-a4 .roster-grid .stat-col { display: none !important; }
html.printing-a4 .roster-grid thead th small { display: none !important; }
html.printing-a4 .roster-grid .stick-name { width: 9rem !important; min-width: 9rem !important; max-width: 9rem !important; }
html.printing-a4 .roster-grid .stick-name small { display: none !important; }
/* Without the weekday names, Fridays/holidays are still marked: the day
   number is bold + underlined (backgrounds alone do not survive printing
   without "background graphics" enabled). */
html.printing-a4 .roster-grid th.holiday-col { font-weight: 900; text-decoration: underline; }
html.printing-a4 .roster-grid .cell-full { display: none !important; }
html.printing-a4 .roster-grid .cell-short { display: inline !important; }
html.printing-a4 .print-legend-a3 { display: none !important; }

/* --- Phase 7 — A3 full print layout («چاپ A3» only): everything visible
   (stats + weekdays + full codes) at the same 10pt base. The padding /
   position rules are here for the same measurement reason as A4 above. --- */
html.printing-a3 .roster-grid { font-size: 10pt; min-width: 0; }
html.printing-a3 .roster-grid th, html.printing-a3 .roster-grid td { padding: 1px 2px !important; position: static !important; }
html.printing-a3 .roster-grid td.cell { font-size: 10pt; }
html.printing-a3 .print-legend-a4 { display: none !important; }
html.printing-a3 .print-legend-a3 { display: block !important; }

/* --- Mobile roster (390px phones): the sticky name (11rem) + six stat
   columns (3.2rem each = 30.2rem total) are wider than a 390px viewport,
   so the sticky block covered the whole screen and no day cell could be
   tapped (measured live 2026-11-22: sticky block 424px, toolbar 435px,
   0/4 day cells tappable). Below 576px (same breakpoint as the cell
   combobox centred mode) the stat columns leave the grid entirely and
   live behind a tap on the person's name instead (person-stats popover,
   roster-grid.js); the name column narrows so several day columns fit
   and stay tappable; the toolbar compacts so the grid gets room.
   Desktop is untouched (all rules below are inside this media query).
   Scoped to `screen` so the A4/A3 print layouts never see it. --- */
@media screen and (max-width: 576px) {
    /* Stat columns: hidden in the header, the shortage row and every
       body row. The cells stay in the DOM (display:none) and the live
       SetCell refresh keeps updating them, so the popover reads fresh
       numbers from the same ids (ps-{personId}-*). */
    .roster-grid .stat-col { display: none !important; }
    /* Name column: 7.5rem (~105px at the 14px root) leaves ~285px for
       day columns (~6 days visible). The shortage-row label cell uses
       the same width so it never covers day cells either. */
    .roster-grid .stick-name {
        width: 7.5rem !important;
        min-width: 7.5rem !important;
        max-width: 7.5rem !important;
        font-size: 0.9rem;
    }
    .roster-staff-indicators .roster-staff-stats { display: inline-block; }
    /* Day cells stay tappable: nothing sticky may sit over them. */
    .roster-grid td.cell { font-size: 0.95rem; padding: 0.35rem 0.25rem; }

    /* Compact toolbar: smaller padding, title, buttons and card bodies
       so «ساخت پیش‌نویس» and «انتشار» stay reachable without the
       toolbar eating half the screen (435px -> ~260px, measured live). */
    .roster-toolbar { padding: 0.5rem; margin-bottom: 0.5rem; }
    .roster-toolbar .page-title { font-size: 1.15rem; }
    .roster-toolbar .page-title::after { width: 40px; height: 3px; margin-top: 0.25rem; }
    .roster-toolbar .card { margin-bottom: 0.5rem !important; }
    .roster-toolbar .card-body { padding: 0.5rem 0.75rem !important; gap: 0.35rem !important; }
    .roster-toolbar .alert { padding: 0.4rem 0.6rem; margin-bottom: 0.5rem; font-size: 0.9rem; }
    .roster-toolbar .btn { padding: 0.2rem 0.45rem; font-size: 0.82rem; }
    .roster-toolbar .form-select-sm { font-size: 0.82rem; }
    /* The month label duplicates the toolbar title («برنامه اورژانس —
       آذر ۱۴۰۵»); hiding it on mobile saves a whole wrapped row. */
    .roster-toolbar .month-label { display: none; }

    /* Roster layout — taller drag handle for touch (36px grab target). */
    .roster-resize-handle { height: 36px; }
    .roster-resize-handle .resize-hint { font-size: 0.8rem; }
}

/* --- Mobile person-stats popover (roster-grid.js): the six at-a-glance
   stats for one person, opened by tapping their (sticky) name cell on
   a phone, where the stat columns are hidden. Same fixed panel language
   as the cell combobox (z 1070, anchored by computeAnchor). --- */
.person-stats-pop {
    position: fixed;
    z-index: 1070;
    background: #fff;
    border: 1px solid #93c5fd;
    border-radius: 0.75rem;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.25);
    padding: 0.5rem 0.75rem;
    direction: rtl;
    width: 240px;
    max-width: calc(100vw - 16px);
}
.person-stats-pop .psp-title { font-weight: 700; padding: 0.25rem 0.25rem 0.5rem; border-bottom: 1px solid #e5e7eb; margin-bottom: 0.5rem; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.person-stats-pop .psp-close { border: none; background: transparent; font-size: 1.1rem; line-height: 1; cursor: pointer; color: #6b7280; padding: 0.25rem 0.5rem; border-radius: 0.5rem; }
.person-stats-pop .psp-close:hover { background: rgba(0, 0, 0, 0.08); }
.person-stats-pop .psp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem 0.75rem; }
.person-stats-pop .psp-item { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.92rem; }
.person-stats-pop .psp-item span:first-child { color: #6b7280; }
.person-stats-pop .psp-item span:last-child { font-weight: 700; }

.roster-grid .shift-balance { display: inline-grid; grid-template-columns: repeat(2, auto); gap: 2px 4px; font-size: .68rem; line-height: 1.2; }
.roster-grid .shift-balance > span { display: inline-flex; align-items: baseline; white-space: nowrap; }

.roster-grid .stat-7 { right: 32.8rem; }
@media screen {
    #staffRosterGrid.stats-hidden .stat-col { display: none !important; }
}
@media screen and (max-width: 576px) {
    #staffRosterGrid.stats-visible .stat-col { display: table-cell !important; right: auto; }
    #staffRosterGrid.stats-visible tbody .stat-col { position: static; }
    #staffRosterGrid.stats-visible thead .stat-col { z-index: 3; }
}


/* Dashboard workplace identity. */
.dashboard-workplace {
    margin: .25rem 0 .85rem;
    padding: 1rem 1.15rem;
    border: 1px solid rgba(96, 165, 250, .42);
    border-radius: 1rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, .92), rgba(219, 234, 254, .78));
    box-shadow: 0 8px 24px rgba(30, 64, 175, .10);
}
.dashboard-workplace-heading {
    margin-bottom: .65rem;
    color: #1e40af;
    font-size: .9rem;
    font-weight: 700;
}
.dashboard-workplace-line {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .75rem 1.25rem;
    color: #164e8a;
}
.dashboard-workplace-line + .dashboard-workplace-line {
    margin-top: .8rem;
    padding-top: .8rem;
    border-top: 1px solid rgba(96, 165, 250, .28);
}
.dashboard-workplace-field {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    min-width: 0;
}
.dashboard-workplace-field span {
    color: #64748b;
    font-size: .78rem;
    font-weight: 600;
}
.dashboard-workplace-field strong {
    overflow-wrap: anywhere;
    color: #164e8a;
    font-size: clamp(1rem, 1.8vw, 1.3rem);
    font-weight: 750;
    line-height: 1.5;
}
.dashboard-greeting { margin-top: 0; }
@media (max-width: 576px) {
    .dashboard-workplace-line { grid-template-columns: 1fr; gap: .55rem; }
}

.roster-staff-name { display: flex; align-items: center; gap: .2rem; white-space: nowrap; }
.roster-staff-label { flex: 1 1 0; min-width: 0; overflow: hidden; block-size: 1.4rem; line-height: 1.4rem; }
.roster-staff-text { width: max-content; white-space: nowrap; transform-origin: right center; }
.roster-staff-label .badge { white-space: nowrap; }
.roster-staff-indicators { flex: none; display: flex; align-items: center; gap: .15rem; }
.roster-staff-stats { display: none; font: inherit; font-size: .7rem; line-height: 1; color: #17427f; background: #fff; border: 1px solid #a9c7f4; border-radius: .2rem; padding: .15rem .2rem; }

.roster-profile-edit, .roster-combined-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: .25rem;
    padding: 0 .2rem;
    line-height: 1.25rem;
    font-size: .75rem;
}
.roster-profile-edit { border: 1px solid #a9c7f4; background: #fff; color: #17427f; }
.roster-profile-edit:focus-visible { outline: 2px solid #2563eb; outline-offset: 1px; }
.roster-combined-mark { background: #dbeafe; color: #1e3a8a; font-weight: 700; }
.roster-combined-mark[hidden] { display: none; }


.coverage-person-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: .25rem .65rem;
    padding-block: .3rem;
}
.coverage-quick-action {
    --coverage-ink: #164e91;
    --coverage-tint: #dcecff;
    --coverage-edge: #9bbde9;
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: .3rem;
    padding: .27rem .62rem;
    border: 1px solid var(--coverage-edge);
    border-radius: 999px;
    white-space: nowrap;
    color: var(--coverage-ink);
    background: linear-gradient(165deg, #fff 0%, var(--coverage-tint) 100%);
    box-shadow: inset 0 1px 0 #fff, 0 2px 5px rgb(27 54 91 / 12%);
    font: inherit;
    font-size: .78rem;
    font-weight: 700;
    line-height: 1.3;
}
.coverage-quick-remove {
    --coverage-ink: #952138;
    --coverage-tint: #ffe3e8;
    --coverage-edge: #e5a5b1;
}
.coverage-quick-action:not(:disabled):hover {
    background: var(--coverage-tint);
    border-color: var(--coverage-ink);
}
.coverage-quick-action:focus-visible {
    outline: 2px solid var(--coverage-ink);
    outline-offset: 2px;
}
.coverage-quick-action:disabled {
    opacity: .6;
    cursor: wait;
}

.quick-staff-actions { display: inline-flex; align-items: center; gap: .35rem; }
.quick-staff-close { width: 2rem; height: 2rem; padding: 0 !important; border-radius: 50% !important; font-size: 1.1rem !important; line-height: 1; }

.hn-workflow-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem 1rem;
    padding: .5rem .75rem;
    margin: 0 0 .7rem;
    border: 1px solid #c9ddf4;
    border-radius: .8rem;
    background: linear-gradient(110deg, rgba(239,246,255,.92), rgba(255,255,255,.96));
    box-shadow: 0 3px 12px rgba(37,99,235,.07);
}
.hn-workflow-navigation { flex: 1 1 auto; display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-width: 0; }
.hn-workflow-actions { order: 1; flex-wrap: nowrap; }
.hn-workflow-subtasks { order: 2; display: flex; flex-wrap: nowrap; gap: .35rem; margin-inline-start: auto; }
.leave-ledger-heading { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-block: .8rem .45rem; }
.hn-workflow-current { display: flex; align-items: baseline; gap: .55rem; color: #52677f; font-size: .82rem; }
.hn-workflow-current strong { color: #174c83; font-size: .95rem; }
.hn-workflow-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.hn-workflow-link {
    display: inline-flex; align-items: center; gap: .3rem;
    border: 1px solid #b8d0ec; border-radius: 999px;
    background: rgba(255,255,255,.8); color: #174c83;
    text-decoration: none; font-size: .82rem; font-weight: 600;
    padding: .3rem .65rem; transition: background .15s, transform .15s, box-shadow .15s;
}
.hn-workflow-link:hover { background: #e1efff; color: #0b3d91; transform: translateY(-1px); box-shadow: 0 3px 9px #174c8320; }
.hn-workflow-next { background: #e8f2ff; }
@media(max-width:600px) {
 .hn-workflow-nav { align-items: stretch; flex-direction: column; }
 .hn-workflow-navigation { flex-direction: row; align-items: center; }
 .hn-workflow-subtasks { flex-wrap: wrap; margin-inline-start: 0; }
 .hn-workflow-actions { flex-wrap: nowrap; }
 .hn-workflow-link { flex: 1 1 auto; justify-content: center; }
}
@media print { .hn-workflow-nav { display:none !important; } }

.hn-workflow-subtasks, .hn-step-links { display:flex; flex-wrap:wrap; gap:.35rem; }
.hn-workflow-subtasks { flex-basis:auto; justify-content:flex-start; padding-top:0; border-top:0; margin-inline-start:auto; }
.hn-step-links { margin-top:.3rem; }

.hn-workflow-actions { flex-wrap: nowrap; flex: 0 0 auto; }
.hn-workflow-actions .hn-workflow-link { flex: 0 0 auto; white-space: nowrap; }
.hn-workflow-subtasks { margin-inline-start: auto; }
.shiftcore-footer .container { line-height: 1.4; }
@media (max-width: 600px) {
    .hn-workflow-navigation { width: 100%; }
    .hn-workflow-actions .hn-workflow-link { white-space: normal; }
    .shiftcore-footer { padding: .3rem 0; }
}

.leave-requests-heading {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:.6rem;
    margin-block:.8rem .45rem;
}
.leave-requests-heading .btn { flex:0 0 auto; }
