:root {
    --brand-primary: #0b5566;
    --brand-primary-dark: #083c48;
    --brand-accent: #0f8b8d;
    --brand-bg: #f5f8f9;
    --brand-border: #e2e8ec;
    --sidebar-width: 260px;
}

body {
    background-color: var(--brand-bg);
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    color: #1f2d33;
}

[dir="rtl"] body,
.rtl-field {
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

a {
    color: var(--brand-primary);
}

/* ---------- Buttons ---------- */
.btn-brand {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #fff;
}
.btn-brand:hover,
.btn-brand:focus {
    background-color: var(--brand-primary-dark);
    border-color: var(--brand-primary-dark);
    color: #fff;
}
.btn-outline-brand {
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}
.btn-outline-brand:hover {
    background-color: var(--brand-primary);
    color: #fff;
}

/* ---------- Auth / error pages ---------- */
.auth-page, .error-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-dark) 100%);
}
.auth-card {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    max-width: 420px;
    width: 100%;
}
.error-code {
    font-size: 5rem;
    font-weight: 700;
    color: var(--brand-primary);
    line-height: 1;
}

/* ---------- App shell ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--brand-primary-dark);
    color: #eaf4f4;
    flex-shrink: 0;
    transition: margin-left 0.2s ease, margin-right 0.2s ease;
}
.sidebar .brand-block {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}
.sidebar .nav-link {
    color: #cfe6e6;
    padding: 0.65rem 1rem;
    border-radius: 0.4rem;
    margin: 0.15rem 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.sidebar .nav-link:hover {
    background-color: rgba(255,255,255,0.08);
    color: #fff;
}
.sidebar .nav-link.active {
    background-color: var(--brand-accent);
    color: #fff;
}
.main-content {
    flex-grow: 1;
    min-width: 0;
}
.topbar {
    background-color: #fff;
    border-bottom: 1px solid var(--brand-border);
    padding: 0.75rem 1.25rem;
}
.page-body {
    padding: 1.5rem;
}
.card {
    border: 1px solid var(--brand-border);
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.stat-card {
    border-left: 4px solid var(--brand-primary);
}
.stat-card .stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--brand-primary-dark);
}

@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1050;
        margin-left: calc(-1 * var(--sidebar-width));
    }
    .sidebar.show {
        margin-left: 0;
    }
    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 1040;
    }
    .sidebar-backdrop.show {
        display: block;
    }
}

/* ---------- Photo / thumbnails ---------- */
.employee-photo-thumb {
    width: 42px;
    height: 42px;
    object-fit: cover;
    border-radius: 50%;
    border: 1px solid var(--brand-border);
}
.employee-photo-lg {
    width: 160px;
    height: 160px;
    object-fit: cover;
    border-radius: 0.5rem;
    border: 1px solid var(--brand-border);
    background: #fff;
}

/* ---------- Card photo cropper ---------- */
.employee-photo-card-preview {
    width: 160px;
    height: 160px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid #1a1a1a;
    background: #fff;
}
.photo-crop-stage {
    height: 55vh;
    min-height: 300px;
    background: #f0f3f4;
}
.photo-crop-stage img {
    display: block;
    max-width: 100%;
}
#photo-crop-modal .cropper-view-box,
#photo-crop-modal .cropper-face {
    border-radius: 50%;
}
#photo-crop-modal .cropper-view-box {
    outline: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.35);
}

/* ---------- RTL helpers ---------- */
.dir-rtl {
    direction: rtl;
    text-align: right;
}

/* ---------- Required field indicator ---------- */
.required-mark {
    color: #c0392b;
    margin-left: 0.15rem;
}

/* ---------- Employee ID card (portrait CR80: 53.98mm x 85.6mm) ---------- */
/* Card typefaces (bundled so the card prints identically on every PC):
   Century Gothic for Latin text, Diwan Muna for Arabic. */
