/* ===========================================================================
   HR Leave Management — Theme  ·  Direction: "Royal Blue / Console"
   ---------------------------------------------------------------------------
   A calm, corporate SaaS look built around a royal-navy blue. Navigation lives
   in a fixed dark-blue rail on the leading edge (right in RTL); the content
   area is bright, table-forward and airy. Type pairs Cairo (geometric display,
   bilingual) with Readex Pro (Arabic-first humanist body). Motion is deliberate
   — button sheen + lift, staggered card entrance — and always yields to
   prefers-reduced-motion.

   Single source of design tokens: re-skin by editing the :root variables (the
   brand primary/accent are also overridden at runtime from the org settings).
   ===========================================================================*/
:root {
    --hr-primary: #1a5cae;        /* royal blue — links, buttons, accents  */
    --hr-primary-dark: #123f79;
    --hr-primary-soft: #2a6fc4;   /* highlight stop for button gradients   */
    --hr-accent: #10305a;         /* deep navy — brand text                */
    --hr-sidebar: #1a4f92;        /* nav rail top                          */
    --hr-sidebar-2: #123c73;      /* nav rail bottom                       */
    --hr-gold: #5a93da;           /* blue accent (active bar / stat top)   */
    --hr-gold-soft: #a8c8ee;
    --hr-bg: #eef1f6;             /* cool paper                            */
    --hr-surface: #ffffff;
    --hr-surface-2: #f5f7fb;
    --hr-border: #e2e6ee;
    --hr-text: #1c2637;
    --hr-muted: #6b7688;
    --hr-success: #15803d;
    --hr-warning: #b45309;
    --hr-danger: #c02626;
    --hr-radius: 0;
    --hr-radius-sm: 0;
    --hr-sidebar-w: 256px;
    --hr-shadow: 0 1px 3px rgba(16, 34, 64, .06), 0 1px 2px rgba(16, 34, 64, .04);
    --hr-shadow-md: 0 14px 34px -16px rgba(18, 63, 121, .28), 0 6px 16px -10px rgba(16, 34, 64, .14);
    --hr-shadow-lg: 0 24px 56px -22px rgba(18, 63, 121, .36);
    --hr-ease: cubic-bezier(.2, .7, .2, 1);
    --hr-font: "Readex Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --hr-font-display: "Cairo", "Readex Pro", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
::selection { background: var(--hr-primary); color: #fff; }
body {
    margin: 0;
    font-family: var(--hr-font);
    background:
        radial-gradient(1200px 380px at 100% -120px, rgba(26, 92, 174, .08), transparent 60%),
        radial-gradient(900px 320px at -10% -80px, rgba(18, 60, 115, .06), transparent 55%),
        var(--hr-bg);
    background-attachment: fixed;
    color: var(--hr-text);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .brand span { font-family: var(--hr-font-display); letter-spacing: -.01em; }
h1 { font-size: 27px; font-weight: 800; }
a { color: var(--hr-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout: sidebar shell ----------------------------------------------------*/
.sidebar {
    position: fixed; top: 0; inset-inline-start: 0; z-index: 60;
    width: var(--hr-sidebar-w); height: 100vh;
    display: flex; flex-direction: column;
    background: linear-gradient(180deg, var(--hr-sidebar), var(--hr-sidebar-2));
    color: #eaf1fb;
    box-shadow: 2px 0 20px -10px rgba(9, 26, 52, .45);
    transition: width .22s var(--hr-ease);
}
body.rtl .sidebar { box-shadow: -2px 0 20px -10px rgba(9, 26, 52, .45); }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 16px; }
.sidebar-brand a { display: flex; align-items: center; gap: 12px; color: #fff; font-weight: 800; font-size: 15.5px; line-height: 1.2; font-family: var(--hr-font-display); flex: 1; min-width: 0; }
.sidebar-brand a:hover { text-decoration: none; }
.sidebar-brand a span { overflow: hidden; text-overflow: ellipsis; }
.sidebar-brand img { height: 44px; width: 44px; flex: 0 0 44px; object-fit: contain; transition: transform .3s var(--hr-ease); }
.sidebar-brand a:hover img { transform: scale(1.05) rotate(-2deg); }
/* White MOI logo: flag (emblem) on the left, name text on the right. Forced LTR
   so the flag stays physically left in both languages. */
.sidebar-brand a { direction: ltr; }
.sidebar-brand .sidebar-emblem { height: 58px; width: auto; flex: 0 0 auto; }
.sidebar-brand .sidebar-wordmark { height: 46px; width: auto; flex: 0 1 auto; }
.sidebar-brand a:hover .sidebar-emblem { transform: scale(1.04); }
.nav-collapsed .sidebar-brand .sidebar-emblem { height: 46px; }
.nav-collapsed .sidebar-brand .sidebar-wordmark { display: none; }
/* Desktop collapse toggle */
.nav-collapse-btn {
    display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 auto; width: 30px; height: 30px; padding: 0; cursor: pointer;
    background: rgba(255, 255, 255, .12); color: #eaf1fb;
    border: 1px solid rgba(255, 255, 255, .18); border-radius: 0;
    transition: background-color .18s var(--hr-ease);
}
.nav-collapse-btn:hover { background: rgba(255, 255, 255, .22); }
.nav-collapse-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .22s var(--hr-ease); }
body.rtl .nav-collapse-btn svg { transform: scaleX(-1); }
.nav-collapsed .nav-collapse-btn svg { transform: scaleX(-1); }
body.rtl .nav-collapsed .nav-collapse-btn svg { transform: none; }

.sidebar-nav { display: flex; flex-direction: column; gap: 3px; padding: 8px 12px; overflow-y: auto; flex: 1; }
.sidebar-nav a {
    position: relative; display: flex; align-items: center; gap: 12px;
    padding: 10px 13px; border-radius: 0; font-weight: 600; font-size: 14px;
    color: #cdddf3; white-space: nowrap; text-decoration: none;
    transition: background-color .18s var(--hr-ease), color .18s var(--hr-ease), transform .15s var(--hr-ease);
}
.sidebar-nav a svg { width: 20px; height: 20px; flex: 0 0 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; opacity: .9; }
.sidebar-nav a:hover { background: rgba(255, 255, 255, .1); color: #fff; text-decoration: none; transform: translateX(2px); }
body.rtl .sidebar-nav a:hover { transform: translateX(-2px); }
.sidebar-nav a.active { background: #fff; color: var(--hr-primary-dark); box-shadow: 0 6px 16px -8px rgba(0, 0, 0, .5); }
.sidebar-nav a.active svg { opacity: 1; }
.sidebar-nav a.active::before {
    content: ""; position: absolute; inset-inline-start: -12px; top: 50%; transform: translateY(-50%);
    width: 4px; height: 22px; border-radius: 0 4px 4px 0; background: var(--hr-gold);
}
body.rtl .sidebar-nav a.active::before { border-radius: 4px 0 0 4px; }

.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .12); }
.side-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.side-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%;
    background: rgba(255, 255, 255, .16); color: #fff; font-weight: 800; font-size: 16px;
    font-family: var(--hr-font-display);
}
.side-user-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.side-user-name { font-weight: 700; font-size: 13.5px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user .role-pill {
    align-self: flex-start;
    background: rgba(255, 255, 255, .18); color: #eaf1fb;
    padding: 2px 9px; border-radius: 0; font-size: 11px; font-weight: 700;
}
.side-actions { display: flex; align-items: stretch; gap: 8px; }
.side-actions .lang-btn {
    flex: 1; display: flex; align-items: center; justify-content: center;
    text-align: center; border: 1px solid rgba(255, 255, 255, .28);
    color: #eaf1fb !important; padding: 6px 10px; border-radius: 0; font-weight: 600; font-size: 13px;
    transition: background-color .18s var(--hr-ease), border-color .18s var(--hr-ease);
}
.side-actions .lang-btn:hover { background: rgba(255, 255, 255, .14); text-decoration: none; }
/* The logout button is wrapped in a <form> (the real flex item) — make the form
   stretch and the button fill it so its height matches the language button. */
.side-actions .inline-form { display: flex; }
.side-actions .btn { display: flex; align-items: center; padding-top: 0; padding-bottom: 0; }

/* Content column + mobile topbar -------------------------------------------*/
.app-main { min-height: 100vh; transition: margin-inline-start .22s var(--hr-ease); }
body.has-sidebar .app-main { margin-inline-start: var(--hr-sidebar-w); }
.topbar { display: none; }
.nav-open, .nav-close, .nav-scrim { display: none; }

/* Collapsed rail (desktop, user-toggled, remembered in localStorage) --------*/
@media (min-width: 901px) {
    .nav-collapsed { --hr-sidebar-w: 78px; }
    .nav-collapsed .sidebar-brand { justify-content: center; padding: 16px 10px; }
    .nav-collapsed .sidebar-brand a { flex: 0 0 auto; }
    .nav-collapsed .sidebar-brand a span,
    .nav-collapsed .side-user-meta,
    .nav-collapsed .side-actions { display: none; }
    .nav-collapsed .nav-collapse-btn { position: absolute; top: 14px; inset-inline-end: 8px; width: 26px; height: 26px; background: rgba(255,255,255,.14); }
    .nav-collapsed .sidebar-brand { position: relative; padding-top: 46px; }
    .nav-collapsed .sidebar-nav { padding: 8px 10px; }
    .nav-collapsed .sidebar-nav a { justify-content: center; padding: 11px 0; }
    .nav-collapsed .sidebar-nav a span { display: none; }
    .nav-collapsed .sidebar-nav a.active::before { inset-inline-start: -10px; }
    .nav-collapsed .sidebar-foot { padding: 12px 10px; display: flex; justify-content: center; }
    .nav-collapsed .side-user { margin-bottom: 0; }
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .28s var(--hr-ease);
    }
    body.rtl .sidebar { transform: translateX(100%); }
    .nav-toggle-cb:checked ~ .sidebar { transform: translateX(0); }
    body.has-sidebar .app-main { margin-inline-start: 0; }
    .topbar {
        display: flex; align-items: center; gap: 12px;
        position: sticky; top: 0; z-index: 40;
        height: 58px; padding: 0 16px;
        background: linear-gradient(180deg, var(--hr-sidebar), var(--hr-sidebar-2));
        color: #fff; box-shadow: var(--hr-shadow);
    }
    .topbar-title { font-family: var(--hr-font-display); font-weight: 800; font-size: 15px; }
    .nav-open { display: inline-flex; cursor: pointer; color: #fff; }
    .nav-open svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
    .nav-close { display: inline-flex; cursor: pointer; color: #eaf1fb; font-size: 18px; line-height: 1; padding: 4px; }
    .nav-collapse-btn { display: none; }
    .nav-toggle-cb:checked ~ .nav-scrim {
        display: block; position: fixed; inset: 0; z-index: 55;
        background: rgba(9, 26, 52, .5);
    }
}

/* Right-to-left (Arabic) -------------------------------------------------- */
body.rtl { direction: rtl; }
body.rtl table.data th, body.rtl table.data td { text-align: right; }
body.rtl .page-title { flex-direction: row-reverse; }
body.rtl .auth-wrap { direction: rtl; }
.container { max-width: 1480px; margin: 26px auto; padding: 0 34px; }

/* Cards & grid -------------------------------------------------------------*/
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.card {
    position: relative;
    background: var(--hr-surface);
    border: 1px solid var(--hr-border);
    border-radius: var(--hr-radius);
    box-shadow: var(--hr-shadow);
    padding: 22px;
    transition: box-shadow .25s var(--hr-ease), transform .2s var(--hr-ease), border-color .2s;
}
.card h2, .card h3 { margin-top: 0; }
.stat { text-align: center; }
/* Stat cards get a thin blue top accent on hover. */
.card.stat::before {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
    border-radius: var(--hr-radius) var(--hr-radius) 0 0;
    background: linear-gradient(90deg, var(--hr-primary), var(--hr-gold));
    opacity: .0; transition: opacity .25s var(--hr-ease);
}
.card.stat:hover::before { opacity: .9; }
/* Clickable stat cards (dashboard overview) */
a.card.clickable { display: block; color: inherit; text-decoration: none; }
a.card.clickable:hover { transform: translateY(-4px); box-shadow: var(--hr-shadow-md); border-color: color-mix(in srgb, var(--hr-primary) 35%, var(--hr-border)); text-decoration: none; }
a.card.clickable:hover .value { color: var(--hr-primary-dark); }
.stat .value { font-family: var(--hr-font-display); font-size: 34px; font-weight: 800; color: var(--hr-primary); font-variant-numeric: tabular-nums; line-height: 1.1; transition: color .2s var(--hr-ease); }
.stat .label { color: var(--hr-muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }

/* Tables -------------------------------------------------------------------*/
/* Wide tables scroll horizontally within their card instead of spilling past
   its edge — otherwise the last columns (the Edit/Delete action buttons) get
   clipped off-screen: to the right in LTR, to the left in RTL. */
.table-scroll { overflow-x: auto; max-width: 100%; }
.table-scroll > table.data { margin: 0; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--hr-border); }
/* Action-button cells hug the row's outer edge (right in LTR, left in RTL) so
   the Edit/Delete buttons never leave a gap when the table is narrower than
   its card — matching the tidy right-aligned look English already has. */
table.data td:has(.btn) { text-align: right; }
body.rtl table.data td:has(.btn) { text-align: left; }
table.data th { background: #d6dfec; padding: 19px 16px; font-size: 17px; color: var(--hr-primary-dark); font-weight: 700; border-bottom: 2px solid #c2cee0; white-space: nowrap; }
table.data th.sortable { cursor: pointer; user-select: none; transition: color .15s var(--hr-ease), background-color .15s var(--hr-ease); }
table.data th.sortable:hover { color: var(--hr-primary); background: #c7d4e6; }
table.data th .sort-ind { display: inline-block; margin-inline-start: 5px; font-size: 10px; opacity: .4; }
table.data th[aria-sort] { color: var(--hr-primary); }
table.data th[aria-sort] .sort-ind { opacity: 1; }
table.data thead th:first-child { border-top-left-radius: var(--hr-radius-sm); }
table.data thead th:last-child { border-top-right-radius: var(--hr-radius-sm); }
table.data tbody tr { transition: background-color .15s ease, box-shadow .15s ease; }
/* Zebra striping — alternate rows get a subtle tint (hover + row-warn win). */
table.data tbody tr:nth-child(even) td { background: var(--hr-surface-2); }
table.data tbody tr:hover td { background: #eff4fb; }
table.data tbody tr.row-warn td { background: #fff8e8; }
table.data tbody tr.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--hr-warning); }
body.rtl table.data tbody tr.row-warn td:first-child { box-shadow: inset -3px 0 0 var(--hr-warning); }
table.data tbody tr.row-warn:hover td { background: #fef3d6; }

/* Status — plain coloured text (no chip). */
.badge { display: inline-block; padding: 0; background: none; box-shadow: none; font-size: 13px; font-weight: 700; letter-spacing: .01em; }
.badge.PENDING  { color: var(--hr-warning); }
.badge.APPROVED { color: var(--hr-success); }
.badge.REJECTED { color: var(--hr-danger); }
.badge.CANCELLED{ color: var(--hr-muted); }
.badge.DRAFT    { color: #4338ca; }

/* Small "Backdated" tag shown next to the status of a back-filed request. */
.tag-backdated {
    display: inline-block; margin-inline-start: 6px; padding: 1px 7px;
    font-size: 11px; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
    color: #8a5a00; background: #fff3d6; border: 1px solid #f0d089; border-radius: 2px;
    vertical-align: middle;
}

/* Forms & buttons ----------------------------------------------------------*/
.form-control {
    width: 100%; padding: 10px 12px; border: 1px solid var(--hr-border); border-radius: var(--hr-radius-sm);
    font-size: 14px; font-family: inherit; background: #fff; color: var(--hr-text);
    transition: border-color .18s var(--hr-ease), box-shadow .18s var(--hr-ease);
}
.form-control:focus {
    outline: none; border-color: var(--hr-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--hr-primary) 18%, transparent);
}
label { display: block; font-weight: 600; margin: 12px 0 5px; font-size: 13px; }

/* Checkbox list (roles / supervised departments) — tick to add, untick to remove.
   Django renders CheckboxSelectMultiple as <div class="checklist"> with a <div>
   per option; the class also lands on each <input>, so scope selectors to the
   container div. */
div.checklist {
    margin: 0; padding: 10px 12px; border: 1px solid var(--hr-border);
    border-radius: var(--hr-radius-sm); background: #fff;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 16px;
}
div.checklist > div { margin: 0; }
div.checklist label {
    display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 500;
    font-size: 14px; cursor: pointer;
}
div.checklist input[type="checkbox"] { width: 16px; height: 16px; margin: 0; cursor: pointer; flex: none; }

.btn {
    position: relative; overflow: hidden;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; border: 1px solid transparent; border-radius: var(--hr-radius-sm);
    font-family: var(--hr-font-display); font-weight: 700; font-size: 14px; letter-spacing: .01em;
    cursor: pointer; text-decoration: none; vertical-align: middle;
    transition: transform .16s var(--hr-ease), box-shadow .22s var(--hr-ease),
                background-color .2s, border-color .2s, color .2s;
}
/* Sheen sweep on hover — the signature button motion. */
.btn::before {
    content: ""; position: absolute; top: 0; left: -130%; width: 55%; height: 100%;
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, .5), transparent);
    transform: skewX(-18deg); transition: left .6s var(--hr-ease); pointer-events: none;
}
.btn:hover::before { left: 140%; }
.btn:hover { transform: translateY(-2px); box-shadow: var(--hr-shadow-md); text-decoration: none; }
.btn:active { transform: translateY(0) scale(.97); box-shadow: var(--hr-shadow); }
.btn:focus-visible { outline: 3px solid var(--hr-primary); outline-offset: 2px; }
.btn-primary { background: linear-gradient(180deg, var(--hr-primary-soft), var(--hr-primary)); color: #fff; box-shadow: 0 2px 0 var(--hr-primary-dark), var(--hr-shadow); }
.btn-primary:hover { background: linear-gradient(180deg, var(--hr-primary), var(--hr-primary-dark)); color: #fff; }
.btn-success { background: linear-gradient(180deg, #1c9849, var(--hr-success)); color: #fff; box-shadow: 0 2px 0 #0f5f2c, var(--hr-shadow); }
.btn-danger  { background: linear-gradient(180deg, #d33232, var(--hr-danger)); color: #fff; box-shadow: 0 2px 0 #8f1414, var(--hr-shadow); }
.btn-ghost   { background: #fff; border-color: var(--hr-border); color: var(--hr-text); }
.btn-ghost:hover { border-color: var(--hr-primary); color: var(--hr-primary); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 0; }
/* Fixed-width record buttons so PDF / Download are identical size. */
.btn-record { min-width: 104px; }
/* Equal-width action buttons (My Leave: PDF / Edit / Cancel). */
.btn-eq { min-width: 96px; }
/* Live (no-refresh) refresh: the "Updated" pill + a brief highlight on swap. */
.live-pill { display:inline-block; margin-inline-start:12px; padding:3px 10px; font-size:12px;
    font-weight:700; color:#0f5f2c; background:#e3f4e9; border:1px solid #bfe6cd; vertical-align:middle; }
[data-live].live-flash { animation: live-flash 1s ease; }
@keyframes live-flash { 0% { background:#fff7e0; } 100% { background:transparent; } }
/* Modal overlay (global — used by the sidebar Calendar popup). */
.hr-modal-scrim { position:fixed; inset:0; background:rgba(16,24,40,.55); display:flex;
    align-items:center; justify-content:center; z-index:1000; padding:20px; }
.hr-modal-scrim[hidden] { display:none; }
.hr-modal { background:var(--hr-card,#fff); color:inherit; max-width:460px; width:100%;
    padding:22px 24px; box-shadow:0 20px 60px rgba(0,0,0,.35); animation:hr-rise .25s var(--hr-ease) both; }
/* Sidebar Calendar popup. */
.hr-cal { max-width:380px; border-top:3px solid var(--hr-primary); }
/* Flyout variant: slides out from the sidebar's inner edge instead of centring. */
.hr-modal-scrim.hr-flyout { justify-content:flex-start; align-items:stretch; padding:0;
    background:rgba(16,24,40,.32); }
.hr-flyout .hr-cal { margin-inline-start:var(--hr-sidebar-w,256px); width:360px; max-width:88vw;
    height:100%; overflow-y:auto; border-top:0; border-inline-start:3px solid var(--hr-primary);
    box-shadow:0 0 46px rgba(0,0,0,.28);
    /* Slow, springy slide-out from the sidebar edge (easeOutExpo → gentle settle). */
    animation:hr-flyout-in .62s cubic-bezier(.16,1,.3,1) both; }
@keyframes hr-flyout-in {
    from { transform:translateX(-100%); opacity:0; }
    55%  { opacity:1; }
    to   { transform:translateX(0); opacity:1; } }
html[dir="rtl"] .hr-flyout .hr-cal { animation-name:hr-flyout-in-rtl; }
@keyframes hr-flyout-in-rtl {
    from { transform:translateX(100%); opacity:0; }
    55%  { opacity:1; }
    to   { transform:translateX(0); opacity:1; } }
/* The dim backdrop fades in alongside the panel rather than snapping on. */
.hr-modal-scrim.hr-flyout:not([hidden]) { animation:hr-flyout-scrim .5s ease both; }
@keyframes hr-flyout-scrim { from { background:rgba(16,24,40,0); } to { background:rgba(16,24,40,.32); } }
/* Calendar contents rise in a beat after the panel, for a layered, dynamic feel. */
.hr-flyout .hr-cal-day { animation:hr-cal-rise .5s var(--hr-ease) both; animation-delay:.12s; }
@keyframes hr-cal-rise { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }
/* Closing: slide the panel back into the sidebar before hiding. JS adds
   .is-closing, then flips [hidden] once the animation ends. */
.hr-flyout.is-closing .hr-cal { animation:hr-flyout-out .42s cubic-bezier(.5,0,.75,0) both; }
@keyframes hr-flyout-out { from { transform:translateX(0); opacity:1; } to { transform:translateX(-100%); opacity:0; } }
html[dir="rtl"] .hr-flyout.is-closing .hr-cal { animation-name:hr-flyout-out-rtl; }
@keyframes hr-flyout-out-rtl { from { transform:translateX(0); opacity:1; } to { transform:translateX(100%); opacity:0; } }
.hr-modal-scrim.hr-flyout.is-closing { animation:hr-flyout-scrim-out .4s ease both; }
@keyframes hr-flyout-scrim-out { from { background:rgba(16,24,40,.32); } to { background:rgba(16,24,40,0); } }
/* On mobile the sidebar is an off-canvas drawer — anchor the flyout to the screen edge. */
@media (max-width:900px) { .hr-flyout .hr-cal { margin-inline-start:0; } }
@media (prefers-reduced-motion:reduce) {
    .hr-flyout .hr-cal, .hr-modal-scrim.hr-flyout:not([hidden]), .hr-flyout .hr-cal-day,
    .hr-flyout.is-closing .hr-cal, .hr-modal-scrim.hr-flyout.is-closing {
        animation-duration:.01ms; animation-delay:0ms; } }
.hr-cal-head { display:flex; align-items:center; gap:6px; margin-bottom:14px; }
.hr-cal-title { flex:1; text-align:center; font-size:16px; }
.hr-cal-nav, .hr-cal-close { border:1px solid var(--hr-border); background:#fff; color:inherit;
    width:30px; height:30px; line-height:1; font-size:17px; cursor:pointer; }
.hr-cal-nav:hover, .hr-cal-close:hover { background:var(--hr-bg,#f2f3f6); }
.hr-cal-close { margin-inline-start:6px; border-color:transparent; }
.hr-cal-grid { display:grid; grid-template-columns:repeat(7,1fr); gap:1px; }
.hr-cal-wd { text-align:center; font-size:12px; font-weight:700; color:var(--hr-muted,#667085); padding:4px 0; }
/* Light-gray lines between the dates: the grid background shows through 1px gaps. */
.hr-cal-days { margin-top:6px; background:var(--hr-border,#e2e6ee); border:1px solid var(--hr-border,#e2e6ee); }
.hr-cal-day { aspect-ratio:1/1; display:flex; align-items:center; justify-content:center;
    font-size:14px; background:var(--hr-card,#fff); }
.hr-cal-day.is-leave { color:#1f2937; font-weight:700; }
.hr-cal-day.is-today { box-shadow:inset 0 0 0 2px var(--hr-primary); font-weight:700; }
.hr-cal-foot { margin-top:16px; border-top:1px solid var(--hr-border); padding-top:12px; }
.hr-cal-legend { display:inline-flex; align-items:center; gap:7px; font-size:13px; color:var(--hr-muted,#667085); }
.hr-cal-swatch { width:13px; height:13px; background:var(--hr-primary); display:inline-block; }
.hr-cal-list { list-style:none; margin:10px 0 0; padding:0; font-size:13.5px; }
.hr-cal-list li { display:flex; align-items:center; gap:8px; padding:4px 0; }
.hr-cal-dot { width:10px; height:10px; border-radius:50%; flex:none; }
.hr-cal-none { color:var(--hr-muted,#667085); }
/* List pagination bar (Leave History, My Leave, console Users, Audit log). */
.pager { display:flex; align-items:center; justify-content:space-between; gap:12px;
    flex-wrap:wrap; margin-top:16px; }
.pager-perpage { display:flex; align-items:center; gap:8px; margin:0; }
.pager-nav { display:flex; align-items:center; gap:8px; }
.pager-nav .btn { min-width:34px; font-size:17px; line-height:1; }
.pager-total { margin-inline-start:4px; }
/* Bare icon action — no button chrome (attachment view / delete). */
.icon-action {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; padding: 5px; margin: 0 1px; cursor: pointer;
    background: none; border: 0; line-height: 1; text-decoration: none; vertical-align: middle;
    color: var(--hr-primary);
    transition: transform .15s var(--hr-ease), background-color .15s var(--hr-ease), color .15s var(--hr-ease);
}
.icon-action svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; display: block; }
.icon-action:hover { transform: translateY(-1px); text-decoration: none; background: color-mix(in srgb, var(--hr-primary) 13%, transparent); }
.icon-action:active { transform: scale(.94); }
.icon-action:focus-visible { outline: 2px solid var(--hr-primary); outline-offset: 1px; }
.icon-action.danger { color: var(--hr-danger); }
.icon-action.danger:hover { background: color-mix(in srgb, var(--hr-danger) 13%, transparent); }
.icon-action.danger:focus-visible { outline-color: var(--hr-danger); }

/* Messages -----------------------------------------------------------------*/
.messages { list-style: none; padding: 0; margin: 0 0 18px; }
.messages li { padding: 13px 16px; border-radius: var(--hr-radius-sm); margin-bottom: 8px; font-weight: 500; animation: hr-rise .4s var(--hr-ease) both; max-height: 200px; overflow: hidden; cursor: default; transition: opacity .45s ease, transform .45s ease, max-height .45s ease, margin .45s ease, padding .45s ease; }
/* Auto-dismiss: JS adds .hr-hide after a few seconds to fade + collapse it. */
.messages li.hr-hide { opacity: 0; transform: translateY(-6px); max-height: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; }
@media (prefers-reduced-motion: reduce) { .messages li { transition-duration: .01ms; } }
.messages li.success { background: #dcfce7; color: var(--hr-success); box-shadow: inset 4px 0 0 var(--hr-success); }
.messages li.error   { background: #fee2e2; color: var(--hr-danger); box-shadow: inset 4px 0 0 var(--hr-danger); }
.messages li.warning { background: #fef3c7; color: var(--hr-warning); box-shadow: inset 4px 0 0 var(--hr-warning); }
.messages li.info    { background: #e0f2fe; color: #0369a1; box-shadow: inset 4px 0 0 #0369a1; }

/* Compact inline notice (e.g. the dashboard carry-over reminder). */
.notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; margin: 0 0 16px;
    font-weight: 500; border-radius: var(--hr-radius-sm); animation: hr-rise .4s var(--hr-ease) both; }
.notice-icon { flex: 0 0 auto; line-height: 1.4; }
.notice-warn { background: #fef3c7; color: var(--hr-warning); box-shadow: inset 4px 0 0 var(--hr-warning); }
body.rtl .notice-warn { box-shadow: inset -4px 0 0 var(--hr-warning); }

.page-title { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.muted { color: var(--hr-muted); }
.name-role { color: var(--hr-muted); font-weight: 600; font-size: .72em; }
.inline-form { display: inline; }
.auth-wrap { max-width: 400px; margin: 8vh auto; }

/* Auth pages (login / change password): frosted-glass card over a living
   royal-blue gradient mesh. Shared by auth/login.html + change_password.html. */
.auth-bg {
    position: fixed; inset: 0; z-index: 0; overflow: hidden;
    background-color: #0f2a52;
    /* Manama skyline (blue wash) + a soft dark scrim so the transparent card and
       its light text stay readable. The MOI logo is a separate corner element so
       it never gets cropped by background-size: cover. */
    background-image:
        linear-gradient(180deg, rgba(6,18,44,.30), rgba(6,18,44,.46)),
        url(../img/Manama_bg.jpg);
    background-size: cover; background-position: center; background-repeat: no-repeat;
}
/* MOI logo, top-left, always visible + crisp (independent of the photo crop). */
.auth-logo-corner {
    position: fixed; top: 22px; left: 26px; z-index: 2;
    height: 104px; width: auto;
    filter: drop-shadow(0 2px 8px rgba(3,10,28,.6));
}
@media (max-width: 480px) { .auth-logo-corner { height: 74px; } }

.auth-wrap.auth-page {
    position: relative; z-index: 1;
    max-width: none; margin: 0;
    min-height: 100vh; padding: 24px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
}

.auth-lang {
    position: fixed; top: 18px; right: 22px; z-index: 2;
    background: rgba(255,255,255,.14); color: #fff;
    border: 1px solid rgba(255,255,255,.32); border-radius: 0;
    padding: 8px 17px; font-weight: 600; font-size: 13px;
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    transition: background .18s var(--hr-ease);
}
.auth-lang:hover { background: rgba(255,255,255,.26); text-decoration: none; }

.auth-card {
    position: relative;
    width: 100%; max-width: 404px; padding: 36px 32px 30px;
    /* Barely-there glass — the Manama photo reads clearly through it; the blur +
       a light sheen edge keep it a distinct pane. */
    background: linear-gradient(145deg, rgba(255,255,255,.06), rgba(255,255,255,0));
    -webkit-backdrop-filter: blur(15px) saturate(120%); backdrop-filter: blur(15px) saturate(120%);
    border: 1px solid rgba(255,255,255,.24); border-radius: 0;
    box-shadow: 0 40px 90px -30px rgba(3,10,28,.78),
                inset 0 1px 0 rgba(255,255,255,.32);
    color: #eef4fc;
    animation: auth-card-in .6s var(--hr-ease) both;
}
/* A faint highlight along the top-left edge reinforces the "layer" feel. */
.auth-card::before {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    border-top: 1px solid rgba(255,255,255,.3);
    border-inline-start: 1px solid rgba(255,255,255,.16);
}
@keyframes auth-card-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.auth-brand { text-align: center; margin-bottom: 22px; }
/* Logo overhangs the card so the top border crosses the MIDDLE OF THE FLAG
   (emblem centre ≈ 28% down the logo): lift = card padding-top (36) + 0.28×180. */
.auth-card-logo { display: block; height: 180px; width: auto; margin: -86px auto 10px;
    filter: drop-shadow(0 2px 10px rgba(3,10,28,.55)); }
.auth-logo {
    height: 96px; width: auto; object-fit: contain;
    filter: drop-shadow(0 8px 18px rgba(6,20,46,.45));
}
.auth-brand h2 { margin: 16px 0 0; color: #ffffff; font-size: 21px; text-shadow: 0 1px 8px rgba(3,10,28,.5); }
.auth-brand .muted { margin: 5px 0 0; }
.auth-card .muted { color: rgba(232,241,252,.82); font-weight: 500; text-shadow: 0 1px 6px rgba(3,10,28,.45); }

.auth-card label { display: block; text-align: left; font-weight: 600; font-size: 13px;
    color: rgba(236,244,253,.92); margin: 14px 0 5px; text-shadow: 0 1px 6px rgba(3,10,28,.4); }
.auth-card .form-control {
    width: 100%; background: rgba(255,255,255,.12); color: #f4f8fd;
    border: 1px solid rgba(255,255,255,.30);
    box-shadow: inset 0 1px 2px rgba(0,0,0,.22);
    transition: border-color .15s var(--hr-ease), box-shadow .15s var(--hr-ease), background .15s var(--hr-ease);
}
.auth-card .form-control::placeholder { color: rgba(236,244,253,.55); }
/* Icon tucked inside the field (username / password), like the reference.
   Inputs are Latin/LTR, so keep the icon + its padding on the physical right
   edge regardless of the UI language. */
.auth-field { position: relative; }
.auth-field .form-control { padding-right: 42px; }
.auth-field .field-icon {
    position: absolute; right: 13px; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; color: rgba(236,244,253,.72); pointer-events: none;
}
/* Clickable show/hide-password eye toggle. */
.auth-field .field-toggle {
    position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
    width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
    padding: 0; background: transparent; border: 0; cursor: pointer;
    color: rgba(236,244,253,.72);
}
.auth-field .field-toggle:hover { color: #fff; }
.auth-field .field-toggle svg { width: 19px; height: 19px; }
.auth-field .field-toggle .ic-eye-off { display: none; }
.auth-field .field-toggle.on .ic-eye { display: none; }
.auth-field .field-toggle.on .ic-eye-off { display: block; }

.auth-remember { display: flex; align-items: center; gap: 8px; margin: 14px 0 2px;
    color: rgba(236,244,253,.9); font-size: 13px; cursor: pointer; }
.auth-remember input { width: 16px; height: 16px; accent-color: var(--hr-primary); cursor: pointer; }
.auth-card .form-control:focus {
    outline: none; background: rgba(255,255,255,.2); border-color: var(--hr-primary-soft);
    box-shadow: 0 0 0 3px rgba(90,147,218,.32);
}
.auth-card .btn-primary { width: 100%; margin-top: 22px; box-shadow: 0 14px 26px -12px rgba(18,63,121,.7); }
.auth-card .messages { margin: 4px 0 14px; }

@media (prefers-reduced-motion: reduce) {
    .auth-bg::before, .auth-bg::after, .auth-card { animation: none; }
}
@media (max-width: 480px) { .auth-card { padding: 28px 22px 24px; } }

/* Collapsible report panel (<details>) -------------------------------------*/
.report-cap {
    background: var(--hr-surface); border: 1px solid var(--hr-border);
    box-shadow: var(--hr-shadow); margin-bottom: 22px;
}
.report-cap > summary {
    list-style: none; cursor: pointer; user-select: none;
    display: flex; align-items: center; gap: 12px; padding: 18px 22px;
    font-family: var(--hr-font-display); font-weight: 800; font-size: 18px; color: var(--hr-text);
    transition: color .15s var(--hr-ease);
}
.report-cap > summary::-webkit-details-marker { display: none; }
.report-cap > summary::after {
    content: ""; margin-inline-start: auto; width: 9px; height: 9px;
    border-right: 2px solid var(--hr-primary); border-bottom: 2px solid var(--hr-primary);
    transform: rotate(45deg); transition: transform .2s var(--hr-ease);
}
.report-cap[open] > summary::after { transform: rotate(-135deg); }
.report-cap > summary:hover { color: var(--hr-primary); }
.report-cap > summary:focus-visible { outline: 2px solid var(--hr-primary); outline-offset: -2px; }
.report-cap .cap-body { padding: 0 22px 18px; }

/* Back button --------------------------------------------------------------*/
.back-bar { margin-bottom: 16px; }
.back-btn { cursor: pointer; }

/* Staff search bar ---------------------------------------------------------*/
.staff-search { display: flex; gap: 10px; margin: 4px 0 24px; }
.staff-search .form-control { flex: 1; }
.staff-search .btn { white-space: nowrap; }

/* Dashboard charts ---------------------------------------------------------*/
.chart-toolbar { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; margin-bottom: 8px; }
.seg { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.seg-label { font-size: 12px; font-weight: 700; color: var(--hr-muted); text-transform: uppercase; letter-spacing: .04em; }
.seg-btn {
    border: 1px solid var(--hr-border); background: #fff; color: var(--hr-text);
    padding: 6px 13px; border-radius: 0; font-size: 13px; font-weight: 600; cursor: pointer;
    transition: background-color .18s var(--hr-ease), color .18s var(--hr-ease), border-color .18s var(--hr-ease), transform .15s var(--hr-ease);
}
.seg-btn:hover { border-color: var(--hr-primary); color: var(--hr-primary); transform: translateY(-1px); }
.seg-btn.active { background: linear-gradient(180deg, var(--hr-primary-soft), var(--hr-primary)); border-color: var(--hr-primary); color: #fff; box-shadow: 0 4px 12px -6px rgba(26, 92, 174, .55); }
.chart-canvas { margin-top: 10px; min-height: 200px; }
.chart-canvas svg { display: block; width: 100%; height: auto; max-height: 360px; }
.chart-empty { text-align: center; padding: 60px 0; }

/* Donut + legend (Leave overview) ------------------------------------------*/
.donut-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 30px; padding: 10px 4px; }
.donut-figure { flex: 0 0 auto; width: 240px; max-width: 62vw; }
.donut-figure svg { width: 100%; height: auto; }
.chart-legend {
    flex: 1 1 300px; display: grid; gap: 12px 22px;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.lg-item { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--hr-text); }
.lg-dot { width: 12px; height: 12px; flex: 0 0 12px; border-radius: 50%; }
.lg-label { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-val { flex: 0 0 auto; font-weight: 800; color: var(--hr-primary-dark); font-variant-numeric: tabular-nums; }

/* Date range (start -> end): always laid out LTR so the arrow reads
   start->end in both English and Arabic (RTL was reordering the two dates). */
.date-range { direction: ltr; unicode-bidi: isolate; display: inline-block; white-space: nowrap; }

/* Leave overview: month bar + donut + mini bar cards -----------------------*/
.ov-months { display: flex; align-items: stretch; gap: 8px; margin-bottom: 18px; }
.ov-month-track { display: flex; gap: 6px; overflow-x: auto; flex: 1; padding: 2px; scroll-behavior: smooth; }
.ov-month {
    flex: 0 0 auto; min-width: 66px; display: flex; flex-direction: column; align-items: center; gap: 1px;
    padding: 8px 12px; background: #fff; border: 1px solid var(--hr-border); color: var(--hr-text);
    cursor: pointer; font-family: inherit; white-space: nowrap;
    transition: background-color .15s var(--hr-ease), color .15s var(--hr-ease), border-color .15s var(--hr-ease);
}
.ov-month:hover { border-color: var(--hr-primary); color: var(--hr-primary); }
.ov-month.active { background: linear-gradient(180deg, var(--hr-primary-soft), var(--hr-primary)); border-color: var(--hr-primary); color: #fff; }
.ovm-l { font-weight: 700; font-size: 13.5px; }
.ovm-y { font-size: 11px; opacity: .82; }
.ov-arrow {
    flex: 0 0 auto; width: 40px; border: 1px solid var(--hr-border); background: #fff;
    color: var(--hr-primary); font-size: 20px; line-height: 1; cursor: pointer;
    transition: background-color .15s var(--hr-ease), color .15s var(--hr-ease);
}
.ov-arrow:hover { background: var(--hr-primary); color: #fff; border-color: var(--hr-primary); }
.ov-title { margin: 4px 0 10px; }
.ov-month-name { display: block; font-family: var(--hr-font-display); font-weight: 800; font-size: 19px; color: var(--hr-text); }
.ov-sub { display: block; font-size: 13px; color: var(--hr-muted); }
.ov-donut { min-height: 200px; }
.ov-bars { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 20px; }
.ov-bar-card { border: 1px solid var(--hr-border); background: var(--hr-surface-2); padding: 14px 14px 8px; }
.ov-bar-title { font-size: 13px; font-weight: 700; color: var(--hr-primary-dark); margin-bottom: 4px; }
.ov-bar svg { width: 100%; height: auto; display: block; }

/* Motion: entrance choreography (respects reduced-motion) ------------------*/
@keyframes hr-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes hr-drop { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
@keyframes hr-fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: no-preference) {
    .sidebar { animation: hr-fade .5s var(--hr-ease) both; }
    .sidebar-nav a { animation: hr-rise .4s var(--hr-ease) both; }
    .sidebar-nav a:nth-child(1) { animation-delay: .06s; }
    .sidebar-nav a:nth-child(2) { animation-delay: .10s; }
    .sidebar-nav a:nth-child(3) { animation-delay: .14s; }
    .sidebar-nav a:nth-child(4) { animation-delay: .18s; }
    .sidebar-nav a:nth-child(5) { animation-delay: .22s; }
    .sidebar-nav a:nth-child(6) { animation-delay: .26s; }
    .sidebar-nav a:nth-child(7) { animation-delay: .30s; }
    .sidebar-nav a:nth-child(8) { animation-delay: .34s; }
    .page-title, .card, .staff-search, .messages li { animation: hr-rise .5s var(--hr-ease) both; }
    /* Stagger grid children so cards cascade in. */
    .grid > *:nth-child(1) { animation-delay: .03s; }
    .grid > *:nth-child(2) { animation-delay: .08s; }
    .grid > *:nth-child(3) { animation-delay: .13s; }
    .grid > *:nth-child(4) { animation-delay: .18s; }
    .grid > *:nth-child(5) { animation-delay: .23s; }
    .grid > *:nth-child(6) { animation-delay: .28s; }
    .grid > *:nth-child(7) { animation-delay: .33s; }
    .grid > *:nth-child(8) { animation-delay: .38s; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
    .btn::before { display: none; }
}
