/* Tom Select theme overrides — Odoo-style many2many_tags look.
   Layered on top of tom-select.bootstrap5.min.css (CDN). Uses the club's
   --color-primario CSS var so pills re-tint automatically when the theme
   changes. Cargado GLOBALMENTE desde _Layout (07/09/2026): todos los desplegables de la app
   son Tom Select (ver tom-select-global.js); este archivo cubre el widget dentro de .rt-form
   (underline), fuera de él (caja tematizada) y la variante compacta de los filtros de listados. */

/* ── Container ────────────────────────────────────────────── */
.ts-wrapper.multi .ts-control,
.ts-wrapper.single .ts-control {
    border: 1px solid var(--border, #dee2e6);
    border-radius: 0.375rem;
    padding: 4px 8px;
    min-height: calc(1.5em + 0.75rem + 2px);
    background: var(--bg-2, #fff);
    color: var(--text, inherit);
    box-shadow: none;
}

/* Tom Select copia las clases del <select> al wrapper: la clase `form-select` de Bootstrap
   traería su propio caret, borde y padding al wrapper. Se neutralizan; el caret es el ::after
   de abajo y la caja vive en .ts-control. */
.ts-wrapper.form-select,
.ts-wrapper.form-select.single,
.ts-wrapper.form-select.multi {
    background-image: none !important;
    background-color: transparent !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
}
.ts-wrapper.form-select .ts-control { background-image: none !important; }
.ts-wrapper .ts-control > .item { color: var(--text, inherit); }
.ts-wrapper.single .ts-control > input { color: var(--text, inherit); }

/* Inside ref-table forms (.rt-form) the widget must match the underline-only
   pattern used by every other input in the form: transparent, no box, one
   single border-bottom spanning the full width (including under the caret).
   The <select> carries `form-control` which Tom Select copies to the
   `.ts-wrapper`; that wrapper is where the underline must live so the caret
   pseudo-element (rendered inside the wrapper) sits above the same line as
   the pill + placeholder text.
   The inner `.ts-control` stays fully transparent and borderless so there
   is no double underline. */
.rt-form .ts-wrapper.multi,
.rt-form .ts-wrapper.single {
    background: transparent !important;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border) !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    transition: border-bottom-color 0.15s;
}
.rt-form .ts-wrapper.multi.focus,
.rt-form .ts-wrapper.single.focus {
    border-bottom-color: var(--color-primario) !important;
}
.rt-form .ts-wrapper.multi .ts-control,
.rt-form .ts-wrapper.single .ts-control {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 4px 28px 6px 0 !important;
    min-height: 32px !important;
    box-shadow: none !important;
}
.rt-form .ts-wrapper.multi .ts-control > input,
.rt-form .ts-wrapper.single .ts-control > input {
    font-size: 14px;
    color: var(--text);
    background: transparent !important;
    border: none !important;
    border-bottom: none !important;
    padding: 2px 4px !important;
    box-shadow: none !important;
}
.rt-form .ts-wrapper.multi .ts-control > input::placeholder,
.rt-form .ts-wrapper.single .ts-control > input::placeholder {
    color: color-mix(in srgb, var(--text) 55%, transparent);
}

/* ── Focus ────────────────────────────────────────────────── */
.ts-wrapper.focus .ts-control {
    border-color: var(--color-primario);
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--color-primario) 25%, transparent);
    outline: none;
}

/* ── Pill (selected tag) ──────────────────────────────────── */
.ts-wrapper.multi .ts-control > .item {
    background: color-mix(in srgb, var(--color-primario) 15%, transparent);
    color: color-mix(in srgb, var(--color-primario) 80%, #000);
    border: none;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.85rem;
    font-weight: 500;
    margin: 2px 4px 2px 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1.4;
}

/* ── Pill remove (×) ──────────────────────────────────────── */
.ts-wrapper.multi .ts-control > .item .remove {
    border: none;
    padding: 0 6px;
    margin-left: 4px;
    opacity: 0.5;
    transition: opacity 0.15s;
    background: transparent;
    color: inherit;
    font-size: 1rem;
    line-height: 1;
    text-decoration: none;
}
.ts-wrapper.multi .ts-control > .item .remove:hover {
    opacity: 1;
    background: transparent;
}

/* ── Dropdown caret on the right ─────────────────────────── */
.ts-wrapper.multi,
.ts-wrapper.single { position: relative; }
.ts-wrapper.multi .ts-control,
.ts-wrapper.single .ts-control {
    padding-right: 28px;
}
.ts-wrapper.multi::after,
.ts-wrapper.single::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 10px;
    width: 12px;
    height: 12px;
    transform: translateY(-50%);
    pointer-events: none;
    background: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%238a8a94' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
    opacity: 0.7;
    transition: transform 0.15s;
}
.ts-wrapper.focus::after {
    transform: translateY(-50%) rotate(180deg);
    opacity: 1;
}