@font-face {
    font-family: "Century Gothic";
    src: url("../fonts/CenturyGothic.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: block;
}
@font-face {
    font-family: "Century Gothic";
    src: url("../fonts/CenturyGothic-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: block;
}
/* Only the Bold cut is licensed; it covers both weights so no faux-bold is synthesised. */
@font-face {
    font-family: "Diwan Muna";
    src: url("../fonts/DiwanMuna-Bold.woff2") format("woff2"),
         url("../fonts/DiwanMuna-Bold.woff") format("woff"),
         url("../fonts/DiwanMuna-Bold.ttf") format("truetype");
    font-weight: 400 700;
    font-style: normal;
    font-display: block;
}
.card-preview-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: center;
}
.id-card {
    width: 53.98mm;
    height: 85.6mm;
    border-radius: 2.5mm;
    box-shadow: 0 4px 14px rgba(0,0,0,0.18);
    position: relative;
    overflow: hidden;
    background: #fff;
    font-family: "Century Gothic", "Segoe UI", Arial, sans-serif;
    font-size: 8px;
    color: #1a1a1a;
}
.id-card .name-ar,
.id-card .card-category-row .ar,
.id-card .card-department .ar {
    font-family: "Diwan Muna", "Segoe UI", Tahoma, Arial, sans-serif;
}
.id-card-front,
.id-card-back {
    background: #ffffff;
}
.id-card .card-pad {
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}
/* The back's logo is the same artwork cut from the front template and placed
   at the same percentages, so front and back line up exactly. The empty
   .card-logo-row just reserves that space in the flex column below it. */
.id-card .card-back-logo {
    position: absolute;
}
.id-card .card-logo-row {
    width: 100%;
    flex-shrink: 0;
}

/* --- Front ---
   The front uses the client's own template image (one per category, see
   EmployeeController::CATEGORY_CARD_TEMPLATE) as the card's background -
   logo and colored banner are baked into that image. The employee photo,
   the ring/ribbon PNG (drawn above the photo so its stroke hides the photo
   edge) and the text are overlaid, absolutely positioned using percentages
   measured directly off each template image. */
.id-card-front {
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
}
.id-card .card-front-name-overlay {
    position: absolute;
    left: 0;
    width: 100%;
    box-sizing: border-box;
    padding: 0 2mm;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    text-align: center;
}
.id-card .card-front-name-overlay .name-ar {
    font-size: 14px;
    font-weight: 700;
    direction: rtl;
    line-height: 1.25;
}
.id-card .card-front-name-overlay .name-en {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    line-height: 1.25;
    margin-top: 0.5mm;
}
.id-card .card-front-photo-overlay {
    position: absolute;
    border-radius: 50%;
    object-fit: cover;
    background: #f0f3f4;
}
.id-card .card-front-ring-overlay {
    position: absolute;
    object-fit: contain;
    pointer-events: none;
}
.id-card .card-front-text-overlay {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    box-sizing: border-box;
    padding: 0 3mm 1mm;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}
.id-card .card-category-row {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 2.5mm;
    font-size: 12px;
    line-height: 1.3;
    color: #1a1a1a;
}
.id-card .card-category-row .ar {
    direction: rtl;
    font-weight: 700;
    font-size: 14px;
}
.id-card .card-department {
    margin-top: 0.5mm;
    font-size: 11.5px;
    color: #1a1a1a;
    line-height: 1.4;
}
.id-card .card-department .ar {
    direction: rtl;
    display: block;
    font-weight: 700;
    font-size: 15px;
}
.id-card .card-department .en {
    display: block;
}

/* --- Back --- */
.id-card .card-qr-wrap {
    margin: 10mm auto 10mm auto;
}
.id-card .card-qr {
    width: 26mm;
    height: 26mm;
    display: block;
}
.id-card .card-ids-block {
    width: 100%;
    box-sizing: border-box;
    padding: 0 3mm 4mm 9mm;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.8;
    color: #1a1a1a;
}

@media print {
    .no-print {
        display: none !important;
    }
}
