/* ============================================
   Kalium Intranet — Estilos del selector de roles (RoleSelect)
   ============================================ */

.rs-native {
    display: none !important;
}

.rs-widget {
    position: relative;
    width: 100%;
    font-size: 13px;
}

.rs-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 38px;
    padding: 6px 10px;
    background: var(--bg-secondary, #161b22);
    border: 1px solid var(--border-color, #30363d);
    border-radius: 8px;
    color: var(--text-primary, #e6edf3);
    cursor: pointer;
    text-align: left;
    transition: border-color .15s, box-shadow .15s;
}

.rs-trigger:hover,
.rs-widget.rs-open .rs-trigger {
    border-color: var(--accent, #7c3aed);
}

.rs-widget.rs-open .rs-trigger {
    box-shadow: 0 0 0 3px rgba(124, 58, 237, .15);
}

.rs-values {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.rs-placeholder {
    color: var(--text-secondary, #8b949e);
}

.rs-value-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rs-caret {
    color: var(--text-secondary, #8b949e);
    font-size: 11px;
    flex-shrink: 0;
    transition: transform .15s;
}

.rs-widget.rs-open .rs-caret {
    transform: rotate(180deg);
}

.rs-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1200;
    display: none;
    flex-direction: column;
    max-height: 300px;
    background: var(--bg-secondary, #161b22);
    border: 1px solid var(--border-color, #30363d);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
    overflow: hidden;
}

.rs-widget.rs-open .rs-dropdown {
    display: flex;
}

.rs-search {
    padding: 6px;
    border-bottom: 1px solid var(--border-color, #30363d);
    flex-shrink: 0;
}

.rs-search-input {
    width: 100%;
    padding: 6px 10px;
    background: var(--bg-primary, #1c2128);
    border: 1px solid var(--border-color, #30363d);
    border-radius: 6px;
    color: var(--text-primary, #e6edf3);
    font-size: 12px;
    outline: none;
}

.rs-search-input:focus {
    border-color: var(--accent, #7c3aed);
}

.rs-options {
    overflow-y: auto;
    max-height: 240px;
    padding: 4px;
    flex: 1;
}

.rs-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary, #e6edf3);
}

.rs-option:hover,
.rs-option.rs-active {
    background: rgba(124, 58, 237, .12);
}

.rs-option.rs-selected {
    background: rgba(124, 58, 237, .08);
}

.rs-option.rs-selected.rs-active,
.rs-option.rs-selected:hover {
    background: rgba(124, 58, 237, .18);
}

.rs-option.rs-locked {
    opacity: .5;
    cursor: not-allowed;
}

.rs-option-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.rs-option-label {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.3;
}

.rs-option-sub {
    font-size: 10px;
    color: var(--text-secondary, #8b949e);
}

.rs-option-lock {
    color: #f43f5e;
    font-size: 11px;
    flex-shrink: 0;
}

.rs-option-check {
    color: var(--accent, #7c3aed);
    font-size: 11px;
    flex-shrink: 0;
}

.rs-empty {
    padding: 14px;
    text-align: center;
    color: var(--text-secondary, #8b949e);
    font-size: 12px;
}

/* Badges de rol reutilizables (tablas, tooltips) */
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    vertical-align: middle;
}

.role-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Focus y estado del trigger (ahora es un div role=combobox) ── */
.rs-trigger {
    user-select: none;
    outline: none;
}

.rs-trigger:focus-visible,
.rs-trigger:focus {
    border-color: var(--accent, #7c3aed);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, .15);
}

/* ── Chips removibles (multi-select) ── */
.rs-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    max-width: 100%;
}

.rs-chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.rs-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .14);
    color: inherit;
    font-size: 9px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.rs-chip-remove:hover {
    background: rgba(255, 255, 255, .28);
}

/* ── Checkboxes en las opciones (multi-select) ── */
.rs-option-checkbox {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border-color, #30363d);
    border-radius: 4px;
    background: var(--bg-primary, #1c2128);
    color: transparent;
    font-size: 9px;
    flex-shrink: 0;
    transition: background .12s, border-color .12s, color .12s;
}

.rs-option.rs-selected .rs-option-checkbox {
    background: var(--accent, #7c3aed);
    border-color: var(--accent, #7c3aed);
    color: #fff;
}

.rs-option.rs-locked .rs-option-checkbox {
    opacity: .5;
}

/* ── Estados vacío / sin sincronizar ── */
.rs-empty {
    padding: 18px 14px;
    text-align: center;
    color: var(--text-secondary, #8b949e);
    font-size: 12px;
}

.rs-empty-icon {
    font-size: 20px;
    margin-bottom: 6px;
    opacity: .7;
}

.rs-empty-title {
    margin-bottom: 10px;
    line-height: 1.4;
}

.rs-sync-btn {
    margin-top: 2px;
}

/* ── Skeleton loader (carga / sincronización) ── */
.rs-skeleton-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
}

.rs-skeleton-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bg-primary, #1c2128);
    flex-shrink: 0;
}

.rs-skeleton-line {
    display: inline-block;
    height: 10px;
    border-radius: 4px;
    background: linear-gradient(90deg,
            var(--bg-primary, #1c2128) 25%,
            rgba(255, 255, 255, .08) 50%,
            var(--bg-primary, #1c2128) 75%);
    background-size: 200% 100%;
    animation: rs-shimmer 1.2s infinite;
}

.rs-skeleton-hint {
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary, #8b949e);
    padding: 2px 0 12px;
}

@keyframes rs-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==========================================================
   RESPONSIVE — Role Selector
   ========================================================== */

@media (max-width: 768px) {
    .rs-widget { font-size: 12px; }
    .rs-trigger { min-height: 42px; padding: 5px 8px; }
    .rs-dropdown { max-height: 260px; }
    .rs-option { padding: 8px 10px; min-height: 40px; }
    .rs-search-input { padding: 8px 10px; font-size: 13px; }
}

@media (max-width: 480px) {
    .rs-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 50vh;
        border-radius: 12px 12px 0 0;
        z-index: 1300;
    }
    .rs-option { min-height: 44px; }
}

/* ── Touch targets ── */
@media (hover:none), (pointer:coarse) {
    .rs-trigger { min-height: 44px; }
    .rs-option { min-height: 44px; }
    .rs-chip-remove { width: 20px; height: 20px; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    .rs-trigger, .rs-option, .rs-dropdown {
        transition: none;
    }
}


/* ==========================================================
   RESPONSIVE · MÓVIL · TÁCTIL (adiciones)
   ========================================================== */

/* Anti-zoom iOS: el buscador del selector estaba a 12-13px. */
@media (max-width: 768px) {
    .rs-search-input { font-size: 16px !important; min-height: 44px; }
}

@media (max-width: 480px) {
    /* Bottom sheet: el home indicator tapaba la última opción. */
    .rs-dropdown {
        padding-bottom: env(safe-area-inset-bottom);
        max-height: 60vh;
        -webkit-overflow-scrolling: touch;
    }
}

@media (hover:none), (pointer:coarse) {
    /* La X del chip era de 16-20px: por debajo del mínimo táctil (24px)
       y muy lejos de los 44px recomendados. */
    .rs-chip-remove { width: 32px; height: 32px; font-size: 12px; }
    .rs-option-checkbox { width: 20px; height: 20px; font-size: 11px; }
}
