/* ============================================================
   HRIMS design tokens — light + dark themes.
   Theme is toggled by setting data-theme="dark" | "light" on <html>
   (see app.js hrims.theme.* and the anti-flash script in App.razor /
   SignIn.cshtml). Absence of data-theme falls back to system preference.
   ============================================================ */
:root {
    --hr-primary: #2563EB;
    --hr-primary-hover: #1D4ED8;
    --hr-primary-tint: #EFF6FF;
    --hr-primary-rgb: 37, 99, 235;

    --hr-ink: #0F172A;
    --hr-body: #334155;
    --hr-muted: #64748B;
    --hr-border: #E2E8F0;
    --hr-surface: #FFFFFF;
    --hr-surface-2: #F1F5F9;
    --hr-app-bg: #F8FAFC;

    --hr-success: #16A34A;
    --hr-success-bg: #DCFCE7;
    --hr-warning: #D97706;
    --hr-warning-bg: #FEF3C7;
    --hr-danger: #DC2626;
    --hr-danger-bg: #FEE2E2;

    --hr-accent-purple: #7C3AED;
    --hr-accent-purple-bg: #F3E8FF;
    --hr-accent-teal: #0D9488;
    --hr-accent-teal-bg: #CCFBF1;

    --hr-radius-card: 14px;
    --hr-radius-control: 10px;
    --hr-radius-pill: 999px;

    --hr-page-gutter: 28px;
    --hr-card-gap: 20px;

    --hr-shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.03);
    --hr-shadow-card-hover: 0 12px 28px rgba(15, 23, 42, 0.10);
    --hr-shadow-pop: 0 20px 45px rgba(15, 23, 42, 0.16);

    --hr-gradient-brand: linear-gradient(135deg, #2563EB 0%, #4F46E5 50%, #7C3AED 100%);
    --hr-gradient-mesh:
        radial-gradient(900px circle at 0% 0%, rgba(37, 99, 235, 0.06), transparent 45%),
        radial-gradient(900px circle at 100% 0%, rgba(124, 58, 237, 0.05), transparent 45%);
    --hr-glass-bg: rgba(255, 255, 255, 0.72);
    --hr-scrollbar-thumb: #CBD5E1;

    color-scheme: light;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;

    /* Chart palette — categorical, fixed order. Validated (lightness band,
       chroma, CVD separation, contrast) against the light surface. */
    --hr-viz-1: #2563EB;
    --hr-viz-2: #0D9488;
    --hr-viz-3: #9333EA;
    --hr-viz-4: #EA580C;
    --hr-viz-5: #0891B2;
    --hr-viz-6: #DB2777;
}

/* ---- dark theme (system preference, when no explicit choice saved) ---- */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --hr-primary: #4F8CFF;
        --hr-primary-hover: #6EA2FF;
        --hr-primary-tint: rgba(79, 140, 255, 0.14);
        --hr-primary-rgb: 79, 140, 255;

        --hr-ink: #F1F5F9;
        --hr-body: #CBD5E1;
        --hr-muted: #8A97AC;
        --hr-border: #26314A;
        --hr-surface: #131B2C;
        --hr-surface-2: #1B2436;
        --hr-app-bg: #0B1220;

        --hr-success: #34D399;
        --hr-success-bg: rgba(52, 211, 153, 0.14);
        --hr-warning: #FBBF24;
        --hr-warning-bg: rgba(251, 191, 36, 0.14);
        --hr-danger: #F87171;
        --hr-danger-bg: rgba(248, 113, 113, 0.14);

        --hr-accent-purple: #A78BFA;
        --hr-accent-purple-bg: rgba(167, 139, 250, 0.16);
        --hr-accent-teal: #2DD4BF;
        --hr-accent-teal-bg: rgba(45, 212, 191, 0.16);

        --hr-shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3);
        --hr-shadow-card-hover: 0 16px 32px rgba(0, 0, 0, 0.45);
        --hr-shadow-pop: 0 24px 50px rgba(0, 0, 0, 0.55);

        --hr-gradient-brand: linear-gradient(135deg, #3B82F6 0%, #6366F1 50%, #A855F7 100%);
        --hr-gradient-mesh:
            radial-gradient(900px circle at 0% 0%, rgba(79, 140, 255, 0.10), transparent 45%),
            radial-gradient(900px circle at 100% 0%, rgba(168, 85, 247, 0.08), transparent 45%);
        --hr-glass-bg: rgba(19, 27, 44, 0.72);
        --hr-scrollbar-thumb: #2C3A54;

        /* Chart palette, stepped for the dark surface (validated separately). */
        --hr-viz-1: #3B82F6;
        --hr-viz-2: #0D9488;
        --hr-viz-3: #9333EA;
        --hr-viz-4: #EA580C;
        --hr-viz-5: #0891B2;
        --hr-viz-6: #DB2777;

        color-scheme: dark;
    }
}

