/* Shalash Patient Form — Paper Style */

:root {
    --pf-purple: #3d2d6b;
    --pf-purple-dark: #2a1f4e;
    --pf-purple-light: #5c4a8a;
    --pf-text: #1a1a1a;
    --pf-muted: #555;
    --pf-line: #333;
    --pf-border: #ccc;
    --pf-paper: #ffffff;
    --pf-bg: #ffffff;
}

* { box-sizing: border-box; }

.patient-form-page {
    font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
    background: var(--pf-bg);
    min-height: 100vh;
    padding: 20px 10px 50px;
    color: var(--pf-text);
    font-size: 12px;
    line-height: 1.35;
}

.patient-nav {
    max-width: 560px;
    margin: 0 auto 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.patient-nav a {
    color: var(--pf-purple);
    text-decoration: none;
    font-weight: 600;
}

.patient-nav a:hover { text-decoration: underline; }

/* ── Paper sheet ── */
.patient-form-wrapper {
    max-width: 560px;
    margin: 0 auto;
    background: var(--pf-paper);
    box-shadow: 0 2px 16px rgba(0,0,0,0.18);
    position: relative;
    overflow: hidden;
}

/* Watermark */
.patient-form-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('../img/shalash_logo_transparent.png') center 46% / 58% no-repeat;
    opacity: 0.075;
    pointer-events: none;
    z-index: 0;
}

.patient-form-body {
    position: relative;
    z-index: 1;
    padding: 14px 34px 26px;
}

[dir="rtl"] .patient-form-body { text-align: right; }

/* ── Header (white pill with curved top + bottom in purple band) ── */
.pf-header {
    background: var(--pf-paper);
    position: relative;
    display: block;
    padding: 0;
    overflow: hidden;
}

.pf-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 76px;
    background: var(--pf-purple-dark);
    z-index: 1;
}

.pf-header::after {
    content: '';
    position: absolute;
    top: 6px;
    left: -95px;
    width: calc(100% + 190px);
    height: 74px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 100' preserveAspectRatio='none'%3E%3Cpath d='M0 40 C410 2 770 18 1000 72' fill='none' stroke='%23fff' stroke-width='3.2' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
    pointer-events: none;
    z-index: 3;
}

.pf-header-bar {
    display: none;
}

.pf-header-curve {
    width: calc(100% + 240px);
    max-width: none;
    background: var(--pf-paper);
    border-top: 1px solid rgba(255, 255, 255, 0.98);
    border-radius: 50% 50% 0 0 / 54px 54px 0 0;
    padding: 21px 24px 14px;
    text-align: center;
    position: relative;
    z-index: 2;
    margin: 29px -120px 0;
    box-shadow: 0 -2px 0 rgba(42, 31, 78, 0.45);
}

/* The reference has one curved white line on the paper edge, not a full oval. */
.pf-header-curve::before,
.pf-header-curve::after {
    display: none;
}

.pf-logo-img {
    max-width: 100%;
    width: 245px;
    height: auto;
    margin: 0 auto;
    display: block;
    position: relative;
    z-index: 1;
}

.pf-brand {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--pf-text);
    text-transform: uppercase;
    line-height: 1.3;
}

.pf-tagline {
    font-size: 11px;
    color: var(--pf-muted);
    margin-top: 3px;
    font-style: italic;
    letter-spacing: 0.3px;
}

.pf-footer-wave {
    height: 76px;
    background: var(--pf-purple-dark);
    position: relative;
    overflow: hidden;
}

.pf-footer-wave::before {
    content: '';
    position: absolute;
    top: -29px;
    left: -120px;
    width: calc(100% + 240px);
    height: 76px;
    background: var(--pf-paper);
    border-bottom: 1px solid rgba(255, 255, 255, 0.98);
    border-radius: 0 0 50% 50% / 0 0 54px 54px;
    box-shadow: 0 2px 0 rgba(42, 31, 78, 0.45);
    z-index: 2;
}

.pf-footer-wave::after {
    content: '';
    position: absolute;
    top: 12px;
    left: -95px;
    width: calc(100% + 190px);
    height: 74px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 100' preserveAspectRatio='none'%3E%3Cpath d='M0 60 C410 98 770 82 1000 28' fill='none' stroke='%23fff' stroke-width='3.2' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
    pointer-events: none;
    z-index: 3;
}

