/* ================================
   HR Policy Generator - FINAL CSS
   ================================ */

/* Frontend Form */
.hpg-wrapper {
    max-width: 1100px;
    margin: 30px auto;
    font-family: 'IBM Plex Sans Arabic', Tahoma, Arial, sans-serif;
    color: #111;
    direction: rtl;
}

.hpg-wrapper h2 {
    margin: 0 0 10px;
    font-size: 28px;
    font-weight: 800;
    color: #111;
}

.hpg-wrapper p {
    margin: 0 0 22px;
    color: #555;
    line-height: 1.8;
}

.hpg-form {
    background: #fff;
    border: 1px solid #e5e5e5;
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 12px 35px rgba(0,0,0,0.05);
}

.hpg-section {
    margin-bottom: 25px;
    padding-bottom: 22px;
    border-bottom: 1px solid #eee;
}

.hpg-section h3,
.hpg-grid h3 {
    margin: 0 0 15px;
    font-size: 20px;
    font-weight: 800;
    color: #111;
}

.hpg-form label {
    display: block;
    margin: 10px 0 6px;
    font-weight: 700;
    color: #222;
}

.hpg-form input[type="text"],
.hpg-form input[type="file"] {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #d7d7d7;
    border-radius: 9px;
    font-family: inherit;
    font-size: 14px;
    background: #fff;
}

.hpg-form input[type="text"]:focus,
.hpg-form input[type="file"]:focus {
    outline: none;
    border-color: #00ad55;
    box-shadow: 0 0 0 3px rgba(0,173,85,0.12);
}

.hpg-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 25px;
}

.hpg-grid > div {
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 14px;
    padding: 16px;
}

/* Plan notices */
.hpg-plan-notice {
    margin: 12px 0 18px;
    padding: 14px 18px;
    border-radius: 12px;
    background: rgba(47, 208, 122, 0.10);
    border: 1px solid rgba(47, 208, 122, 0.25);
    color: #111;
    font-weight: 700;
    line-height: 1.8;
}

.hpg-plan-notice.premium {
    background: rgba(47, 208, 122, 0.14);
}