/* ---- dark theme (explicit user choice, wins over system preference) ---- */
:root[data-theme="dark"] {
    --hr-primary: #4F8CFF;
    --hr-primary-hover: #6EA2FF;
    --hr-primary-tint: rgba(79, 140, 255, 0.14);
    --hr-primary-rgb: 79, 140, 255;

    --hr-ink: #F1F5F9;
    --hr-body: #CBD5E1;
    --hr-muted: #8A97AC;
    --hr-border: #26314A;
    --hr-surface: #131B2C;
    --hr-surface-2: #1B2436;
    --hr-app-bg: #0B1220;

    --hr-success: #34D399;
    --hr-success-bg: rgba(52, 211, 153, 0.14);
    --hr-warning: #FBBF24;
    --hr-warning-bg: rgba(251, 191, 36, 0.14);
    --hr-danger: #F87171;
    --hr-danger-bg: rgba(248, 113, 113, 0.14);

    --hr-accent-purple: #A78BFA;
    --hr-accent-purple-bg: rgba(167, 139, 250, 0.16);
    --hr-accent-teal: #2DD4BF;
    --hr-accent-teal-bg: rgba(45, 212, 191, 0.16);

    --hr-shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3);
    --hr-shadow-card-hover: 0 16px 32px rgba(0, 0, 0, 0.45);
    --hr-shadow-pop: 0 24px 50px rgba(0, 0, 0, 0.55);

    --hr-gradient-brand: linear-gradient(135deg, #3B82F6 0%, #6366F1 50%, #A855F7 100%);
    --hr-gradient-mesh:
        radial-gradient(900px circle at 0% 0%, rgba(79, 140, 255, 0.10), transparent 45%),
        radial-gradient(900px circle at 100% 0%, rgba(168, 85, 247, 0.08), transparent 45%);
    --hr-glass-bg: rgba(19, 27, 44, 0.72);
    --hr-scrollbar-thumb: #2C3A54;

    color-scheme: dark;
    /* Chart palette, stepped for the dark surface (validated separately). */
    --hr-viz-1: #3B82F6;
    --hr-viz-2: #0D9488;
    --hr-viz-3: #9333EA;
    --hr-viz-4: #EA580C;
    --hr-viz-5: #0891B2;
    --hr-viz-6: #DB2777;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    background: var(--hr-app-bg);
    color: var(--hr-body);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Animate color-ish props only (never layout props) so the theme toggle
   feels smooth without causing jank on every render. */
.hr-card, .hr-sidebar, .hr-topbar, .hr-badge, button, input, .mud-paper {
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

::selection {
    background: var(--hr-primary);
    color: white;
}

/* ---- scrollbars ---------------------------------------------------------- */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--hr-scrollbar-thumb) transparent;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-thumb {
    background: var(--hr-scrollbar-thumb);
    border-radius: 999px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

/* ---- typography helpers ------------------------------------------------ */
.hr-page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--hr-ink);
    margin: 0;
    letter-spacing: -0.02em;
}

.hr-page-subtitle {
    font-size: 14px;
    font-weight: 400;
    color: var(--hr-muted);
    margin: 2px 0 0;
}

.hr-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--hr-ink);
    letter-spacing: -0.02em;
}

.hr-stat-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--hr-muted);
}