/* ── Line fields (paper underline style) ── */
.pf-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 4px 8px;
    margin-bottom: 7px;
}

.pf-row-full { width: 100%; }

.pf-label {
    white-space: nowrap;
    font-size: 12px;
    color: var(--pf-text);
    flex-shrink: 0;
}

.pf-label.required::after {
    content: ' *';
    color: #c0392b;
}

.pf-file-code-badge {
    display: inline-block;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--pf-primary, #1a6b8a);
    padding: 4px 12px;
    border: 2px solid var(--pf-primary, #1a6b8a);
    border-radius: 4px;
    background: #f0f8fb;
}

.pf-input-wrap {
    flex: 1;
    min-width: 80px;
}

.pf-input {
    width: 100%;
    border: none;
    border-bottom: 1px solid var(--pf-line);
    background: transparent;
    padding: 1px 3px 2px;
    font-size: 12px;
    font-family: inherit;
    color: var(--pf-text);
    outline: none;
    border-radius: 0;
}

.pf-input:focus {
    border-bottom-color: var(--pf-purple);
    border-bottom-width: 2px;
    padding-bottom: 2px;
}

.pf-input.is-invalid { border-bottom-color: #c0392b; }

.pf-input[type="date"],
.pf-input[type="number"] {
    appearance: none;
    -webkit-appearance: none;
}

.pf-input[readonly] {
    color: var(--pf-muted);
    background: transparent;
}

.pf-error {
    width: 100%;
    color: #c0392b;
    font-size: 11px;
    margin-top: -6px;
    margin-bottom: 4px;
}

/* ── Checkboxes / Radio (small squares like paper) ── */
.pf-checks {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 3px 11px;
}

.pf-check {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
}

.pf-check input[type="checkbox"],
.pf-check input[type="radio"] {
    width: 13px;
    height: 13px;
    accent-color: var(--pf-purple);
    cursor: pointer;
    margin: 0;
}

.pf-yn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-inline-start: 8px;
}

.pf-yn-label {
    font-size: 12px;
    font-weight: 600;
}

/* ── Section labels ── */
.pf-section-label {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--pf-text);
}

/* ── Health Status box ── */
.pf-health-box {
    border: 0;
    border-top: 1px solid var(--pf-line);
    padding: 8px 0 10px;
    margin: 12px 0;
    position: relative;
}

.pf-health-box-title {
    display: inline-block;
    border: 1.5px solid var(--pf-line);
    padding: 1px 9px;
    font-size: 12px;
    font-weight: 700;
    background: var(--pf-paper);
    position: relative;
    top: -18px;
    margin-bottom: -12px;
}

.pf-health-intro {
    font-size: 12px;
    color: var(--pf-text);
    margin: 0 0 10px;
    line-height: 1.5;
}

.pf-health-list {
    list-style: disc;
    padding-inline-start: 20px;
    margin: 0;
}

.pf-health-list > li {
    margin-bottom: 6px;
    font-size: 12px;
    line-height: 1.5;
}

.pf-health-list .pf-sub-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    margin-top: 4px;
    margin-inline-start: -8px;
    list-style: none;
}

.pf-females-block {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--pf-border);
}

.pf-females-title {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 6px;
}

.pf-females-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 20px;
    margin-bottom: 6px;
    font-size: 13px;
}

/* ── Referral ── */
.pf-referral-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 12px;
    margin-bottom: 8px;
}

/* ── Certification & Payment ── */
.pf-cert-text {
    font-size: 12px;
    line-height: 1.55;
    margin: 16px 0 10px;
    color: var(--pf-text);
}

.pf-policy-box {
    border: 1.5px solid var(--pf-line);
    padding: 8px 12px;
    margin-bottom: 16px;
    font-size: 12px;
    line-height: 1.5;
}

.pf-policy-title {
    display: inline-block;
    border: 1.5px solid var(--pf-line);
    padding: 0 8px;
    font-weight: 700;
    font-size: 12px;
    background: var(--pf-paper);
    position: relative;
    top: -16px;
    margin-bottom: -8px;
}

/* ── Signature ── */
.pf-signature-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
    margin-top: 8px;
}

