/* ============================================
   Form Culture Support Styles
   For bilingual forms with Arabic support
   ============================================ */

/* ============================================
   INPUT DIRECTION & ALIGNMENT
   ============================================ */

/* Auto-direction for text inputs */
input[dir="auto"],
textarea[dir="auto"],
[contenteditable="true"][dir="auto"] {
    text-align: start;
}

/* LTR inputs (numbers, emails, URLs) */
input[type="number"],
input[type="email"],
input[type="url"],
input[dir="ltr"] {
    direction: ltr;
    text-align: left;
}

/* RTL for Arabic context */
html[lang="ar"] input[type="text"],
html[lang="ar"] textarea,
html[dir="rtl"] input[type="text"],
html[dir="rtl"] textarea {
    text-align: start;
}

/* ============================================
   NUMERIC INPUTS
   ============================================ */

/* Bilingual numeric inputs */
input.numeric-bilingual,
input[data-numeric-bilingual="true"] {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

html[lang="ar"] input.numeric-bilingual,
html[lang="ar"] input[data-numeric-bilingual="true"],
html[dir="rtl"] input.numeric-bilingual,
html[dir="rtl"] input[data-numeric-bilingual="true"] {
    text-align: left;
    direction: ltr;
}

/* Number input styling */
input[type="number"] {
    -moz-appearance: textfield;
    font-variant-numeric: tabular-nums;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ============================================
   FORM LABELS
   ============================================ */

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

html[lang="ar"] label,
html[dir="rtl"] label {
    text-align: start;
}

/* Required field indicator */
label.required::after,
label[required]::after {
    content: " *";
    color: #dc3545;
    margin-inline-start: 0.25rem;
}

html[lang="ar"] label.required::after,
html[lang="ar"] label[required]::after {
    content: " *";
}

/* ============================================
   INPUT GROUPS
   ============================================ */

.input-group {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    width: 100%;
}

html[dir="rtl"] .input-group {
    flex-direction: row-reverse;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    font-weight: 400;
    line-height: 1.5;
    color: #495057;
    text-align: center;
    white-space: nowrap;
    background-color: #e9ecef;
    border: 1px solid #ced4da;
}

html[dir="rtl"] .input-group-text {
    border-radius: 0.25rem 0 0 0.25rem;
}

html[dir="ltr"] .input-group-text {
    border-radius: 0 0.25rem 0.25rem 0;
}

/* ============================================
   CURRENCY INPUTS
   ============================================ */

.currency-input-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.currency-symbol {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    pointer-events: none;
    font-weight: 500;
}

html[dir="ltr"] .currency-symbol {
    left: 0.75rem;
}

html[dir="rtl"] .currency-symbol {
    right: 0.75rem;
}

html[dir="ltr"] .currency-input-wrapper input {
    padding-left: 2rem;
}

html[dir="rtl"] .currency-input-wrapper input {
    padding-right: 2rem;
}

/* ============================================
   PHONE NUMBER INPUTS
   ============================================ */

input[type="tel"] {
    direction: ltr;
    text-align: left;
    font-family: 'Courier New', monospace;
}

/* ============================================
   VALIDATION STYLES
   ============================================ */

.is-invalid {
    border-color: #dc3545 !important;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

html[dir="rtl"] .is-invalid {
    padding-right: 0.75rem;
    padding-left: calc(1.5em + 0.75rem);
    background-position: left calc(0.375em + 0.1875rem) center;
}

.invalid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #dc3545;
}

.invalid-feedback.d-block {
    display: block;
}

.is-valid {
    border-color: #28a745 !important;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2328a745' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

html[dir="rtl"] .is-valid {
    padding-right: 0.75rem;
    padding-left: calc(1.5em + 0.75rem);
    background-position: left calc(0.375em + 0.1875rem) center;
}

.valid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #28a745;
}

.valid-feedback.d-block {
    display: block;
}

/* ============================================
   FORM CONTROL BASE
   ============================================ */

.form-control {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    color: #495057;
    background-color: #fff;
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

html[lang="ar"] .form-control,
html[dir="rtl"] .form-control {
    font-family: 'Noto Sans Arabic', 'Cairo', 'Segoe UI Arabic', 'Tahoma', sans-serif;
}

/* ============================================
   SELECT DROPDOWNS
   ============================================ */

select.form-control {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3e%3cpath fill='%23343a40' d='M2 0L0 2h4zm0 5L0 3h4z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-size: 8px 10px;
    padding-right: 1.5rem;
}

html[dir="ltr"] select.form-control {
    background-position: right 0.75rem center;
}

html[dir="rtl"] select.form-control {
    background-position: left 0.75rem center;
    padding-right: 0.75rem;
    padding-left: 1.5rem;
}

/* ============================================
   CHECKBOXES & RADIO BUTTONS
   ============================================ */

.form-check {
    position: relative;
    display: block;
    padding-left: 1.25rem;
}

html[dir="rtl"] .form-check {
    padding-left: 0;
    padding-right: 1.25rem;
}

.form-check-input {
    position: absolute;
    margin-top: 0.3rem;
    margin-left: -1.25rem;
}

html[dir="rtl"] .form-check-input {
    margin-left: 0;
    margin-right: -1.25rem;
}

.form-check-label {
    margin-bottom: 0;
}

/* ============================================
   DATE INPUTS
   ============================================ */

input[type="date"],
input[type="datetime-local"],
input[type="time"] {
    direction: ltr;
}

/* ============================================
   PLACEHOLDER TEXT
   ============================================ */

::placeholder {
    color: #6c757d;
    opacity: 0.6;
}

html[lang="ar"] ::placeholder,
html[dir="rtl"] ::placeholder {
    text-align: start;
}

/* ============================================
   FORM GROUPS
   ============================================ */

.form-group {
    margin-bottom: 1rem;
}

html[lang="ar"] .form-group,
html[dir="rtl"] .form-group {
    text-align: start;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
    .form-control {
        font-size: 16px; /* Prevent iOS zoom on focus */
    }
    
    label {
        font-size: 0.9rem;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus visible for keyboard navigation */
.form-control:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================
   END OF FORM CULTURE STYLESHEET
   ============================================ */