/* Policy checkboxes */
.hpg-policies {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.hpg-policies label {
    background: #f7f7f7;
    padding: 12px 12px;
    border-radius: 10px;
    font-weight: 700;
    border: 1px solid #eee;
    cursor: pointer;
    transition: 0.18s ease;
}

.hpg-policies label:hover {
    background: #f1fff7;
    border-color: rgba(0,173,85,0.35);
}

.hpg-policies input {
    margin-left: 6px;
}

/* Locked policies for Classic plan */
.hpg-policy-locked {
    opacity: 0.52;
    cursor: not-allowed !important;
    background: #f1f1f1 !important;
    border-color: #e0e0e0 !important;
}

.hpg-policy-locked:hover {
    background: #f1f1f1 !important;
    border-color: #e0e0e0 !important;
}

.hpg-policy-locked input {
    cursor: not-allowed !important;
}

.hpg-locked-note {
    display: block;
    font-size: 12px;
    color: #777;
    margin-top: 5px;
    font-weight: 700;
}

/* Buttons */
.hpg-actions {
    display: flex;
    gap: 12px;
    margin-top: 25px;
    flex-wrap: wrap;
}

.hpg-actions button {
    border: 0;
    background: linear-gradient(135deg, #2fd07a, #159a55);
    color: #fff;
    padding: 13px 22px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 800;
    font-family: inherit;
    font-size: 15px;
    box-shadow: 0 12px 28px rgba(47,208,122,.22);
    transition: 0.22s ease;
}

.hpg-actions button:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 36px rgba(47,208,122,.34);
}

.hpg-actions button:disabled {
    opacity: 0.65;
    cursor: wait;
    transform: none;
}

/* Responsive form */
@media (max-width: 900px) {
    .hpg-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .hpg-policies {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .hpg-grid,
    .hpg-policies {
        grid-template-columns: 1fr;
    }

    .hpg-form {
        padding: 18px;
    }
}

/* ================================
   PDF Render Area
   ================================ */

/* Hidden render area used only for PDF capture.
   It must NOT be display:none / visibility:hidden. */
.hpg-render-stage {
    position: fixed;
    top: 0;
    left: 0;
    width: 794px;
    background: #fff;
    z-index: 999999;
    opacity: 1;
    pointer-events: none;
}

.hpg-document,
.hpg-document * {
    box-sizing: border-box;
}

.hpg-document {
    width: 794px;
    direction: rtl;
    unicode-bidi: embed;
    font-family: "Tahoma", "Arial", sans-serif;
    color: #111;
    background: #fff;
}

.hpg-document span,
.hpg-document p,
.hpg-document td {
    color: #111;
}

.hpg-page {
    width: 794px;
    height: 1123px;
    position: relative;
    overflow: hidden;
    background: #fff;
}

.hpg-header {
    position: absolute;
    top: 52px;
    left: 52px;
    width: 195px;
    height: 96px;
    z-index: 3;
}

.hpg-logo-box {
    width: 195px;
    height: 96px;
    border-radius: 13px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111;
    font-weight: 700;
    font-size: 24px;
    overflow: hidden;
}

.hpg-logo-box img {
    max-width: 90%;
    max-height: 80%;
    object-fit: contain;
}

.hpg-page-body {
    position: absolute;
    top: 170px;
    right: 52px;
    left: 52px;
    bottom: 88px;
}

.hpg-red {
    color: #111;
    font-weight: 700;
}

/* Cover */
.hpg-cover-page {
    background: #fff;
}

.hpg-cover-logo {
    position: absolute;
    top: 86px;
    left: 38px;
    z-index: 5;
    width: 290px;
    height: 120px;
    border-radius: 22px;
    font-size: 28px;
}

.cover-gray {
    position: absolute;
    left: -60px;
    top: 280px;
    width: 940px;
    height: 180px;
    background: #d9d9d9;
    transform: rotate(-10deg);
    transform-origin: left top;
    z-index: 1;
}

.cover-dark {
    position: absolute;
    left: -45px;
    top: 410px;
    width: 440px;
    height: 70px;
    background: #777;
    transform: rotate(-10deg);
    z-index: 2;
}

.cover-green {
    position: absolute;
    left: -110px;
    top: 455px;
    width: 1010px;
    height: 420px;
    background: #00ad55;
    transform: rotate(-7deg);
    z-index: 3;
}

.cover-title {
    position: absolute;
    top: 505px;
    left: 0;
    right: 0;
    text-align: center;
    z-index: 4;
    color: #fff;
    font-weight: 700;
}

.cover-ar {
    font-size: 48px;
    line-height: 1.45;
    margin-bottom: 22px;
}

.cover-en {
    font-size: 39px;
    line-height: 1.25;
    letter-spacing: .5px;
    direction: ltr;
}

/* Footer */
.hpg-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    z-index: 4;
    direction: ltr;
}

.footer-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: #e9e9e9;
    font-weight: 700;
}

.footer-page {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 145px;
    height: 70px;
    color: #fff;
    background: #2e2e2e;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    direction: rtl;
    z-index: 4;
}

.footer-org {
    position: absolute;
    right: 34px;
    bottom: 0;
    height: 70px;
    display: flex;
    align-items: center;
    color: #111;
    font-size: 20px;
    direction: rtl;
    z-index: 4;
}

.footer-green {
    position: absolute;
    bottom: 0;
    left: 132px;
    width: 42px;
    height: 70px;
    background: #00ad55;
    transform: skewX(-18deg);
    z-index: 3;
}

.footer-dark {
    position: absolute;
    bottom: 0;
    left: 118px;
    width: 28px;
    height: 70px;
    background: #2d2d2d;
    transform: skewX(-18deg);
    z-index: 2;
}

/* Revision / approval */
.revision-body {
    top: 150px;
}

.hpg-big-heading {
    color: #333;
    text-align: right;
    font-size: 28px;
    margin: 0 0 18px;
    font-weight: 800;
}

.hpg-rev-table,
.hpg-approval-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    direction: rtl;
    margin-bottom: 22px;
}

.hpg-rev-table th,
.hpg-approval-table th {
    background: #00ad55;
    color: #fff;
    border: 2px solid #fff;
    padding: 12px 8px;
    font-size: 18px;
    line-height: 1.3;
}

.hpg-rev-table td,
.hpg-approval-table td {
    background: #e9e9e9;
    border: 2px solid #fff;
    padding: 11px 7px;
    min-height: 48px;
    text-align: center;
    font-size: 14px;
    color: #111;
    font-weight: 700;
    vertical-align: middle;
}

.hpg-rev-table tbody tr:not(:first-child) td {
    height: 48px;
    color: #111;
    font-weight: 400;
}

.hpg-approval-title {
    margin-top: 12px;
}