.pf-signature-field {
    flex: 1;
    min-width: 200px;
}

.pf-signature-pad {
    border-bottom: 1px solid var(--pf-line);
    background: transparent;
    position: relative;
}

.pf-signature-pad canvas {
    display: block;
    width: 100%;
    height: 70px;
    cursor: crosshair;
    touch-action: none;
}

.pf-clear-sig {
    position: absolute;
    top: 2px;
    inset-inline-end: 0;
    background: none;
    border: none;
    font-size: 10px;
    color: #999;
    cursor: pointer;
    padding: 2px 4px;
}

.pf-clear-sig:hover { color: #c0392b; }

.pf-date-field {
    width: 160px;
    flex-shrink: 0;
}

/* ── Submit ── */
.pf-submit-wrap {
    text-align: center;
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px solid var(--pf-border);
}

.pf-submit-btn {
    background: var(--pf-purple);
    color: #fff;
    border: none;
    padding: 10px 40px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.3px;
    transition: background 0.2s;
}

.pf-submit-btn:hover { background: var(--pf-purple-dark); }
.pf-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Success page ── */
.pf-success {
    text-align: center;
    padding: 60px 30px;
    position: relative;
    z-index: 1;
}

.pf-success-icon {
    font-size: 48px;
    color: #27ae60;
    margin-bottom: 16px;
}

.pf-success h2 {
    color: var(--pf-purple);
    font-size: 20px;
    margin-bottom: 10px;
}

.pf-success p {
    color: var(--pf-muted);
    margin-bottom: 24px;
    line-height: 1.6;
}

.pf-back-btn {
    display: inline-block;
    background: var(--pf-purple);
    color: #fff;
    padding: 10px 28px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

.pf-back-btn:hover { background: var(--pf-purple-dark); color: #fff; }

/* ── Responsive ── */
@media (max-width: 600px) {
    .patient-form-page { padding: 0; }

    .patient-nav { padding: 10px 14px 0; }

    .patient-form-wrapper {
        width: 100%;
        box-shadow: none;
    }

    .patient-form-body { padding: 14px 28px 24px; }

    .pf-header { padding: 0; }

    .pf-header::before { height: 66px; }

    .pf-header::after {
        top: 13px;
        left: -95px;
        width: calc(100% + 190px);
        height: 48px;
        border-radius: 50% 50% 0 0 / 48px 48px 0 0;
    }

    .pf-header-curve {
        width: calc(100% + 190px);
        max-width: none;
        border-radius: 50% 50% 0 0 / 44px 44px 0 0;
        margin: 26px -95px 0;
        padding: 18px 16px 12px;
    }

    .pf-header-curve::before,
    .pf-header-curve::after {
        height: 26px;
    }

    .pf-logo-img { width: 230px; max-width: 78%; }

    .pf-footer-wave { height: 66px; }

    .pf-footer-wave::before {
        top: -26px;
        left: -95px;
        width: calc(100% + 190px);
        height: 66px;
        border-radius: 0 0 50% 50% / 0 0 44px 44px;
    }

    .pf-footer-wave::after {
        top: 10px;
        left: -75px;
        width: calc(100% + 150px);
        height: 62px;
    }

    .pf-row {
        flex-direction: row;
        align-items: flex-end;
    }

    .pf-checks { gap: 6px 10px; }

    .pf-signature-row { flex-direction: column; }

    .pf-date-field { width: 100%; }
}

@media print {
    .patient-nav, .pf-submit-wrap { display: none; }
    .patient-form-page { background: #fff; padding: 0; }
    .patient-form-wrapper { box-shadow: none; }
}

/* ── Admin view (read-only) ── */
.patient-form-page.patient-form-admin,
.patient-form-admin {
    padding: 0 10px 20px;
    background: transparent;
    min-height: 0;
}

.patient-form-admin .patient-form-wrapper {
    max-width: 560px;
    margin: 0 auto;
}

.patient-form-readonly input:not([type="hidden"]),
.patient-form-readonly canvas {
    pointer-events: none;
}

.patient-form-readonly .pf-check input:disabled {
    opacity: 1;
}

.pf-registered-meta {
    margin-top: 16px;
    font-size: 11px;
    color: var(--pf-muted, #555);
    text-align: center;
}

