/* Persian Text Support - Content Only */
/* This file provides Persian text alignment without affecting overall layout direction */

/* Enhanced validation styling for Publication Source field */
#publicationSourceError {
    display: none;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

#publicationSource.is-invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

#publicationSource.is-valid {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

#publicationSourceError.show {
    display: block;
}

/* Required fields note styling in modal footer */
.add-publication-modal-footer .text-muted {
    font-size: 0.875rem;
    line-height: 1.4;
}

.add-publication-modal-footer .text-muted i {
    color: #6c757d;
}

/* Enhanced validation styling for all form fields */
.invalid-feedback {
    display: none !important;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    color: #dc3545;
    width: 100%;
}

.invalid-feedback.show {
    display: block !important;
}

/* Force display of validation messages */
.invalid-feedback.d-block {
    display: block !important;
}

.form-control.is-invalid,
.form-select.is-invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.form-control.is-valid,
.form-select.is-valid {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

/* Persian text content areas */
.persian-text,
[lang="fa"],
[lang="ar"],
[lang="ur"] {
    direction: rtl;
    text-align: right;
    font-family: 'Tahoma', 'Arial Unicode MS', 'Arial', sans-serif;
}

/* Override RTL for publication modal elements (English only) */
html:not([lang="fa"]) #addPublicationModal [lang="fa"],
html:not([lang="fa"]) #addPublicationModal [lang="ar"],
html:not([lang="fa"]) #addPublicationModal [lang="ur"] {
    direction: auto !important;
    text-align: auto !important;
}

/* Persian text in specific content areas */
.review-content[lang="fa"],
.review-content[lang="ar"],
.review-content[lang="ur"],
.post-content[lang="fa"],
.post-content[lang="ar"],
.post-content[lang="ur"],
.publication-title[lang="fa"],
.publication-title[lang="ar"],
.publication-title[lang="ur"],
.study-title[lang="fa"],
.study-title[lang="ar"],
.study-title[lang="ur"] {
    direction: rtl;
    text-align: right;
    font-family: 'Tahoma', 'Arial Unicode MS', 'Arial', sans-serif;
}

/* Persian text in form inputs */
input[lang="fa"],
textarea[lang="fa"],
select[lang="fa"] {
    direction: rtl;
    text-align: right;
}

/* OVERRIDE: LTR form fields in modals when site language is English */
html:not([lang="fa"]) .modal input,
html:not([lang="fa"]) .modal textarea,
html:not([lang="fa"]) .modal select,
html:not([lang="fa"]) #addReviewModal input,
html:not([lang="fa"]) #addReviewModal textarea,
html:not([lang="fa"]) #addReviewModal select,
html:not([lang="fa"]) #addPublicationModal input,
html:not([lang="fa"]) #addPublicationModal textarea,
html:not([lang="fa"]) #addPublicationModal select,
html:not([lang="fa"]) #editPostModal input,
html:not([lang="fa"]) #editPostModal textarea,
html:not([lang="fa"]) #editPostModal select {
    direction: ltr !important;
    text-align: left !important;
}

/* Persian text in modals */
.modal-body [lang="fa"],
.modal-body [lang="ar"],
.modal-body [lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Override RTL for publication modal body elements (English only) */
html:not([lang="fa"]) #addPublicationModal .modal-body [lang="fa"],
html:not([lang="fa"]) #addPublicationModal .modal-body [lang="ar"],
html:not([lang="fa"]) #addPublicationModal .modal-body [lang="ur"] {
    direction: auto !important;
    text-align: auto !important;
}

/* Custom file upload styling */
.custom-file-upload {
    position: relative;
    display: inline-block;
    width: 100%;
}

.custom-file-label {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    background-color: #f8f9fa;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    width: 100%;
    text-align: center;
    font-size: 0.875rem;
    color: #495057;
}

.custom-file-label:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

.custom-file-label i {
    margin-right: 0.5rem;
}

.file-name {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #6c757d;
    text-align: center;
}

/* RTL support for custom file upload */
[lang="fa"] .custom-file-label {
    text-align: center;
    direction: rtl;
}

[lang="fa"] .file-name {
    text-align: center;
    direction: rtl;
}

