/* ============================================================
   HRIS Brand Touch — overrides for Jidox theme (RTL + brand)
   Works WITH Jidox, not against it.
   Jidox already provides: --ct-leftbar-width, --ct-topbar-height,
   fixed sidebar, margin-right on content-page.
   ============================================================ */

:root {
    --hris-primary: #4254ba;
    --hris-primary-rgb: 66, 84, 186;
    --hris-primary-dark: #364691;
    --hris-accent: #17a497;
    --hris-bg: #f4f5f8;
    --hris-text: #495057;
    --hris-radius: 0.75rem;

    /* Override Jidox palette to match HRIS brand */
    --ct-primary: var(--hris-primary);
    --ct-primary-rgb: var(--hris-primary-rgb);
    --ct-secondary: #64748b;
    --ct-success: #17a497;
    --ct-info: #0dcaf0;
    --ct-warning: #f59e0b;
    --ct-danger: #ef4444;
}

html,
body {
    font-family: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
    background: var(--hris-bg);
}

html[dir="rtl"] body { text-align: right; }

/* ---------- Brand-tinted buttons ---------- */
.btn-primary {
    --bs-btn-bg: var(--hris-primary);
    --bs-btn-border-color: var(--hris-primary);
    --bs-btn-hover-bg: var(--hris-primary-dark);
    --bs-btn-hover-border-color: var(--hris-primary-dark);
    --bs-btn-active-bg: #2c3a7c;
    --bs-btn-active-border-color: #2c3a7c;
}

.btn-soft-primary {
    color: var(--hris-primary);
    background-color: rgba(var(--hris-primary-rgb), 0.12);
    border-color: transparent;
}
.btn-soft-primary:hover {
    color: #fff;
    background-color: var(--hris-primary);
}