/* ── Inner input ─────────────────────────────────────────── */
.ts-control input {
    padding: 2px 4px !important;
    font-size: inherit;
    min-height: auto;
    box-shadow: none !important;
}

/* ── Dropdown ────────────────────────────────────────────── */
.ts-dropdown {
    border: 1px solid var(--border, #dee2e6);
    border-radius: 0.375rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    margin-top: 4px;
    background: var(--bg-2, #fff);
    color: var(--text, inherit);
    z-index: 1100;                 /* por encima de los modales (.rt-modal es 1055) */
}
/* Volteado hacia arriba cuando abajo no entra (tom-select-global.js, item 2 del 20/09/2026).
   El wrapper es position:relative, asi que basta cambiar el anclaje vertical. */
.ts-wrapper.ts-drop-up .ts-dropdown {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 4px;
}
.ts-dropdown .optgroup-header {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: color-mix(in srgb, var(--text, #000) 55%, transparent);
    background: transparent;
}
.ts-dropdown .option.disabled, .ts-dropdown [data-selectable].disabled { opacity: 0.45; }
.ts-dropdown-input {
    background: var(--bg-2, #fff);
    color: var(--text, inherit);
    border-color: var(--border, #dee2e6);
}

/* ── Filtros compactos de los listados (.rt-filter-compact) ──
   La clase se copia al wrapper y site.css le daría caja, alto y caret propios: se anulan en el
   wrapper y la caja de 30px vive en .ts-control, con la letra chica de los chips. */
.ts-wrapper.rt-filter-compact {
    height: auto !important;
    min-width: 120px;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
    font-size: 0.78rem;
    display: inline-block;
    vertical-align: middle;
}
.ts-wrapper.rt-filter-compact .ts-control {
    min-height: 30px !important;
    height: 30px;
    padding: 2px 26px 2px 10px !important;
    border: 1px solid var(--border, #dee2e6);
    border-radius: 3px;
    background: var(--bg-2, #fff);
    font-size: 0.78rem;
    line-height: 1.5;
    box-shadow: none;
}
.ts-wrapper.rt-filter-compact .ts-control > input { font-size: 0.78rem; }
.ts-wrapper.rt-filter-compact .ts-control { overflow: hidden; }
.ts-wrapper.rt-filter-compact .ts-control > .item {
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: block;
}
.ts-wrapper.rt-filter-compact::after { right: 8px; width: 10px; height: 10px; }
.ts-wrapper.rt-filter-compact .ts-dropdown { font-size: 0.8rem; min-width: 180px; }
@media (max-width: 640px) {
    .ts-wrapper.rt-filter-compact { flex: 1 1 auto; min-width: 120px; }
}

/* Sin caja de búsqueda (menos de 6 opciones): el control no debe reservar alto para el input. */
.ts-wrapper.single.no-search .ts-control { cursor: pointer; }
.ts-dropdown .active {
    background: color-mix(in srgb, var(--color-primario) 10%, transparent);
    color: inherit;
}
.ts-dropdown .highlight {
    background: color-mix(in srgb, var(--color-primario) 25%, transparent);
    font-weight: 600;
    border-radius: 2px;
}

/* ── Compact mode for large rival sets (tournament teams), scoped to .rivals-select ──
   Smaller pills + a scrollable control so ~16+ chips scroll instead of overflowing the form. */
.rivals-select .ts-wrapper.multi .ts-control {
    max-height: 120px;
    overflow-y: auto;
}
.rivals-select .ts-wrapper.multi .ts-control > .item {
    padding: 1px 8px;
    margin: 2px 4px 0 0;
    font-size: 0.78rem;
    line-height: 1.35;
}

/* Derived count shown next to the "Rivals" label. */
.rivals-count {
    color: color-mix(in srgb, var(--text) 55%, transparent);
    font-weight: 600;
    font-size: 0.85em;
}

/* ── Convocatoria › "+Agregar": sin coincidencias, el desplegable ofrece el alta en el Plantel
   (clases propias: la global .no-results de site.css está en display:none). ── */
.ts-dropdown .ts-no-results {
    padding: 8px 10px;
    color: var(--text-dim);
}
.ts-dropdown .ts-not-found {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
}
.ts-dropdown .ts-not-found .rt-btn-mini { white-space: nowrap; }