/* Persian text in cards */
.card-body [lang="fa"],
.card-body [lang="ar"],
.card-body [lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Exception for publisher content to preserve Word formatting */
.card-body .publisher-content [lang="fa"],
.card-body .publisher-content [lang="ar"],
.card-body .publisher-content [lang="ur"],
.publisher-content [lang="fa"],
.publisher-content [lang="ar"],
.publisher-content [lang="ur"] {
    /* Don't override inline styles - let them work naturally */
}

/* Persian text in alerts */
.alert [lang="fa"],
.alert [lang="ar"],
.alert [lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in tables */
.table [lang="fa"],
.table [lang="ar"],
.table [lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in lists */
ul [lang="fa"],
ol [lang="fa"],

/* Post cards text direction and justification */
.post-card .card-title[dir="rtl"] {
    direction: rtl;
    text-align: justify;
}

.post-card .card-title[dir="ltr"] {
    direction: ltr;
    text-align: justify;
}

.post-card .card-text[dir="rtl"] {
    direction: rtl;
    text-align: justify;
}

.post-card .card-text[dir="ltr"] {
    direction: ltr;
    text-align: justify;
}

/* Also target any p tags within card-text */
.post-card .card-text p[dir="rtl"] {
    direction: rtl !important;
    text-align: justify !important;
}

.post-card .card-text p[dir="ltr"] {
    direction: ltr !important;
    text-align: justify !important;
}

/* More specific selectors for postcard content */
.post-card .card-text p {
    text-align: justify !important;
}

/* Force justification for all text in postcards */
.post-card .card-text {
    text-align: justify !important;
}

.post-card .card-text * {
    text-align: justify !important;
}

/* Ultra-specific selectors for postcard content */
.post-card .card-text[dir="rtl"] {
    direction: rtl !important;
    text-align: justify !important;
}

.post-card .card-text[dir="ltr"] {
    direction: ltr !important;
    text-align: justify !important;
}

/* Target the actual content within card-text */
.post-card .card-text p {
    text-align: justify !important;
    direction: inherit !important;
}

.post-card .card-text p[dir="rtl"] {
    direction: rtl !important;
    text-align: justify !important;
}

.post-card .card-text p[dir="ltr"] {
    direction: ltr !important;
    text-align: justify !important;
}

/* Post content in details page */
.post-content p[dir="rtl"] {
    direction: rtl;
    text-align: justify;
}

.post-content p[dir="ltr"] {
    direction: ltr;
    text-align: justify;
}
ul [lang="ar"],
ol [lang="ar"],
ul [lang="ur"],
ol [lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in navigation (if needed) */
.nav-link[lang="fa"],
.nav-link[lang="ar"],
.nav-link[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in buttons */
.btn[lang="fa"],
.btn[lang="ar"],
.btn[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in badges */
.badge[lang="fa"],
.badge[lang="ar"],
.badge[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in dropdowns */
.dropdown-item[lang="fa"],
.dropdown-item[lang="ar"],
.dropdown-item[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in tooltips */
.tooltip[lang="fa"],
.tooltip[lang="ar"],
.tooltip[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in popovers */
.popover[lang="fa"],
.popover[lang="ar"],
.popover[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in breadcrumbs */
.breadcrumb-item[lang="fa"],
.breadcrumb-item[lang="ar"],
.breadcrumb-item[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in pagination */
.page-link[lang="fa"],
.page-link[lang="ar"],
.page-link[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in form validation messages */
.invalid-feedback[lang="fa"],
.invalid-feedback[lang="ar"],
.invalid-feedback[lang="ur"],
.valid-feedback[lang="fa"],
.valid-feedback[lang="ar"],
.valid-feedback[lang="ur"],
.text-danger[lang="fa"],
.text-danger[lang="ar"],
.text-danger[lang="ur"],
div[id$="-error"][lang="fa"],
div[id$="-error"][lang="ar"],
div[id$="-error"][lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Ensure proper bidirectional text handling in validation messages */
.text-danger[dir="rtl"] bdi,
div[id$="-error"][dir="rtl"] bdi {
    direction: ltr;
    unicode-bidi: isolate;
}

/* Persian text in input groups */
.input-group-text[lang="fa"],
.input-group-text[lang="ar"],
.input-group-text[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in progress bars */
.progress-bar[lang="fa"],
.progress-bar[lang="ar"],
.progress-bar[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in spinners */
.spinner-border[lang="fa"],
.spinner-border[lang="ar"],
.spinner-border[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in placeholders */
::placeholder[lang="fa"],
::placeholder[lang="ar"],
::placeholder[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in labels */
label[lang="fa"],
label[lang="ar"],
label[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in legends */
legend[lang="fa"],
legend[lang="ar"],
legend[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in fieldset */
fieldset[lang="fa"],
fieldset[lang="ar"],
fieldset[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in figure captions */
figcaption[lang="fa"],
figcaption[lang="ar"],
figcaption[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in blockquotes */
blockquote[lang="fa"],
blockquote[lang="ar"],
blockquote[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in code blocks */
code[lang="fa"],
code[lang="ar"],
code[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in pre blocks */
pre[lang="fa"],
pre[lang="ar"],
pre[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in kbd elements */
kbd[lang="fa"],
kbd[lang="ar"],
kbd[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in samp elements */
samp[lang="fa"],
samp[lang="ar"],
samp[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in var elements */
var[lang="fa"],
var[lang="ar"],
var[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in mark elements */
mark[lang="fa"],
mark[lang="ar"],
mark[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in small elements */
small[lang="fa"],
small[lang="ar"],
small[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in sub elements */
sub[lang="fa"],
sub[lang="ar"],
sub[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in sup elements */
sup[lang="fa"],
sup[lang="ar"],
sup[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in del elements */
del[lang="fa"],
del[lang="ar"],
del[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in ins elements */
ins[lang="fa"],
ins[lang="ar"],
ins[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in u elements */
u[lang="fa"],
u[lang="ar"],
u[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in s elements */
s[lang="fa"],
s[lang="ar"],
s[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in strike elements */
strike[lang="fa"],
strike[lang="ar"],
strike[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in em elements */
em[lang="fa"],
em[lang="ar"],
em[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in strong elements */
strong[lang="fa"],
strong[lang="ar"],
strong[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in b elements */
b[lang="fa"],
b[lang="ar"],
b[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in i elements */
i[lang="fa"],
i[lang="ar"],
i[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in span elements */
span[lang="fa"],
span[lang="ar"],
span[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in div elements */
div[lang="fa"],
div[lang="ar"],
div[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in p elements */
p[lang="fa"],
p[lang="ar"],
p[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in h1-h6 elements */
h1[lang="fa"], h2[lang="fa"], h3[lang="fa"], h4[lang="fa"], h5[lang="fa"], h6[lang="fa"],
h1[lang="ar"], h2[lang="ar"], h3[lang="ar"], h4[lang="ar"], h5[lang="ar"], h6[lang="ar"],
h1[lang="ur"], h2[lang="ur"], h3[lang="ur"], h4[lang="ur"], h5[lang="ur"], h6[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in a elements */
a[lang="fa"],
a[lang="ar"],
a[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in abbr elements */
abbr[lang="fa"],
abbr[lang="ar"],
abbr[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in acronym elements */
acronym[lang="fa"],
acronym[lang="ar"],
acronym[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in address elements */
address[lang="fa"],
address[lang="ar"],
address[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in article elements */
article[lang="fa"],
article[lang="ar"],
article[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in aside elements */
aside[lang="fa"],
aside[lang="ar"],
aside[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in footer elements */
footer[lang="fa"],
footer[lang="ar"],
footer[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in header elements */
header[lang="fa"],
header[lang="ar"],
header[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in main elements */
main[lang="fa"],
main[lang="ar"],
main[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in nav elements */
nav[lang="fa"],
nav[lang="ar"],
nav[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in section elements */
section[lang="fa"],
section[lang="ar"],
section[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in time elements */
time[lang="fa"],
time[lang="ar"],
time[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in wbr elements */
wbr[lang="fa"],
wbr[lang="ar"],
wbr[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in br elements */
br[lang="fa"],
br[lang="ar"],
br[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in hr elements */
hr[lang="fa"],
hr[lang="ar"],
hr[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in img elements */
img[lang="fa"],
img[lang="ar"],
img[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in map elements */
map[lang="fa"],
map[lang="ar"],
map[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in area elements */
area[lang="fa"],
area[lang="ar"],
area[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in canvas elements */
canvas[lang="fa"],
canvas[lang="ar"],
canvas[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in embed elements */
embed[lang="fa"],
embed[lang="ar"],
embed[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in iframe elements */
iframe[lang="fa"],
iframe[lang="ar"],
iframe[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in object elements */
object[lang="fa"],
object[lang="ar"],
object[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in param elements */
param[lang="fa"],
param[lang="ar"],
param[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in source elements */
source[lang="fa"],
source[lang="ar"],
source[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in track elements */
track[lang="fa"],
track[lang="ar"],
track[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in video elements */
video[lang="fa"],
video[lang="ar"],
video[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in audio elements */
audio[lang="fa"],
audio[lang="ar"],
audio[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in picture elements */
picture[lang="fa"],
picture[lang="ar"],
picture[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in svg elements */
svg[lang="fa"],
svg[lang="ar"],
svg[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in math elements */
math[lang="fa"],
math[lang="ar"],
math[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in script elements */
script[lang="fa"],
script[lang="ar"],
script[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in style elements */
style[lang="fa"],
style[lang="ar"],
style[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in title elements */
title[lang="fa"],
title[lang="ar"],
title[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in meta elements */
meta[lang="fa"],
meta[lang="ar"],
meta[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in link elements */
link[lang="fa"],
link[lang="ar"],
link[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in base elements */
base[lang="fa"],
base[lang="ar"],
base[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in head elements */
head[lang="fa"],
head[lang="ar"],
head[lang="ur"] {
    direction: rtl;
    text-align: right;
}

/* Persian text in body elements — content only; header/navbar stay LTR */
body[lang="fa"] main,
body[lang="ar"] main,
body[lang="ur"] main {
    direction: rtl;
    text-align: right;
}

/* Persian page content — do not flip global layout (navbar, top bar) */
html[lang="fa"] main,
html[lang="ar"] main,
html[lang="ur"] main {
    direction: rtl;
    text-align: right;
}

/* Post card text direction classes (similar to review cards) */
.post-card .text-rtl {
    direction: rtl !important;
}

.post-card .text-ltr {
    direction: ltr !important;
}

.post-card .text-justify-rtl {
    direction: rtl !important;
    text-align: justify !important;
    text-align-last: right !important;
}

.post-card .text-justify-ltr {
    direction: ltr !important;
    text-align: justify !important;
    text-align-last: left !important;
}

/* Post card text content specific styles */
.post-card .card-text {
    text-align: justify !important;
    line-height: 1.6 !important;
    word-spacing: 0.1em !important;
    hyphens: auto !important;
    -webkit-hyphens: auto !important;
    -moz-hyphens: auto !important;
    -ms-hyphens: auto !important;
}

/* RTL specific adjustments for post cards */
.post-card .card-text.text-rtl,
.post-card .card-text.text-justify-rtl {
    direction: rtl !important;
    text-align: justify !important;
    text-align-last: right !important;
    font-family: 'Tahoma', 'Arial Unicode MS', 'Arial', sans-serif !important;
}

/* LTR specific adjustments for post cards */
.post-card .card-text.text-ltr,
.post-card .card-text.text-justify-ltr {
    direction: ltr !important;
    text-align: justify !important;
    text-align-last: left !important;
    font-family: 'Crimson Text', 'Times New Roman', serif !important;
}

/* Target inner p tags within post cards */
.post-card .card-text p.text-rtl,
.post-card .card-text p.text-justify-rtl {
    direction: rtl !important;
    text-align: justify !important;
    text-align-last: right !important;
    font-family: 'Tahoma', 'Arial Unicode MS', 'Arial', sans-serif !important;
}

.post-card .card-text p.text-ltr,
.post-card .card-text p.text-justify-ltr {
    direction: ltr !important;
    text-align: justify !important;
    text-align-last: left !important;
    font-family: 'Crimson Text', 'Times New Roman', serif !important;
}

/* Additional rules for inner p tags with dir attributes */
.post-card .card-text p[dir="rtl"] {
    direction: rtl !important;
    text-align: justify !important;
    text-align-last: right !important;
    font-family: 'Tahoma', 'Arial Unicode MS', 'Arial', sans-serif !important;
}

.post-card .card-text p[dir="ltr"] {
    direction: ltr !important;
    text-align: justify !important;
    text-align-last: left !important;
    font-family: 'Crimson Text', 'Times New Roman', serif !important;
}

/* Force justification on all post card text content */
.post-card .card-text,
.post-card .card-text * {
    text-align: justify !important;
}

/* Specific override for post card text content */
.post-card .card-text {
    text-align: justify !important;
    line-height: 1.6 !important;
    word-spacing: 0.1em !important;
    hyphens: auto !important;
    -webkit-hyphens: auto !important;
    -moz-hyphens: auto !important;
    -ms-hyphens: auto !important;
}

/* Maximum specificity rule for post card text */
div.post-card .card-text,
div.post-card .card-text p,
div.post-card .card-text * {
    text-align: justify !important;
    text-align-last: auto !important;
}

/* Force justification on all elements within post cards */
.post-card * {
    text-align: justify !important;
}