.text-primary { color: var(--hris-primary) !important; }
.bg-primary   { background-color: var(--hris-primary) !important; }
.text-bg-primary { color: #fff !important; background-color: var(--hris-primary) !important; }

.bg-soft-primary { background-color: rgba(var(--hris-primary-rgb), 0.12) !important; color: var(--hris-primary) !important; }
.bg-soft-success { background-color: rgba(23, 164, 151, 0.12) !important; color: #17a497 !important; }
.bg-soft-warning { background-color: rgba(245, 158, 11, 0.12) !important; color: #f59e0b !important; }
.bg-soft-danger  { background-color: rgba(239, 68, 68, 0.12) !important; color: #ef4444 !important; }
.bg-soft-info    { background-color: rgba(13, 202, 240, 0.12) !important; color: #0dcaf0 !important; }

.badge.bg-primary   { background-color: var(--hris-primary) !important; }
.badge.bg-success   { background-color: #17a497 !important; }
.badge.bg-warning   { background-color: #f59e0b !important; }
.badge.bg-danger    { background-color: #ef4444 !important; }
.badge.bg-info      { background-color: #0dcaf0 !important; color: #fff !important; }
.badge.bg-secondary { background-color: #6c757d !important; }

/* ---------- Sidebar (works with Jidox's fixed positioning) ---------- */
.leftside-menu {
    background: linear-gradient(180deg, #1f2a44 0%, #2c3a5c 100%) !important;
    color: #cbd5e1;
    border-inline-start: 0 !important;
    box-shadow: 0 0 1.5rem rgba(31, 45, 65, 0.08) !important;
}

/* Sidebar collapse on small screens (mobile/tablet) */
@media (max-width: 991.98px) {
    .leftside-menu {
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 1045; /* above overlay so taps reach sidebar items */
    }
    .leftside-menu.show {
        transform: translateX(0);
    }
    .content-page {
        margin-right: 0 !important;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1030;
    }
    .sidebar-overlay.show {
        display: block;
    }
}

.leftside-menu::-webkit-scrollbar { width: 6px; }
.leftside-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

/* Sidebar scrolling — SimpleBar JS is NOT bundled in this project, so the
   `data-simplebar` container never gets its custom scrollbar. Fall back to a
   native vertical scroll on the menu container while keeping the logo pinned:
   flex column on .leftside-menu + min-height:0 on the scroll area.
   The Jidox `--ct-footer-height` padding-bottom is meant for a sidebar footer
   that this project doesn't render, so it's cleared to let the menu stretch
   the full viewport height. */
.leftside-menu {
    display: flex;
    flex-direction: column;
    padding-bottom: 0 !important;
}
.leftside-menu .logo {
    flex-shrink: 0;
}
.leftside-menu #leftside-menu-container {
    flex: 1 1 auto;
    min-height: 0;
    height: auto !important;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}
/* Subtle native scrollbar that blends with the dark sidebar (appears only
   while hovering/scrolling). Firefox uses scrollbar-color; WebKit below. */
.leftside-menu #leftside-menu-container {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.leftside-menu #leftside-menu-container::-webkit-scrollbar { width: 5px; }
.leftside-menu #leftside-menu-container::-webkit-scrollbar-track { background: transparent; }
.leftside-menu #leftside-menu-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 10px;
}
.leftside-menu #leftside-menu-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.32);
}
@media (max-width: 991.98px) {
    .leftside-menu { display: block; }
    .leftside-menu #leftside-menu-container { height: calc(100vh - var(--ct-topbar-height, 70px)) !important; }
}

.leftside-menu .logo {
    display: block;
    padding: 1.25rem 1rem;
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.leftside-menu .logo-text { color: #fff !important; }

/* Brand logo — the logo asset is a WIDE banner (aspect ~1.36:1), so it must
   be sized by WIDTH (not height) to look right in its container. */
.leftside-menu .logo {
    display: flex;
    align-items: center;
    min-height: var(--ct-topbar-height, 70px);
}
.leftside-menu .logo .logo-lg,
.leftside-menu .logo .logo-sm {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    width: 100%;
}
.leftside-menu .logo img.brand-logo {
    display: block;
    width: 150px;
    max-width: 100%;
    height: auto;
}
.topbar .logo-topbar {
    display: flex !important;
    align-items: center !important;
    justify-content: center;
    height: var(--ct-topbar-height, 70px);
    line-height: 1;
    float: none;
    padding: 0;
}
.topbar .logo-topbar a {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    height: 100%;
}
.topbar .logo-topbar img.brand-logo {
    display: block;
    height: 40px;
    width: auto;
    max-width: 180px;
    margin: auto 0;
    vertical-align: middle;
}
.brand-logo {
    height: auto;
    width: auto;
}
.auth-logo {
    width: 230px;
    max-width: 80%;
    height: auto;
}
.cfg-logo-preview {
    max-height: 56px;
    height: auto;
    width: auto;
}

.side-nav { list-style: none; padding: 0.5rem 0; margin: 0; }

.side-nav-title {
    color: #64748b;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.75rem 1.25rem 0.35rem;
}

.side-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    color: #cbd5e1 !important;
    text-decoration: none;
    border-inline-start: 3px solid transparent;
    font-size: 0.9rem;
    transition: all 0.18s;
}
.side-nav-link i { font-size: 1.15rem; min-width: 1.25rem; text-align: center; }
.side-nav-link:hover { background: rgba(255,255,255,0.05); color: #fff !important; }
.side-nav-link.active {
    background: rgba(var(--hris-primary-rgb), 0.18);
    color: #fff !important;
    border-inline-start-color: var(--hris-primary);
}

.leftbar-user { border-bottom: 1px solid rgba(255,255,255,0.06); }

/* ---------- Topbar (sticky) ---------- */
.navbar-custom, .topbar {
    background: #fff;
    box-shadow: 0 0.25rem 0.75rem rgba(31, 45, 65, 0.05);
}
.topbar {
    height: var(--ct-topbar-height, 70px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}
@media (min-width: 768px) { .topbar { padding: 0 1.5rem; } }

.topbar .logo-text { letter-spacing: 0.04em; color: var(--hris-primary); }

.topbar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-inline-start: auto; /* push to far end, opposite side of hamburger/logo */
}
.topbar-menu .nav-link { color: #6c757d; padding: 0.5rem 0.65rem; border-radius: 0.5rem; }
.topbar-menu .nav-link:hover { background: rgba(var(--hris-primary-rgb), 0.08); color: var(--hris-primary); }

/* Compact user toggle — fits inside the topbar without forcing a vertical strip */
.topbar-menu .nav-user {
    min-height: 0;
    height: auto;
    padding: 0.25rem 0.65rem;
    border: 0;
    background: transparent;
    border-radius: 0.5rem;
    color: #343a40;
}
.topbar-menu .nav-user:hover,
.topbar-menu .nav-user:focus,
.topbar-menu .nav-user[aria-expanded="true"] {
    background: rgba(var(--hris-primary-rgb), 0.08);
    color: var(--hris-primary);
}
.topbar-menu .nav-user .account-user-avatar img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    flex-shrink: 0;
}
.topbar-menu .nav-user .flex-column { line-height: 1.25; }

.account-user-name { display: block; font-weight: 600; color: #343a40; font-size: 0.85rem; }
.account-position { display: block; font-size: 0.75rem; color: #94a3b8; }

@media (max-width: 575.98px) {
    .account-user-name, .account-position { display: none; }
}

/* ---------- Cards (polish, keep Jidox sizing) ---------- */
.card {
    border: 0;
    box-shadow: 0 0.5rem 1.25rem rgba(31, 45, 65, 0.05);
    border-radius: var(--hris-radius);
    margin-bottom: 1.5rem; /* breathing room below each card */
    background: #fff;
}
.card-header {
    background: #fff;
    border-bottom: 1px solid #eef0f3;
    font-weight: 600;
    border-top-left-radius: var(--hris-radius);
    border-top-right-radius: var(--hris-radius);
}
.card-body { padding: 1.25rem; }
@media (max-width: 575.98px) {
    .card-body { padding: 1rem; }
    .card-header { padding: 0.85rem 1rem; }
}

.card > .row + .row,
.card > .row:first-child { margin: 0; }

/* breathing room below every grid row (so the bottom card doesn't touch the next section) */
.row { margin-bottom: 0.5rem; }
.row:last-child { margin-bottom: 1rem; }

/* Stat cards (admin dashboard) */
.widget-icon-box {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
}
.widget-icon-box:hover {
    transform: translateY(-3px);
    box-shadow: 0 1rem 2rem rgba(31, 45, 65, 0.1);
}
.widget-icon-box-avatar {
    width: 3rem;
    height: 3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Stat cards (employee portal) */
.stat-card {
    border: 0;
    border-radius: var(--hris-radius);
    overflow: hidden;
    position: relative;
    color: #fff;
    box-shadow: 0 0.5rem 1.25rem rgba(31, 45, 65, 0.08);
    transition: transform 0.2s ease;
    min-height: 130px;
}
.stat-card:hover { transform: translateY(-3px); }
.stat-card::after {
    content: "";
    position: absolute;
    inset-inline-end: -1.5rem;
    inset-block-start: -1.5rem;
    width: 6rem;
    height: 6rem;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    pointer-events: none;
}
.stat-card .stat-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    opacity: 0.85;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}
.stat-card .stat-value { font-size: 1.85rem; font-weight: 700; line-height: 1.1; }
.stat-card.bg-primary { background: linear-gradient(135deg, #4254ba 0%, #5b6cd2 100%) !important; }
.stat-card.bg-success { background: linear-gradient(135deg, #17a497 0%, #1cc8b6 100%) !important; }
.stat-card.bg-warning { background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%) !important; }
.stat-card.bg-danger  { background: linear-gradient(135deg, #ef4444 0%, #f87171 100%) !important; color: #fff; }
.stat-card.bg-info    { background: linear-gradient(135deg, #0dcaf0 0%, #38d9fa 100%) !important; }
.stat-card.bg-purple  { background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%) !important; }
.stat-card .card-body { display: flex; flex-direction: column; justify-content: space-between; }

/* Section nav cards (employee portal) */
.section-card {
    border: 2px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
}
.section-card:hover { border-color: var(--hris-primary); }
.section-card.border-primary { border-color: var(--hris-primary) !important; }

/* ---------- Tables ---------- */
.table { margin-bottom: 0; }
.table thead th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    font-weight: 700;
    border-bottom: 1px solid #eef0f3;
    background: #f8f9fa;
}
.table-centered th, .table-centered td { vertical-align: middle; }
.table-responsive { border-radius: var(--hris-radius); }

/* ---------- Page title ---------- */
.page-title-box {
    padding: 0 0 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
@media (min-width: 768px) {
    .page-title-box {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}
.page-title { font-size: 1.35rem; font-weight: 700; color: #1f2a44; margin: 0; }
.breadcrumb { background: transparent; padding: 0; margin: 0; }
.breadcrumb-item a { color: var(--hris-primary); text-decoration: none; }
.breadcrumb-item.active { color: #94a3b8; }

/* ---------- Footer ---------- */
.footer {
    background: #fff;
    border-top: 1px solid #eef0f3;
    padding: 1rem 0;
    font-size: 0.85rem;
    color: #6c757d;
    margin: 0;
}

/* Keep the footer pinned to the bottom of the viewport on short pages.
   Theme uses position:absolute + min-height on .content-page; if any rule
   breaks that (margin overrides, etc.) the footer drifts up. Pin it via flex. */
.content-page {
    display: flex;
    flex-direction: column;
    padding-bottom: 0 !important; /* theme reserved space for absolute footer; we use flex now */
}
.content-page > .content { flex: 1 1 auto; }
.content-page > .footer {
    position: relative !important;
    margin-top: auto;
    inset: auto !important;
    height: auto !important;
    width: 100%;
}

/* Page content gets bottom padding so the last card doesn't sit on the footer */
.content-page .content { padding-bottom: 2.5rem; }

/* ---------- Auth / Login pages ---------- */
.authentication-bg {
    min-height: 100vh;
    background: linear-gradient(135deg, #0e2a47 0%, #00459e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    position: relative;
    overflow: hidden;
}
.authentication-bg::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at top, rgba(255,255,255,0.08), transparent 60%);
    pointer-events: none;
}

.auth-card {
    max-width: 460px;
    width: 100%;
    border: 0;
    border-radius: 1rem;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1.5rem 4rem rgba(0,0,0,0.3);
    margin: 1.5rem 0;
}
.auth-card .auth-header {
    background: #fff;
    text-align: center;
    padding: 1.75rem 1.5rem 0.5rem;
}
.auth-card .auth-header .logo-icon {
    width: 4rem;
    height: 4rem;
    background: linear-gradient(135deg, var(--hris-primary) 0%, #5b6cd2 100%);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem;
    font-size: 1.65rem;
}
.auth-card .auth-body { padding: 1.5rem 1.75rem 1.75rem; }

@media (max-width: 575.98px) {
    .auth-card { max-width: 100%; }
    .auth-card .auth-body { padding: 1.25rem 1.25rem 1.5rem; }
}

.auth-form-control {
    border-radius: 0.5rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid #e0e0e0;
}
.auth-form-control:focus {
    border-color: var(--hris-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--hris-primary-rgb), 0.18);
}

.btn-brand {
    background: var(--hris-primary);
    color: #fff;
    border: 0;
    border-radius: 0.5rem;
    padding: 0.7rem 1.25rem;
    font-weight: 600;
    transition: all 0.18s;
}
.btn-brand:hover { background: var(--hris-primary-dark); color: #fff; transform: translateY(-1px); }
.btn-brand:disabled { opacity: 0.7; transform: none; }

.btn-ghost-light {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 0.5rem;
    padding: 0.7rem 1.25rem;
    transition: all 0.18s;
}
.btn-ghost-light:hover { background: rgba(255,255,255,0.2); color: #fff; }

/* ---------- Modals / responsive forms ---------- */
.modal-content { border: 0; border-radius: var(--hris-radius); }
.modal-header { border-bottom: 1px solid #eef0f3; }
.modal-footer { border-top: 1px solid #eef0f3; }

.nav-tabs .nav-link {
    color: #64748b;
    border: 0;
    border-bottom: 2px solid transparent;
    padding: 0.6rem 0.9rem;
    font-weight: 500;
}
.nav-tabs .nav-link.active {
    color: var(--hris-primary);
    background: transparent;
    border-bottom-color: var(--hris-primary);
}

/* Tabs scrollable on small screens */
@media (max-width: 767.98px) {
    .nav-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
    .nav-tabs .nav-link { white-space: nowrap; }
}

/* ---------- Profile (employee portal) ---------- */
.profile-hero {
    background: linear-gradient(135deg, var(--hris-primary) 0%, #5b6cd2 100%);
    color: #fff;
    border-radius: var(--hris-radius);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}
.profile-hero::after {
    content: "";
    position: absolute;
    inset-inline-end: -3rem;
    inset-block-end: -3rem;
    width: 10rem;
    height: 10rem;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
}
.profile-hero .avatar-ring {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
    border: 3px solid rgba(255,255,255,0.4);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 1.75rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}
.profile-hero .avatar-ring img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
@media (min-width: 576px) {
    .profile-hero .avatar-ring { width: 96px; height: 96px; font-size: 2rem; }
}

/* ---------- Print ---------- */
@media print {
    .leftside-menu, .topbar, .footer, .no-print { display: none !important; }
    .content-page { margin: 0 !important; }
    .card { box-shadow: none; border: 1px solid #dee2e6; }
}

/* ---------- Loading spinner helper ---------- */
.spinner-mini {
    width: 1rem; height: 1rem; border-width: 0.15rem;
    display: inline-block; vertical-align: text-bottom;
    border: 0.15rem solid currentColor; border-right-color: transparent;
    border-radius: 50%; animation: spinner-border 0.75s linear infinite;
}
@keyframes spinner-border { to { transform: rotate(360deg); } }
