/* =========================================================================
   qnf-forms.css — Quick'N'Fresh form fields: RTL text handling + drop-downs
   -------------------------------------------------------------------------
   Loaded after every other admin stylesheet (including intlTelInput.css) so
   it wins by source order. Purely additive: remove the single <link> in
   layouts/admin/app.blade.php to revert.
   ========================================================================= */

/* ---------------------------------------------------------------- *
 * 1. Text direction inside fields (RTL panel)                       *
 * ---------------------------------------------------------------- */

/* Ordinary text boxes follow the page: right-to-left, whatever their class
   (search boxes, Select2 search, table filters and modal fields included).
   The earlier "plaintext" bidi rule let a box flip to left-to-right as
   soon as its text started with a Latin letter, so selection and delete ran
   the wrong way in Arabic fields (owner report, 2026-09-24). Same rule as
   the three apps: follow the screen unless the value is always Latin. */
[dir="rtl"] input:not([type]):not([dir]),
[dir="rtl"] input[type="text"]:not([dir]),
[dir="rtl"] input[type="search"]:not([dir]),
[dir="rtl"] textarea:not([dir]) {
    direction: rtl;
    unicode-bidi: normal;
    text-align: right;
}

/* Always-Latin values, and every box on an English translation tab
   (#en-form, #en-form2, …): typed left-to-right. Latin-only values stay
   aligned to the RTL edge; English-tab text aligns left like English. */
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="url"],
[dir="rtl"] input[type="tel"],
[dir="rtl"] input[type="password"],
[dir="rtl"] input[type="number"] {
    direction: ltr;
    unicode-bidi: normal;
    text-align: right;
}
[dir="rtl"] [id^="en-form"] input:not([type="checkbox"]):not([type="radio"]),
[dir="rtl"] [id^="en-form"] textarea {
    direction: ltr;
    unicode-bidi: normal;
    text-align: left;
}
/* ...but a placeholder in Arabic still reads right-to-left. */
[dir="rtl"] input[type="email"]::placeholder,
[dir="rtl"] input[type="url"]::placeholder,
[dir="rtl"] input[type="tel"]::placeholder,
[dir="rtl"] input[type="password"]::placeholder,
[dir="rtl"] input[type="number"]::placeholder {
    direction: rtl;
}

/* Phone field: the flag sits on the right in RTL; keep the number beside it. */
[dir="rtl"] .iti input[type="tel"] {
    text-align: right;
}

/* Native <select>: arrow on the left, text clear of it. */
[dir="rtl"] select.form-control,
[dir="rtl"] .custom-select {
    text-align: right;
    background-position: left 0.75rem center;
    padding-right: 0.75rem;
    padding-left: 2rem;
}