.hpg-approval-table .side-col {
    width: 125px;
}

.hpg-approval-table th.side-col {
    background: #00ad55;
    color: #fff;
    font-size: 19px;
}

/* Signature row */
.hpg-approval-table .sign-row td {
    height: 90px;
    background: #fff;
}

.hpg-approval-table .sign-row th.side-col {
    height: 90px;
    background: #00ad55;
    color: #fff;
}

.hpg-note {
    font-size: 12px;
    line-height: 1.85;
    font-weight: 700;
    margin-top: 18px;
    text-align: right;
}

/* TOC */
.toc-body {
    top: 190px;
}

.toc-heading {
    color: #00ad55;
    text-align: right;
    font-size: 28px;
    font-weight: 800;
    margin: 0 0 38px;
}

.toc-list {
    margin-top: 25px;
}

.toc-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 15px;
    margin: 15px 0;
    direction: ltr;
}

.toc-page {
    width: 28px;
    text-align: left;
    direction: ltr;
}

.toc-dots {
    flex: 1;
    border-bottom: 2px dotted #222;
    height: 1px;
    transform: translateY(4px);
}

.toc-label {
    direction: rtl;
    text-align: right;
    min-width: max-content;
}

/* Content pages */
.content-body {
    top: 155px;
    right: 66px;
    left: 66px;
    bottom: 92px;
    font-size: 13.2px;
    line-height: 1.72;
}

.policy-main-title {
    font-size: 30px;
    color: #3a3a3a;
    text-align: right;
    border-bottom: 2px solid #888;
    padding-bottom: 12px;
    margin: 0 0 18px;
    font-weight: 800;
}

.hpg-dates-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 800;
    margin: 10px 0 16px;
}

.section-title {
    color: #00ad55;
    font-size: 22px;
    margin: 0 0 8px;
    font-weight: 800;
}

.sub-title {
    color: #9b9b9b;
    font-size: 19px;
    margin: 18px 0 8px;
    font-weight: 700;
}

.green-label {
    color: #00ad55;
    font-size: 18px;
    margin: 9px 0 2px;
    font-weight: 800;
}

.plain-para,
.num-item,
.bullet-item {
    margin: 0 0 7px;
    text-align: right;
}

.num-item {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.num-item .num {
    min-width: 24px;
    text-align: left;
    direction: ltr;
    font-weight: 500;
}

.bullet-item {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding-right: 22px;
}

.bullet-item span:first-child {
    min-width: 16px;
    color: #333;
}

@media screen {
    .hpg-document {
        transform-origin: top left;
    }
}

/* Generic content tables inside policy body */
.policy-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0 10px;
    direction: rtl;
    table-layout: fixed;
    font-size: 10.5px;
    line-height: 1.35;
}

.policy-table th {
    background: #00ad55;
    color: #fff !important;
    border: 1.5px solid #fff;
    padding: 5px 4px;
    text-align: center;
    font-weight: 800;
}

.policy-table td {
    background: #f1f1f1;
    color: #111 !important;
    border: 1.5px solid #fff;
    padding: 5px 4px;
    text-align: center;
    vertical-align: middle;
    font-weight: 600;
}

/* Loading popup while generating PDFs */
.hpg-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.92);
    z-index: 2147483647;
    display: none;
    align-items: center;
    justify-content: center;
    direction: rtl;
    font-family: Tahoma, Arial, sans-serif;
}

.hpg-loading-overlay.active {
    display: flex;
}

.hpg-loading-box {
    width: 420px;
    max-width: 90%;
    background: #fff;
    border-radius: 18px;
    padding: 34px 28px;
    text-align: center;
    box-shadow: 0 18px 50px rgba(0,0,0,0.18);
    border: 1px solid #eee;
}

.hpg-loading-spinner {
    width: 54px;
    height: 54px;
    border: 5px solid #e5e5e5;
    border-top-color: #00ad55;
    border-radius: 50%;
    margin: 0 auto 18px;
    animation: hpgSpin 1s linear infinite;
}

@keyframes hpgSpin {
    to {
        transform: rotate(360deg);
    }
}

.hpg-loading-title {
    font-size: 22px;
    font-weight: 800;
    color: #222;
    margin-bottom: 10px;
}

.hpg-loading-text {
    font-size: 15px;
    color: #555;
    line-height: 1.8;
}

.hpg-loading-progress {
    margin-top: 14px;
    color: #00ad55;
    font-weight: 700;
    font-size: 14px;
}