/* ══════════════════════════════════════════════════════════════════════════════
   Vendor widget theming.

   select2 and persian-datepicker both ship a light-only stylesheet built for a
   white page. Dropped into this glassmorphism theme untouched, they render as
   bright white rectangles on a near-black page — which is exactly the kind of
   thing that looks fine in a screenshot of one component and awful in the
   product. Every rule below re-points a vendor colour at a design token from
   site.css, so both widgets follow the dark/light toggle for free.

   Load order matters: this file must come AFTER select2.min.css and
   persian-datepicker.css.
════════════════════════════════════════════════════════════════════════════════ */

/* ────────────────────────────── select2 ────────────────────────────────────── */

.select2-container { width: 100% !important; }

/* Closed control — matched to .form-control in site.css so a select2 and a plain
   input sitting next to each other are the same height and colour. */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    min-height: 40px;
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

[data-theme="light"] .select2-container--default .select2-selection--single,
[data-theme="light"] .select2-container--default .select2-selection--multiple {
    background: #fff;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 3px rgba(var(--clr-primary-rgb), 0.15);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--text-primary);
    line-height: 38px;
    padding-inline-start: 0.85rem;
    padding-inline-end: 2rem;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: var(--text-muted);
}

/* The arrow is absolutely positioned with `right` by the vendor, which puts it
   on the wrong side in RTL. */
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 38px;
    right: auto;
    left: 6px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: var(--text-secondary) transparent transparent transparent;
}
.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: transparent transparent var(--text-secondary) transparent;
}

/* The "x" that clears a single select. */
.select2-container--default .select2-selection--single .select2-selection__clear {
    color: var(--text-muted);
    margin-inline-end: 0.5rem;
    font-weight: 400;
}
.select2-container--default .select2-selection--single .select2-selection__clear:hover {
    color: var(--clr-danger);
}

/* Multi-select pills. */
.select2-container--default .select2-selection--multiple .select2-selection__rendered {
    padding: 0.25rem 0.4rem;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background: rgba(var(--clr-primary-rgb), 0.16);
    border: 1px solid rgba(var(--clr-primary-rgb), 0.32);
    border-radius: 50px;
    color: var(--text-primary);
    padding: 0.1rem 0.6rem;
    margin-top: 0.28rem;
    margin-inline-end: 0.3rem;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: var(--clr-primary);
    margin-inline-end: 0.35rem;
    border: 0;
    background: transparent;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: var(--clr-danger);
    background: transparent;
}

/* Open dropdown. z-index sits above .admin-topbar (1020) and below the mobile
   sidebar overlay (1040) so it cannot be trapped under a sticky header. */
.select2-container--default .select2-dropdown {
    background: var(--bg-elevated);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--glass-shadow);
    z-index: 1030;
}

.select2-container--default .select2-results__option {
    color: var(--text-secondary);
    padding: 0.5rem 0.85rem;
    font-size: 0.9rem;
}
.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted {
    background: rgba(var(--clr-primary-rgb), 0.16);
    color: var(--text-primary);
}
.select2-container--default .select2-results__option[aria-selected="true"],
.select2-container--default .select2-results__option[data-selected="true"] {
    background: rgba(var(--clr-primary-rgb), 0.28);
    color: #fff;
}
.select2-container--default .select2-results__message {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Search box inside the dropdown. */
.select2-container--default .select2-search--dropdown { padding: 0.5rem; }
.select2-container--default .select2-search--dropdown .select2-search__field {
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.4rem 0.6rem;
    outline: none;
}
.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--clr-primary);
}
.select2-container--default .select2-search--inline .select2-search__field {
    color: var(--text-primary);
    margin-top: 0.4rem;
}

/* A select2 inside a disabled fieldset must still look disabled. */
.select2-container--disabled .select2-selection--single { opacity: 0.55; }


/* ───────────────────────── persian-datepicker ──────────────────────────────── */

.pdp-popup {
    background: var(--bg-elevated);
    box-shadow: var(--glass-shadow), 0 0 0 1px var(--glass-border);
    border-radius: var(--radius-md);
    /* Above the sticky topbar, same band as the select2 dropdown. */
    z-index: 1030;
}

.pdp-title { color: var(--text-primary); }
.pdp-nav-btn { color: var(--text-secondary); }
.pdp-nav-btn:hover { background: rgba(var(--clr-primary-rgb), 0.12); color: var(--text-primary); }

.pdp-year-input {
    background: var(--bg-surface);
    box-shadow: inset 0 0 0 1px var(--glass-border);
    color: var(--text-primary);
}
.pdp-year-input:focus { box-shadow: inset 0 0 0 2px var(--clr-primary); }

.pdp-weekday { color: var(--text-muted); }
.pdp-day { color: var(--text-secondary); }
.pdp-day:hover { background: rgba(var(--clr-primary-rgb), 0.14); color: var(--clr-primary); }
.pdp-day-today { box-shadow: inset 0 0 0 1px var(--clr-primary); }
.pdp-day-selected,
.pdp-day-selected:hover { background: var(--clr-primary); color: #fff; }
.pdp-day-disabled,
.pdp-day-disabled:hover { color: var(--text-muted); opacity: 0.4; background: transparent; cursor: not-allowed; }

.pdp-footer { border-top: 1px solid var(--glass-border); }
.pdp-link { color: var(--clr-primary); }

/* The visible input is forced LTR by the widget so the digits read naturally.
   These two rules keep it looking like every other .form-control. */
.mcdp-rtl-input {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.5rem 0.85rem;
    width: 100%;
}
[data-theme="light"] .mcdp-rtl-input { background: #fff; }
.mcdp-rtl-input:focus { outline: none; border-color: var(--clr-primary); }

/* Invalid-input feedback from the widget (an out-of-range or half-typed date). */
.mcdp-rtl-input.ring-red-400 { box-shadow: inset 0 0 0 2px var(--clr-danger); }