/* ---------------------------------------------------------------- *
 * 2. Select2 — closed field                                         *
 * ---------------------------------------------------------------- */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    border: 1px solid var(--qnf-border, #e6dfd3);
    border-radius: 8px;
    background-color: var(--qnf-surface, #fff); /* colour only: keeps the .custom-select arrow image */
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.select2-container--default .select2-selection--single:hover,
.select2-container--default .select2-selection--multiple:hover {
    border-color: var(--qnf-green-300);
}
.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--multiple {
    border-color: var(--qnf-green);
    box-shadow: 0 0 0 3px rgba(var(--qnf-green-rgb), 0.15);
}

/* Single: the vendor padding pushed the text below the middle line. */
.select2-container--default .select2-selection--single {
    height: var(--d-input-height, 38px);
    padding: 0;
    display: flex;
    align-items: center;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    flex: 1 1 auto;
    height: auto;
    line-height: 1.4;
    padding-top: 0;
    padding-bottom: 0;
    padding-inline-start: 12px;
    padding-inline-end: 32px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.select2-container--default .select2-selection--single .select2-selection__placeholder,
.select2-container--default .select2-selection--multiple .select2-search__field::placeholder {
    color: var(--qnf-muted, #5b6560);
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
    top: 50%;
    transform: translateY(-50%);
    height: 100%;
}
[dir="rtl"] .select2-container--default .select2-selection--single .select2-selection__arrow {
    left: 8px;
    right: auto;
}
.select2-container--default.select2-container--open .select2-selection__arrow {
    transform: translateY(-50%) rotate(180deg);
}

/* Multiple: placeholder was clipped at its first word (the vendor gives the
   search box a -15px side margin and a fixed pixel width wider than the box). */
.select2-container--default .select2-selection.select2-selection--multiple {
    height: auto;
    min-height: var(--d-input-height, 38px);
    padding: 4px 10px;
}
.select2-container--default .select2-selection--multiple .select2-selection__rendered {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    width: 100%;
    padding: 0;
    margin: 0;
}
.select2-container--default .select2-selection--multiple .select2-search--inline {
    float: none;
    flex: 1 1 0;
    min-width: 120px;
    max-width: 100%;
    margin: 0 !important;
}
.select2-container--default .select2-selection--multiple .select2-search--inline .select2-search__field {
    width: 100% !important;
    max-width: 100%;
    height: 28px;
    margin: 0;
    padding: 0 2px;
}
[dir="rtl"] .select2-container--default .select2-selection--multiple .select2-search__field {
    text-align: right;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    margin: 0;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 13px;
    line-height: 1.5;
}

/* ---------------------------------------------------------------- *
 * 3. Select2 — open list                                            *
 * ---------------------------------------------------------------- */
.select2-dropdown {
    border: 1px solid var(--qnf-border, #e6dfd3);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(22, 30, 25, 0.14);
    overflow: hidden;
    background: var(--qnf-surface, #fff);
}
.select2-container--open .select2-dropdown--below {
    margin-top: 4px;
    border-top: 1px solid var(--qnf-border, #e6dfd3);
}
.select2-container--open .select2-dropdown--above {
    margin-top: -4px;
    border-bottom: 1px solid var(--qnf-border, #e6dfd3);
}

/* Search box with a magnifier on the reading-start side. */
.select2-container--default .select2-search--dropdown {
    padding: 8px;
    border-bottom: 1px solid var(--qnf-border, #e6dfd3);
}
.select2-container--default .select2-search--dropdown .select2-search__field {
    height: 34px;
    border: 1px solid var(--qnf-border, #e6dfd3);
    border-radius: 6px;
    padding-inline-start: 32px;
    padding-inline-end: 10px;
    background: var(--qnf-surface, #fff) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238a877f' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 3.5 3.5'/%3E%3C/svg%3E") no-repeat;
    background-position: left 10px center;
}
[dir="rtl"] .select2-container--default .select2-search--dropdown .select2-search__field {
    background-position: right 10px center;
    text-align: right;
}
.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    outline: none;
    border-color: var(--qnf-green);
    box-shadow: 0 0 0 3px rgba(var(--qnf-green-rgb), 0.15);
}

.select2-container--default .select2-results > .select2-results__options {
    max-height: 260px;
    padding: 4px;
}
.select2-container--default .select2-results__option {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.4;
}
.select2-container--default .select2-results__option + .select2-results__option {
    margin-top: 1px;
}
/* Hover / keyboard focus: soft tint, readable text (was dark text on solid green). */
.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
    background: var(--qnf-green-100) !important;
    color: var(--qnf-green-700) !important;
}
/* The chosen value: solid brand green, white text. */
.select2-container--default .select2-results__option[aria-selected="true"],
.select2-container--default .select2-results__option--selected {
    background: var(--qnf-green) !important;
    color: var(--qnf-on-primary, #fff) !important;
    font-weight: 600;
}
.select2-container--default .select2-results__option[aria-disabled="true"] {
    color: var(--qnf-muted, #5b6560);
}
.select2-container--default .select2-results__group {
    padding: 8px 12px 4px;
    font-size: 12px;
    font-weight: 700;
    color: var(--qnf-muted, #5b6560);
}
.select2-results__message {
    color: var(--qnf-muted, #5b6560);
}

/* ---------------------------------------------------------------- *
 * 4. Dark theme                                                     *
 * ---------------------------------------------------------------- */
:root[data-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected],
:root[data-theme="dark"] .select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
    background: rgba(var(--qnf-green-rgb), 0.28) !important;
    color: var(--qnf-text, #f2f1ec) !important;
}
:root[data-theme="dark"] .select2-dropdown {
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}
