/* Parse Book Request – dark theme */
.pbr-wrap {
    --pbr-bg: #171717;
    --pbr-bg-soft: #202020;
    --pbr-input-bg: #101010;
    --pbr-border: #4a4a4a;
    --pbr-border-focus: #b8b8b8;
    --pbr-text: #f5f5f5;
    --pbr-muted: #c7c7c7;
    --pbr-placeholder: #969696;
    --pbr-danger: #ff9b9b;
    --pbr-success: #a7e8b6;
    color: var(--pbr-text);
    color-scheme: dark;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    direction: ltr;
}

.pbr-wrap *,
.pbr-wrap *::before,
.pbr-wrap *::after {
    box-sizing: border-box;
}

.pbr-form {
    display: grid;
    gap: 1.5rem;
    width: 100%;
    margin: 0;
    padding: clamp(1rem, 2.5vw, 2rem);
    border: 1px solid #303030;
    border-radius: 10px;
    background: var(--pbr-bg);
    color: var(--pbr-text);
}

/* Keep WordPress/theme styles from making dark-form text unreadable. */
.pbr-wrap,
.pbr-wrap label,
.pbr-wrap h3,
.pbr-wrap p,
.pbr-wrap small {
    color: var(--pbr-text);
}

.pbr-grid {
    display: grid;
    gap: 1.15rem;
    width: 100%;
}

/* Name + email: equal columns, aligned from the top. */
.pbr-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
}

.pbr-field {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: .48rem;
    text-align: left;
}

.pbr-field label {
    display: block;
    margin: 0;
    font-size: .98rem;
    font-weight: 600;
    line-height: 1.35;
    min-height: 1.35em;
    color: var(--pbr-text) !important;
}

/* Make mixed Persian/English labels behave predictably in an LTR layout. */
.pbr-wrap [lang="fa"] {
    direction: rtl;
    unicode-bidi: isolate;
}

.pbr-wrap [lang="en"] {
    direction: ltr;
    unicode-bidi: isolate;
}

.pbr-field small,
.pbr-section-heading p {
    margin: 0;
    color: var(--pbr-muted) !important;
    font-size: .88rem;
    line-height: 1.65;
}

/* This helper text was the main source of the uneven top-row formatting. */
.pbr-contact-help {
    display: block;
    margin-top: .08rem;
    max-width: 100%;
    text-align: left;
    overflow-wrap: anywhere;
}

.pbr-field input,
.pbr-field textarea {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0;
    border: 1px solid var(--pbr-border) !important;
    border-radius: 6px;
    background: var(--pbr-input-bg) !important;
    color: var(--pbr-text) !important;
    -webkit-text-fill-color: var(--pbr-text);
    caret-color: var(--pbr-text);
    font: inherit;
    line-height: 1.4;
    padding: .78rem .85rem;
    box-shadow: none !important;
}

.pbr-field input {
    min-height: 46px;
}

.pbr-field textarea {
    min-height: 130px;
    resize: vertical;
}

.pbr-field input::placeholder,
.pbr-field textarea::placeholder {
    color: var(--pbr-placeholder) !important;
    -webkit-text-fill-color: var(--pbr-placeholder);
    opacity: 1;
}

.pbr-field input:focus,
.pbr-field textarea:focus {
    border-color: var(--pbr-border-focus) !important;
    outline: 2px solid rgba(255, 255, 255, .14);
    outline-offset: 1px;
}

.pbr-wrap input:-webkit-autofill,
.pbr-wrap input:-webkit-autofill:hover,
.pbr-wrap input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--pbr-text) !important;
    -webkit-box-shadow: 0 0 0 1000px var(--pbr-input-bg) inset !important;
    box-shadow: 0 0 0 1000px var(--pbr-input-bg) inset !important;
    caret-color: var(--pbr-text);
}

.pbr-required {
    color: var(--pbr-danger) !important;
}

.pbr-books {
    display: grid;
    gap: 1rem;
    width: 100%;
}

.pbr-section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem;
    width: 100%;
}

.pbr-section-heading > div {
    min-width: 0;
    flex: 1 1 auto;
}

.pbr-section-heading h3,
.pbr-section-heading p {
    margin: 0;
}

.pbr-section-heading h3 {
    color: var(--pbr-text) !important;
    font-size: clamp(1.05rem, 2vw, 1.25rem);
    line-height: 1.45;
}

.pbr-section-heading p {
    margin-top: .38rem;
}

.pbr-add-book,
.pbr-remove-book {
    appearance: none;
    flex: 0 0 auto;
    border: 1px solid var(--pbr-border) !important;
    background: var(--pbr-input-bg) !important;
    color: var(--pbr-text) !important;
    cursor: pointer;
    font: inherit;
    line-height: 1;
    box-shadow: none !important;
}

.pbr-add-book:hover,
.pbr-remove-book:hover {
    border-color: var(--pbr-border-focus) !important;
    background: #292929 !important;
}

.pbr-add-book {
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border-radius: 999px;
    font-size: 1.65rem;
}

.pbr-book-list {
    display: grid;
    gap: .9rem;
    width: 100%;
}

.pbr-book-row {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(100px, .55fr) minmax(0, 1.25fr) 2.4rem;
    gap: .85rem;
    align-items: end;
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--pbr-border);
    border-radius: 8px;
    background: var(--pbr-bg-soft);
}

.pbr-remove-book {
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    border-radius: 50%;
    font-size: 1.35rem;
    margin-bottom: .18rem;
}

.pbr-remove-book[hidden] {
    display: none;
}

.pbr-turnstile {
    min-height: 65px;
    max-width: 100%;
    overflow: hidden;
}

.pbr-submit {
    justify-self: start;
    min-height: 44px;
    border: 1px solid #e5e5e5 !important;
    border-radius: 6px;
    background: #f2f2f2 !important;
    color: #111 !important;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    padding: .8rem 1.35rem;
    box-shadow: none !important;
}

.pbr-submit:hover {
    background: #fff !important;
}

.pbr-submit:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.pbr-submit.is-loading {
    opacity: .65;
}

.pbr-notice {
    margin-bottom: 1rem;
    padding: .9rem 1rem;
    border: 1px solid var(--pbr-border);
    border-radius: 6px;
}

.pbr-success {
    border-color: #456d50;
    color: var(--pbr-success) !important;
    background: #142b1a;
}

.pbr-error {
    border-color: #814545;
    color: var(--pbr-danger) !important;
    background: #321616;
}

.pbr-warning {
    border-color: #80662f;
    color: #ffe49a !important;
    background: #30250d;
}

.pbr-honeypot {
    position: absolute !important;
    left: -99999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

@media (max-width: 760px) {
    .pbr-form {
        padding: 1rem;
        gap: 1.25rem;
    }

    .pbr-grid-2,
    .pbr-book-row {
        grid-template-columns: 1fr;
    }

    .pbr-section-heading {
        align-items: center;
    }

    .pbr-remove-book {
        justify-self: end;
        margin-bottom: 0;
    }
}

@media (max-width: 420px) {
    .pbr-section-heading {
        gap: .75rem;
    }

    .pbr-add-book {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.45rem;
    }
}