.hr-gradient-text {
    background: var(--hr-gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ---- surfaces ----------------------------------------------------------- */
.hr-card {
    background: var(--hr-surface);
    border: 1px solid var(--hr-border);
    border-radius: var(--hr-radius-card);
    box-shadow: var(--hr-shadow-card);
    transition: box-shadow 0.18s ease, transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

/* Opt-in lift for cards that act like buttons/links (report tiles, quick actions). */
.hr-card--interactive {
    cursor: pointer;
}

.hr-card--interactive:hover {
    box-shadow: var(--hr-shadow-card-hover);
    transform: translateY(-2px);
    border-color: rgba(var(--hr-primary-rgb), 0.35);
}

.hr-glass {
    background: var(--hr-glass-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

/* ---- status pills -------------------------------------------------------- */
.hr-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: var(--hr-radius-pill);
    font-size: 12px;
    font-weight: 600;
}

.hr-badge--success { color: var(--hr-success); background: var(--hr-success-bg); }
.hr-badge--warning { color: var(--hr-warning); background: var(--hr-warning-bg); }
.hr-badge--danger  { color: var(--hr-danger);  background: var(--hr-danger-bg); }
.hr-badge--neutral { color: var(--hr-muted);   background: var(--hr-surface-2); }
.hr-badge--primary { color: var(--hr-primary); background: var(--hr-primary-tint); }
.hr-badge--purple  { color: var(--hr-accent-purple); background: var(--hr-accent-purple-bg); }
.hr-badge--teal    { color: var(--hr-accent-teal);   background: var(--hr-accent-teal-bg); }

.hr-not-found {
    padding: var(--hr-page-gutter);
    color: var(--hr-muted);
}

/* ---- shared progress bar utility (leave balances, goal progress, etc.) --- */
.hr-progress-track {
    height: 6px;
    border-radius: var(--hr-radius-pill);
    background: var(--hr-surface-2);
    overflow: hidden;
}

.hr-progress-fill {
    height: 100%;
    border-radius: var(--hr-radius-pill);
    background: var(--hr-primary);
    transition: width 0.2s ease;
}

/* ---- theme toggle button (TopBar + SignIn) ----------------------- */
.hr-theme-toggle {
    color: var(--hr-muted) !important;
    background: var(--hr-surface-2) !important;
    border-radius: var(--hr-radius-control) !important;
}

.hr-theme-toggle:hover {
    color: var(--hr-primary) !important;
}

/* ---- generic fade-in for page/section entrances -------------------------- */
@keyframes hr-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.hr-fade-in {
    animation: hr-fade-in 0.35s ease both;
}

/* ============================================================
   Right-side drawer dialogs — every MudDialog in the app shares
   the Class="hr-dialog" root (see Components/Shared/*Dialog.razor),
   so one global override here turns all of them into a slide-in
   drawer instead of MudBlazor's default centered modal. Paired
   with Position = DialogPosition.CenterRight on each page's
   FormDialogOptions so MudBlazor's own layout agrees with us
   before this CSS ever paints.
   ============================================================ */

.hr-dialog.hr-dialog.hr-dialog.hr-dialog.hr-dialog.hr-dialog {
    position: fixed !important;
    inset: 0 !important;
    margin: 0 0 0 auto !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    width: clamp(480px, 46vw, 760px) !important;
    max-width: 100vw !important;
    border-radius: 20px 0 0 20px !important;
    overflow: hidden;
    display: flex !important;
    flex-direction: column !important;
    background: var(--hr-surface) !important;
    border-left: 1px solid var(--hr-border);
    box-shadow: -28px 0 70px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(15, 23, 42, 0.03) !important;
    animation: hr-drawer-in 0.34s cubic-bezier(0.16, 1, 0.3, 1);
}

/* thin brand accent riding the outer / free edge of the drawer */
.hr-dialog::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--hr-gradient-brand);
    z-index: 1;
}

/* A few dialogs carry more fields (Employee, Candidate, Job posting,
   Review, Payslip, Interview) — give them a touch more breathing room. */
.hr-dialog:has(.hr-dialog-grid > :nth-child(6)),
.hr-dialog:has(.hr-payslip-header) {
    width: clamp(560px, 52vw, 860px) !important;
}

@keyframes hr-drawer-in {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

@media (max-width: 640px) {
    .hr-dialog {
        width: 100vw !important;
        max-width: 100vw !important;
    }
}

/* Header stays pinned; only the form body scrolls */
.hr-dialog .hr-dialog-title {
    flex: 0 0 auto;
    padding: 22px 24px 18px;
    border-bottom: 1px solid var(--hr-border);
}

.hr-dialog .mud-dialog-content {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 22px 24px !important;
}

.hr-dialog .mud-dialog-content::-webkit-scrollbar {
    width: 8px;
}

.hr-dialog .mud-dialog-content::-webkit-scrollbar-thumb {
    background: var(--hr-scrollbar-thumb);
    border-radius: var(--hr-radius-pill);
}

/* Footer stays pinned to the bottom of the drawer */
.hr-dialog .mud-dialog-actions {
    flex: 0 0 auto;
    border-top: 1px solid var(--hr-border);
    padding: 14px 24px !important;
    margin: 0 !important;
    background: var(--hr-surface);
}

.hr-dialog .hr-dialog-actions {
    padding: 0 !important;
}

.hr-dialog .hr-dialog-btn {
    border-radius: var(--hr-radius-control);
    text-transform: none;
    font-weight: 600;
}

/* Give the title icon tile the same gradient treatment as the rest of
   the app instead of a flat tint, and tighten the grid rhythm a bit. */
.hr-dialog .hr-dialog-title-icon {
    background: var(--hr-gradient-brand);
    color: #fff;
}

.hr-dialog .hr-dialog-grid {
    gap: 16px 16px;
}

/* ============================================================
   Modern form fields — MudBlazor's stable outlined-field classes,
   so every MudTextField / MudSelect / MudNumericField / MudDatePicker
   in a drawer (or anywhere else) picks this up automatically.
   ============================================================ */

.mud-input-outlined .mud-input-outlined-border {
    border-radius: 12px !important;
    border-color: var(--hr-border) !important;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.mud-input-outlined {
    border-radius: 12px;
    transition: background-color 0.18s ease;
}

.mud-input-outlined:hover .mud-input-outlined-border {
    border-color: var(--hr-muted) !important;
}

.mud-input-outlined:hover {
    background: var(--hr-surface-2);
}

.mud-input-outlined:focus-within {
    background: var(--hr-surface);
}

.mud-input-outlined:focus-within .mud-input-outlined-border {
    border-color: var(--hr-primary) !important;
    border-width: 2px !important;
    box-shadow: 0 0 0 4px var(--hr-primary-tint);
}

.mud-input-outlined .mud-input-slot {
    padding-top: 15px;
    padding-bottom: 15px;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.mud-input-label {
    font-weight: 500;
    transition: color 0.18s ease;
}

.mud-input-label.mud-input-label-outlined.mud-input-shrink {
    color: var(--hr-primary);
    font-weight: 600;
}

.mud-input-helper-text {
    color: var(--hr-muted) !important;
    font-size: 12px;
}

.mud-input-error .mud-input-outlined-border {
    border-color: var(--hr-danger) !important;
}

.mud-input-error:focus-within .mud-input-outlined-border {
    box-shadow: 0 0 0 4px var(--hr-danger-bg);
}

.mud-select-input .mud-input-adornment .mud-icon-root,
.mud-picker-input-text .mud-input-adornment .mud-icon-root {
    color: var(--hr-muted);
    transition: color 0.18s ease, transform 0.18s ease;
}

.mud-input-outlined:focus-within .mud-input-adornment .mud-icon-root {
    color: var(--hr-primary);
}

/* Select chevron rotates open, like a proper modern combobox */
.mud-select.mud-select-input-with-dropdown-icon.mud-shrink .mud-input-adornment .mud-icon-root,
.mud-input-outlined:focus-within .mud-select-input .mud-input-adornment .mud-icon-root {
    transform: rotate(180deg);
}

/* Numeric field's up/down steppers, restyled to match the rounded shell */
.mud-input-outlined .mud-input-numeric-adornment button {
    border-radius: 6px;
    color: var(--hr-muted);
}

.mud-input-outlined .mud-input-numeric-adornment button:hover {
    color: var(--hr-primary);
    background: var(--hr-primary-tint);
}

/* MudMessageBox (delete confirms etc.) keep the classic centered
   card — just round it and lift it to match the rest of the app. */
.mud-dialog:not(.hr-dialog) {
    border-radius: var(--hr-radius-card) !important;
    box-shadow: var(--hr-shadow-pop) !important;
}

/* Soft blur behind the drawer for a more premium, layered feel */
.mud-overlay {
    backdrop-filter: blur(3px) !important;
    -webkit-backdrop-filter: blur(3px) !important;
    background-color: rgba(15, 23, 42, 0.35) !important;
}
